Thread (38 messages) 38 messages, 4 authors, 2020-11-01

Re: [PATCH 2/4] PM: hibernate: improve robustness of mapping pages in the direct map

From: Mike Rapoport <rppt@kernel.org>
Date: 2020-10-29 07:56:11
Also in: linux-mm, linux-pm, linux-riscv, linux-s390, linuxppc-dev, lkml, sparclinux

On Wed, Oct 28, 2020 at 09:15:38PM +0000, Edgecombe, Rick P wrote:
On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote:
quoted
+       if (IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) {
+               unsigned long addr = (unsigned
long)page_address(page);
+               int ret;
+
+               if (enable)
+                       ret = set_direct_map_default_noflush(page);
+               else
+                       ret = set_direct_map_invalid_noflush(page);
+
+               if (WARN_ON(ret))
+                       return;
+
+               flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
+       } else {
+               debug_pagealloc_map_pages(page, 1, enable);
+       }
Looking at the arm side again, I think this might actually introduce a
regression for the arm/hibernate/DEBUG_PAGEALLOC combo.

Unlike __kernel_map_pages(), it looks like arm's cpa will always bail
in the set_direct_map_() functions if rodata_full is false.

So if rodata_full was disabled but debug page alloc is on, then this
would now skip remapping the pages. I guess the significance depends
on whether hibernate could actually try to save any DEBUG_PAGEALLOC
unmapped pages. Looks like it to me though.
 
__kernel_map_pages() on arm64 will also bail out if rodata_full is
false:

void __kernel_map_pages(struct page *page, int numpages, int enable)
{
	if (!debug_pagealloc_enabled() && !rodata_full)
		return;

	set_memory_valid((unsigned long)page_address(page), numpages, enable);
}

So using set_direct_map() to map back pages removed from the direct map
with __kernel_map_pages() seems safe to me.

-- 
Sincerely yours,
Mike.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help