[PATCH v2 10/13] arc: use FLATMEM with freeing of unused memory map instead of DISCONTIGMEM

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport Currently ARC uses DISCONTIGMEM to cope with sparse physical memory address space on systems with 2 memory banks. While DISCONTIGMEM avoids wasting memory on unpopulated memory map, it adds both memory and CPU overhead relatively to FLATMEM. Moreover, DISCONTINGMEM

[PATCH v2 13/13] m68k: deprecate DISCONTIGMEM

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport DISCONTIGMEM was intended to provide more efficient support for systems with holes in their physical address space that FLATMEM did. Yet, it's overhead in terms of the memory consumption seems to overweight the savings on the unused memory map. For a ARAnyM system with 16

[PATCH v2 11/13] m68k/mm: make node data and node setup depend on CONFIG_DISCONTIGMEM

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport The pg_data_t node structures and their initialization currently depends on !CONFIG_SINGLE_MEMORY_CHUNK. Since they are required only for DISCONTIGMEM make this dependency explicit and replace usage of CONFIG_SINGLE_MEMORY_CHUNK with CONFIG_DISCONTIGMEM where appropriate

[PATCH v2 12/13] m68k/mm: enable use of generic memory_model.h for !DISCONTIGMEM

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport The pg_data_map and pg_data_table arrays as well as page_to_pfn() and pfn_to_page() are required only for DISCONTIGMEM. Other memory models can use the generic definitions in asm-generic/memory_model.h. Signed-off-by: Mike Rapoport --- arch/m68k/Kconfig.cpu

[PATCH v2 08/13] arm: remove CONFIG_ARCH_HAS_HOLES_MEMORYMODEL

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport ARM is the only architecture that defines CONFIG_ARCH_HAS_HOLES_MEMORYMODEL which in turn enables memmap_valid_within() function that is intended to verify existence of struct page associated with a pfn when there are holes in the memory map. However

[PATCH v2 09/13] arm, arm64: move free_unused_memmap() to generic mm

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport ARM and ARM64 free unused parts of the memory map just before the initialization of the page allocator. To allow holes in the memory map both architectures overload pfn_valid() and define HAVE_ARCH_PFN_VALID. Allowing holes in the memory map for FLATMEM may be useful

[PATCH v2 06/13] ia64: forbid using VIRTUAL_MEM_MAP with FLATMEM

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport Virtual memory map was intended to avoid wasting memory on the memory map on systems with large holes in the physical memory layout. Long ago it been superseded first by DISCONTIGMEM and then by SPARSEMEM. Moreover, SPARSEMEM_VMEMMAP provide the same functionality in much

[PATCH v2 03/13] ia64: remove 'ifdef CONFIG_ZONE_DMA32' statements

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport After the removal of SN2 platform (commit cf07cb1ff4ea ("ia64: remove support for the SGI SN2 platform") IA-64 always has ZONE_DMA32 and there is no point to guard code with this configuration option. Remove ifdefery associated with CONFIG_ZONE_DMA32 Signed-of

[PATCH v2 05/13] ia64: split virtual map initialization out of paging_init()

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport For both FLATMEM and DISCONTIGMEM/SPARSEMEM the virtual map initialization is spread over paging_init() for no good reason. Split out the bits related to virtual map initialization to a helper functions, one for FLATMEM and another for !FLATMEM configurations. Signed-off

[PATCH v2 04/13] ia64: discontig: paging_init(): remove local max_pfn calculation

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport The maximal PFN in the system is calculated during find_memory() time and it is stored at max_low_pfn then. Use this value in paging_init() and remove the redundant detection of max_pfn in that function. Signed-off-by: Mike Rapoport --- arch/ia64/mm/discontig.c | 5

[PATCH v2 07/13] ia64: make SPARSEMEM default and disable DISCONTIGMEM

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport SPARSEMEM memory model suitable for systems with large holes in their phyiscal memory layout. With SPARSEMEM_VMEMMAP enabled it provides pfn_to_page() and page_to_pfn() as fast as FLATMEM. Make it the default memory model for IA-64 and disable DISCONTIGMEM which

[PATCH v2 01/13] alpha: switch from DISCONTIGMEM to SPARSEMEM

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport Enable SPARSEMEM support on alpha and deprecate DISCONTIGMEM. The required changes are mostly around moving duplicated definitions of page access and address conversion macros to a common place and making sure they are available for all memory models. The DISCONTINGMEM

[PATCH v2 00/13] arch, mm: deprecate DISCONTIGMEM

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport Hi, It's been a while since DISCONTIGMEM is generally considered deprecated, but it is still used by four architectures. This set replaces DISCONTIGMEM with a different way to handle holes in the memory map and marks DISCONTIGMEM configuration as BROKEN in Kconfigs

[PATCH v2 02/13] ia64: remove custom __early_pfn_to_nid()

2020-11-01 Thread Mike Rapoport
From: Mike Rapoport The ia64 implementation of __early_pfn_to_nid() essentially relies on the same data as the generic implementation. The correspondence between memory ranges and nodes is set in memblock during early memory initialization in register_active_ranges() function

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

2020-11-01 Thread Mike Rapoport
On Thu, Oct 29, 2020 at 11:19:18PM +, Edgecombe, Rick P wrote: > On Thu, 2020-10-29 at 09:54 +0200, Mike Rapoport wrote: > > __kernel_map_pages() on arm64 will also bail out if rodata_full is > > false: > > void __kernel_map_pages(struct page *page, int

Re: [PATCH 11/13] m68k/mm: make node data and node setup depend on CONFIG_DISCONTIGMEM

2020-11-01 Thread Mike Rapoport
On Wed, Oct 28, 2020 at 01:16:41PM +0200, Mike Rapoport wrote: > Hi Geert, > > On Wed, Oct 28, 2020 at 10:25:49AM +0100, Geert Uytterhoeven wrote: > > Hi Mike, > > > > On Tue, Oct 27, 2020 at 12:31 PM Mike Rapoport wrote: > > > From: Mike Rapoport >

Re: [PATCH] ARM, xtensa: highmem: avoid clobbering non-page aligned memory reservations

2020-10-31 Thread Mike Rapoport
On Sat, Oct 31, 2020 at 09:37:09AM -0700, Max Filippov wrote: > On Sat, Oct 31, 2020 at 2:43 AM Mike Rapoport wrote: > > Please let me know how do you prefer to take it upstream. > > If needed this can go via memblock tree. > > Going through the memblock tree sounds righ

Re: [PATCH] ARM, xtensa: highmem: avoid clobbering non-page aligned memory reservations

2020-10-31 Thread Mike Rapoport
RM Linux admin > > > wrote: > > > > > > > > On Sat, Oct 31, 2020 at 11:43:45AM +0200, Mike Rapoport wrote: > > > > > From: Ard Biesheuvel > > > > > > > > > > free_highpages() iterates over the free memblock regi

[PATCH] ARM, xtensa: highmem: avoid clobbering non-page aligned memory reservations

2020-10-31 Thread Mike Rapoport
id freeing reserved pages. Fixes: cddb5ddf2b76 ("arm, xtensa: simplify initialization of high memory pages") Link: https://lore.kernel.org/r/20201029110334.4118-1-a...@kernel.org/ Signed-off-by: Ard Biesheuvel Co-developed-by: Mike Rapoport Signed-off-by: Mike Rapoport --- Max, Russell,

Re: [PATCH v2 5/6] RISC-V: Protect .init.text & .init.data

2020-10-30 Thread Mike Rapoport
On Thu, Oct 29, 2020 at 12:21:41PM -0700, Atish Patra wrote: > On Tue, Oct 27, 2020 at 3:46 AM Mike Rapoport wrote: > > > > On Mon, Oct 26, 2020 at 04:02:53PM -0700, Atish Patra wrote: > > > Currently, .init.text & .init.data are intermixed which makes it > >

Re: mm/memblock: export memblock_{start/end}_of_DRAM

2020-10-30 Thread Mike Rapoport
On Thu, Oct 29, 2020 at 02:29:27PM -0700, Sudarshan Rajagopalan wrote: > Hello all, > > We have a usecase where a module driver adds certain memory blocks using > add_memory_driver_managed(), so that it can perform memory hotplug > operations on these blocks. In general, these memory blocks

[PATCH v2 2/4] PM: hibernate: make direct map manipulations more explicit

2020-10-29 Thread Mike Rapoport
From: Mike Rapoport When DEBUG_PAGEALLOC or ARCH_HAS_SET_DIRECT_MAP is enabled a page may be not present in the direct map and has to be explicitly mapped before it could be copied. On arm64 it is possible that a page would be removed from the direct map using set_direct_map_invalid_noflush

[PATCH v2 4/4] arch, mm: make kernel_page_present() always available

2020-10-29 Thread Mike Rapoport
From: Mike Rapoport For architectures that enable ARCH_HAS_SET_MEMORY having the ability to verify that a page is mapped in the kernel direct map can be useful regardless of hibernation. Add RISC-V implementation of kernel_page_present(), update its forward declarations and stubs to be a part

[PATCH v2 3/4] arch, mm: restore dependency of __kernel_map_pages() of DEBUG_PAGEALLOC

2020-10-29 Thread Mike Rapoport
From: Mike Rapoport The design of DEBUG_PAGEALLOC presumes that __kernel_map_pages() must never fail. With this assumption is wouldn't be safe to allow general usage of this function. Moreover, some architectures that implement __kernel_map_pages() have this function guarded by #ifdef

[PATCH v2 0/4] arch, mm: improve robustness of direct map manipulation

2020-10-29 Thread Mike Rapoport
From: Mike Rapoport Hi, During recent discussion about KVM protected memory, David raised a concern about usage of __kernel_map_pages() outside of DEBUG_PAGEALLOC scope [1]. Indeed, for architectures that define CONFIG_ARCH_HAS_SET_DIRECT_MAP it is possible that __kernel_map_pages() would fail

[PATCH v2 1/4] mm: introduce debug_pagealloc_map_pages() helper

2020-10-29 Thread Mike Rapoport
From: Mike Rapoport When CONFIG_DEBUG_PAGEALLOC is enabled, it unmaps pages from the kernel direct mapping after free_pages(). The pages than need to be mapped back before they could be used. Theese mapping operations use __kernel_map_pages() guarded with with debug_pagealloc_enabled

Re: [PATCH 0/4] arch, mm: improve robustness of direct map manipulation

2020-10-29 Thread Mike Rapoport
On Wed, Oct 28, 2020 at 09:03:31PM +, Edgecombe, Rick P wrote: > > On Wed, Oct 28, 2020 at 11:20:12AM +, Will Deacon wrote: > > > On Tue, Oct 27, 2020 at 10:38:16AM +0200, Mike Rapoport wrote: > > > > > &

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

2020-10-29 Thread Mike Rapoport
On Wed, Oct 28, 2020 at 09:15:38PM +, Edgecombe, Rick P wrote: > On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote: > > + if (IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) { > > + unsigned long addr = (unsigned > > long)page_address(page); > &

Re: [PATCH 1/3] mm, page_alloc: do not rely on the order of page_poison and init_on_alloc/free parameters

2020-10-28 Thread Mike Rapoport
on_alloc() > and want_init_on_free(). We don't need to check page_poisoning_enabled() > there, > we can instead not enable the init_on_* tracepoint at all, if page poisoning > is > enabled. This results in a simpler and more effective code. > > Signed-off-by: Vlas

Re: [PATCH 11/13] m68k/mm: make node data and node setup depend on CONFIG_DISCONTIGMEM

2020-10-28 Thread Mike Rapoport
Hi Geert, On Wed, Oct 28, 2020 at 10:25:49AM +0100, Geert Uytterhoeven wrote: > Hi Mike, > > On Tue, Oct 27, 2020 at 12:31 PM Mike Rapoport wrote: > > From: Mike Rapoport > > > > The pg_data_t node structures and their initialization currently depends on > > !

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

2020-10-28 Thread Mike Rapoport
On Tue, Oct 27, 2020 at 10:44:21PM +, Edgecombe, Rick P wrote: > On Tue, 2020-10-27 at 10:49 +0200, Mike Rapoport wrote: > > On Mon, Oct 26, 2020 at 06:57:32PM +, Edgecombe, Rick P wrote: > > > On Mon, 2020-10-26 at 11:15 +0200, Mike Rapoport wrote: > > > >

Re: [PATCH 0/4] arch, mm: improve robustness of direct map manipulation

2020-10-28 Thread Mike Rapoport
On Wed, Oct 28, 2020 at 12:17:35PM +0100, David Hildenbrand wrote: > On 28.10.20 12:09, Mike Rapoport wrote: > > On Tue, Oct 27, 2020 at 09:46:35AM +0100, David Hildenbrand wrote: > > > On 27.10.20 09:38, Mike Rapoport wrote: > > > > On Mon, Oct 26, 2020 at 06:05

Re: [PATCH v3 01/12] mm: Make pagecache tagged lookups return only head pages

2020-10-28 Thread Mike Rapoport
On Mon, Oct 26, 2020 at 04:13:57AM +, Matthew Wilcox (Oracle) wrote: > Pagecache tags are used for dirty page writeback. Since dirtiness is > tracked on a per-THP basis, we only want to return the head page rather > than each subpage of a tagged page. All the filesystems which use huge >

Re: [PATCH 0/4] arch, mm: improve robustness of direct map manipulation

2020-10-28 Thread Mike Rapoport
On Wed, Oct 28, 2020 at 11:20:12AM +, Will Deacon wrote: > On Tue, Oct 27, 2020 at 10:38:16AM +0200, Mike Rapoport wrote: > > On Mon, Oct 26, 2020 at 06:05:30PM +, Edgecombe, Rick P wrote: > > > On Mon, 2020-10-26 at 11:05 +0200, Mike Rapoport wrote: > > > >

Re: [PATCH 11/13] m68k/mm: make node data and node setup depend on CONFIG_DISCONTIGMEM

2020-10-28 Thread Mike Rapoport
On Thu, Oct 29, 2020 at 07:14:38AM +1300, Michael Schmitz wrote: > Hi Mike, > > On 29/10/20 12:16 AM, Mike Rapoport wrote: > > Hi Geert, > > > > On Wed, Oct 28, 2020 at 10:25:49AM +0100, Geert Uytterhoeven wrote: > > > Hi Mike, > > > > > >

Re: [PATCH 1/8] mm: slab: provide krealloc_array()

2020-10-28 Thread Mike Rapoport
On Tue, Oct 27, 2020 at 01:17:18PM +0100, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > When allocating an array of elements, users should check for > multiplication overflow or preferably use one of the provided helpers > like: kmalloc_array(). > > There's no krealloc_array()

Re: [PATCH 0/4] arch, mm: improve robustness of direct map manipulation

2020-10-28 Thread Mike Rapoport
On Tue, Oct 27, 2020 at 09:46:35AM +0100, David Hildenbrand wrote: > On 27.10.20 09:38, Mike Rapoport wrote: > > On Mon, Oct 26, 2020 at 06:05:30PM +, Edgecombe, Rick P wrote: > > > > > Beyond whatever you are seeing, for the latter case of new things > > > g

[PATCH 02/13] ia64: remove custom __early_pfn_to_nid()

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport The ia64 implementation of __early_pfn_to_nid() essentially relies on the same data as the generic implementation. The correspondence between memory ranges and nodes is set in memblock during early memory initialization in register_active_ranges() function

[PATCH 03/13] ia64: remove 'ifdef CONFIG_ZONE_DMA32' statements

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport After the removal of SN2 platform (commit cf07cb1ff4ea ("ia64: remove support for the SGI SN2 platform") IA-64 always has ZONE_DMA32 and there is no point to guard code with this configuration option. Remove ifdefery associated with CONFIG_ZONE_DMA32 Signed-of

[PATCH 12/13] m68k/mm: enable use of generic memory_model.h for !DISCONTIGMEM

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport The pg_data_map and pg_data_table arrays as well as page_to_pfn() and pfn_to_page() are required only for DISCONTIGMEM. Other memory models can use the generic definitions in asm-generic/memory_model.h. Signed-off-by: Mike Rapoport --- arch/m68k/include/asm/page.h

[PATCH 04/13] ia64: discontig: paging_init(): remove local max_pfn calculation

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport The maximal PFN in the system is calculated during find_memory() time and it is stored at max_low_pfn then. Use this value in paging_init() and remove the redundant detection of max_pfn in that function. Signed-off-by: Mike Rapoport --- arch/ia64/mm/discontig.c | 5

[PATCH 11/13] m68k/mm: make node data and node setup depend on CONFIG_DISCONTIGMEM

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport The pg_data_t node structures and their initialization currently depends on !CONFIG_SINGLE_MEMORY_CHUNK. Since they are required only for DISCONTIGMEM make this dependency explicit and replace usage of CONFIG_SINGLE_MEMORY_CHUNK with CONFIG_DISCONTIGMEM where appropriate

[PATCH 01/13] alpha: switch from DISCONTIGMEM to SPARSEMEM

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport Enable SPARSEMEM support on alpha and deprecate DISCONTIGMEM. The required changes are mostly around moving duplicated definitions of page access and address conversion macros to a common place and making sure they are available for all memory models. The DISCONTINGMEM

[PATCH 06/13] ia64: forbid using VIRTUAL_MEM_MAP with FLATMEM

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport Virtual memory map was intended to avoid wasting memory on the memory map on systems with large holes in the physical memory layout. Long ago it been superseded first by DISCONTIGMEM and then by SPARSEMEM. Moreover, SPARSEMEM_VMEMMAP provide the same functionality in much

[PATCH 08/13] arm: remove CONFIG_ARCH_HAS_HOLES_MEMORYMODEL

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport ARM is the only architecture that defines CONFIG_ARCH_HAS_HOLES_MEMORYMODEL which in turn enables memmap_valid_within() function that is intended to verify existence of struct page associated with a pfn when there are holes in the memory map. However

[PATCH 13/13] m68k: deprecate DISCONTIGMEM

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport DISCONTIGMEM was intended to provide more efficient support for systems with holes in their physical address space that FLATMEM did. Yet, it's overhead in terms of the memory consumption seems to overweight the savings on the unused memory map. For a ARAnyM system with 16

[PATCH 05/13] ia64: split virtual map initialization out of paging_init()

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport For both FLATMEM and DISCONTIGMEM/SPARSEMEM the virtual map initialization is spread over paging_init() for no good reason. Split out the bits related to virtual map initialization to a helper functions, one for FLATMEM and another for !FLATMEM configurations. Signed-off

[PATCH 09/13] arm, arm64: move free_unused_memmap() to generic mm

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport ARM and ARM64 free unused parts of the memory map just before the initialization of the page allocator. To allow holes in the memory map both architectures overload pfn_valid() and define HAVE_ARCH_PFN_VALID. Allowing holes in the memory map for FLATMEM may be useful

[PATCH 00/13] arch, mm: deprecate DISCONTIGMEM

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport Hi, It's been a while since DISCONTIGMEM is generally considered deprecated, but it is still used by four architectures. This set replaces DISCONTIGMEM with a different way to handle holes in the memory map and marks DISCONTIGMEM configuration as BROKEN in Kconfigs

[PATCH 10/13] arc: use FLATMEM with freeing of unused memory map instead of DISCONTIGMEM

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport Currently ARC uses DISCONTIGMEM to cope with sparse physical memory address space on systems with 2 memory banks. While DISCONTIGMEM avoids wasting memory on unpopulated memory map, it adds both memory and CPU overhead relatively to FLATMEM. Moreover, DISCONTINGMEM

[PATCH 07/13] ia64: make SPARSEMEM default and disable DISCONTIGMEM

2020-10-27 Thread Mike Rapoport
From: Mike Rapoport SPARSEMEM memory model suitable for systems with large holes in their phyiscal memory layout. With SPARSEMEM_VMEMMAP enabled it provides pfn_to_page() and page_to_pfn() as fast as FLATMEM. Make it the default memory model for IA-64 and disable DISCONTIGMEM which

Re: [PATCH v2 5/6] RISC-V: Protect .init.text & .init.data

2020-10-27 Thread Mike Rapoport
On Mon, Oct 26, 2020 at 04:02:53PM -0700, Atish Patra wrote: > Currently, .init.text & .init.data are intermixed which makes it impossible > apply different permissions to them. .init.data shouldn't need exec > permissions while .init.text shouldn't have write permission. > > Keep them in

Re: [PATCH v2 2/6] RISC-V: Initialize SBI early

2020-10-27 Thread Mike Rapoport
On Mon, Oct 26, 2020 at 04:02:50PM -0700, Atish Patra wrote: > Currently, SBI is initialized towards the end of arch setup. This prevents > the set memory operations to be invoked earlier as it requires a full tlb > flush. > > Initialize SBI as early as possible. > > Signed-off-by: Atish Patra

Re: [PATCH v2 3/6] RISC-V: Enforce protections for kernel sections early

2020-10-27 Thread Mike Rapoport
On Mon, Oct 26, 2020 at 04:02:51PM -0700, Atish Patra wrote: > Currently, all memblocks are mapped with PAGE_KERNEL_EXEC and the strict > permissions are only enforced after /init starts. This leaves the kernel > vulnerable from possible buggy built-in modules. > > Apply permissions to individual

Re: [PATCH v7 3/7] set_memory: allow set_direct_map_*_noflush() for multiple pages

2020-10-27 Thread Mike Rapoport
On Tue, Oct 27, 2020 at 09:12:23AM +0100, David Hildenbrand wrote: > On 26.10.20 20:01, Edgecombe, Rick P wrote: > > On Mon, 2020-10-26 at 10:37 +0200, Mike Rapoport wrote: > >> +++ b/arch/x86/mm/pat/set_memory.c > >> @@ -2184,14 +2184,14 @@ static int __set_pages_np(

Re: [PATCH 0/4] arch, mm: improve robustness of direct map manipulation

2020-10-27 Thread Mike Rapoport
On Tue, Oct 27, 2020 at 09:46:35AM +0100, David Hildenbrand wrote: > On 27.10.20 09:38, Mike Rapoport wrote: > > On Mon, Oct 26, 2020 at 06:05:30PM +, Edgecombe, Rick P wrote: > > > On Mon, 2020-10-26 at 11:05 +0200, Mike Rapoport wrote: > > > > On Mon, Oc

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

2020-10-27 Thread Mike Rapoport
On Mon, Oct 26, 2020 at 06:57:32PM +, Edgecombe, Rick P wrote: > On Mon, 2020-10-26 at 11:15 +0200, Mike Rapoport wrote: > > On Mon, Oct 26, 2020 at 12:38:32AM +, Edgecombe, Rick P wrote: > > > On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote: > >

Re: [PATCH 0/4] arch, mm: improve robustness of direct map manipulation

2020-10-27 Thread Mike Rapoport
On Mon, Oct 26, 2020 at 06:05:30PM +, Edgecombe, Rick P wrote: > On Mon, 2020-10-26 at 11:05 +0200, Mike Rapoport wrote: > > On Mon, Oct 26, 2020 at 01:13:52AM +, Edgecombe, Rick P wrote: > > > On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote: > > >

Re: [PATCH 1/4] mm: introduce debug_pagealloc_map_pages() helper

2020-10-26 Thread Mike Rapoport
On Mon, Oct 26, 2020 at 12:05:13PM +0100, David Hildenbrand wrote: > On 25.10.20 11:15, Mike Rapoport wrote: > > From: Mike Rapoport > > > > When CONFIG_DEBUG_PAGEALLOC is enabled, it unmaps pages from the > > kernel direct mapping after free_pages(). The pages than

Re: [PATCH] mm: cleanup: remove unused tsk arg from __access_remote_vm

2020-10-26 Thread Mike Rapoport
ment. I'd also mention that making page fault accounting actually use this task struct is quite a project, so there is no point to keep tsk argument. > Signed-off-by: John Hubbard > Cc: Oleg Nesterov FWIW: Reviewed-by: Mike Rapoport > --- > > Hi, > > Just something tha

Re: [PATCH] mm: fix page_owner initializing issue for arm32

2020-10-26 Thread Mike Rapoport
On Mon, Oct 26, 2020 at 03:12:55PM +0800, Zhenhua Huang wrote: > Hi Mike, > > On Sun, Oct 25, 2020 at 11:42:53PM +0800, Mike Rapoport wrote: > > On Fri, Oct 16, 2020 at 05:14:00PM +0800, Zhenhua Huang wrote: > > > Page owner of pages used by page owner itself used is miss

Re: [PATCH 4/4] arch, mm: make kernel_page_present() always available

2020-10-26 Thread Mike Rapoport
On Mon, Oct 26, 2020 at 12:54:01AM +, Edgecombe, Rick P wrote: > On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote: > > index 7f248fc45317..16f878c26667 100644 > > --- a/arch/x86/mm/pat/set_memory.c > > +++ b/arch/x86/mm/pat/set_memory.c > > @@ -2228,7 +2228,6

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

2020-10-26 Thread Mike Rapoport
On Mon, Oct 26, 2020 at 12:38:32AM +, Edgecombe, Rick P wrote: > On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote: > > From: Mike Rapoport > > > > When DEBUG_PAGEALLOC or ARCH_HAS_SET_DIRECT_MAP is enabled a page may > > be > > not present in the di

Re: [PATCH 0/4] arch, mm: improve robustness of direct map manipulation

2020-10-26 Thread Mike Rapoport
On Mon, Oct 26, 2020 at 01:13:52AM +, Edgecombe, Rick P wrote: > On Sun, 2020-10-25 at 12:15 +0200, Mike Rapoport wrote: > > Indeed, for architectures that define CONFIG_ARCH_HAS_SET_DIRECT_MAP > > it is > > possible that __kernel_map_pages() would fail, but since this >

[PATCH v7 4/7] mm: introduce memfd_secret system call to create "secret" memory areas

2020-10-26 Thread Mike Rapoport
From: Mike Rapoport Introduce "memfd_secret" system call with the ability to create memory areas visible only in the context of the owning process and not mapped not only to other processes but in the kernel page tables as well. The user will create a file descriptor using the me

[PATCH v7 7/7] secretmem: test: add basic selftest for memfd_secret(2)

2020-10-26 Thread Mike Rapoport
From: Mike Rapoport The test verifies that file descriptor created with memfd_secret does not allow read/write operations, that secret memory mappings respect RLIMIT_MEMLOCK and that remote accesses with process_vm_read() and ptrace() to the secret memory fail. Signed-off-by: Mike Rapoport

[PATCH v7 6/7] mm: secretmem: use PMD-size pages to amortize direct map fragmentation

2020-10-26 Thread Mike Rapoport
From: Mike Rapoport Removing a PAGE_SIZE page from the direct map every time such page is allocated for a secret memory mapping will cause severe fragmentation of the direct map. This fragmentation can be reduced by using PMD-size pages as a pool for small pages for secret memory mappings. Add

[PATCH v7 5/7] arch, mm: wire up memfd_secret system call were relevant

2020-10-26 Thread Mike Rapoport
From: Mike Rapoport Wire up memfd_secret system call on architectures that define ARCH_HAS_SET_DIRECT_MAP, namely arm64, risc-v and x86. Signed-off-by: Mike Rapoport Acked-by: Palmer Dabbelt Acked-by: Arnd Bergmann --- arch/arm64/include/asm/unistd.h| 2 +- arch/arm64/include/asm

[PATCH v7 1/7] mm: add definition of PMD_PAGE_ORDER

2020-10-26 Thread Mike Rapoport
From: Mike Rapoport The definition of PMD_PAGE_ORDER denoting the number of base pages in the second-level leaf page is already used by DAX and maybe handy in other cases as well. Several architectures already have definition of PMD_ORDER as the size of second level page table, so to avoid

[PATCH v7 2/7] mmap: make mlock_future_check() global

2020-10-26 Thread Mike Rapoport
From: Mike Rapoport It will be used by the upcoming secret memory implementation. Signed-off-by: Mike Rapoport --- mm/internal.h | 3 +++ mm/mmap.c | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index c43ccdddb0f6..ae146a260b14

[PATCH v7 0/7] mm: introduce memfd_secret system call to create "secret" memory areas

2020-10-26 Thread Mike Rapoport
From: Mike Rapoport Hi, This is an implementation of "secret" mappings backed by a file descriptor. The file descriptor backing secret memory mappings is created using a dedicated memfd_secret system call The desired protection mode for the memory is configured using flags

[PATCH v7 3/7] set_memory: allow set_direct_map_*_noflush() for multiple pages

2020-10-26 Thread Mike Rapoport
From: Mike Rapoport The underlying implementations of set_direct_map_invalid_noflush() and set_direct_map_default_noflush() allow updating multiple contiguous pages at once. Add numpages parameter to set_direct_map_*_noflush() to expose this ability with these APIs. Signed-off-by: Mike

Re: [PATCH] mm: fix page_owner initializing issue for arm32

2020-10-25 Thread Mike Rapoport
On Fri, Oct 16, 2020 at 05:14:00PM +0800, Zhenhua Huang wrote: > Page owner of pages used by page owner itself used is missing on arm32 > targets. > The reason is dummy_handle and failure_handle is not initialized correctly. > Buddy allocator is used to initialize these two handles. However,

Re: [PATCH v2 1/7] mm, page_alloc: clean up pageset high and batch update

2020-10-25 Thread Mike Rapoport
On Thu, Oct 08, 2020 at 01:41:55PM +0200, Vlastimil Babka wrote: > The updates to pcplists' high and batch valued are handled by multiple Nit: ^ values > functions that make the calculations hard to follow. Consolidate everything > to

Re: [PATCH v2] mm: Optional full ASLR for mmap() and mremap()

2020-10-25 Thread Mike Rapoport
On Fri, Oct 02, 2020 at 02:09:17PM +0300, Topi Miettinen wrote: > Writing a new value of 3 to /proc/sys/kernel/randomize_va_space > enables full randomization of memory mappings created with mmap(NULL, > ...). With 2, the base of the VMA used for such mappings is random, > but the mappings are

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

2020-10-25 Thread Mike Rapoport
From: Mike Rapoport When DEBUG_PAGEALLOC or ARCH_HAS_SET_DIRECT_MAP is enabled a page may be not present in the direct map and has to be explicitly mapped before it could be copied. On arm64 it is possible that a page would be removed from the direct map using set_direct_map_invalid_noflush

[PATCH 4/4] arch, mm: make kernel_page_present() always available

2020-10-25 Thread Mike Rapoport
From: Mike Rapoport For architectures that enable ARCH_HAS_SET_MEMORY having the ability to verify that a page is mapped in the kernel direct map can be useful regardless of hibernation. Add RISC-V implementation of kernel_page_present() and update its forward declarations and stubs

[PATCH 3/4] arch, mm: restore dependency of __kernel_map_pages() of DEBUG_PAGEALLOC

2020-10-25 Thread Mike Rapoport
From: Mike Rapoport The design of DEBUG_PAGEALLOC presumes that __kernel_map_pages() must never fail. With this assumption is wouldn't be safe to allow general usage of this function. Moreover, some architectures that implement __kernel_map_pages() have this function guarded by #ifdef

[PATCH 1/4] mm: introduce debug_pagealloc_map_pages() helper

2020-10-25 Thread Mike Rapoport
From: Mike Rapoport When CONFIG_DEBUG_PAGEALLOC is enabled, it unmaps pages from the kernel direct mapping after free_pages(). The pages than need to be mapped back before they could be used. Theese mapping operations use __kernel_map_pages() guarded with with debug_pagealloc_enabled

[PATCH 0/4] arch, mm: improve robustness of direct map manipulation

2020-10-25 Thread Mike Rapoport
From: Mike Rapoport Hi, During recent discussion about KVM protected memory, David raised a concern about usage of __kernel_map_pages() outside of DEBUG_PAGEALLOC scope [1]. Indeed, for architectures that define CONFIG_ARCH_HAS_SET_DIRECT_MAP it is possible that __kernel_map_pages() would fail

Re: [PATCH v3 47/56] memblock: fix kernel-doc markups

2020-10-25 Thread Mike Rapoport
On Fri, Oct 23, 2020 at 06:33:34PM +0200, Mauro Carvalho Chehab wrote: > Some identifiers have different names between their prototypes > and the kernel-doc markup. > > Signed-off-by: Mauro Carvalho Chehab Acked-by: Mike Rapoport > --- > include/linux/memblock.h | 4 ++-- &g

Re: [RFCv2 15/16] KVM: Unmap protected pages from direct mapping

2020-10-23 Thread Mike Rapoport
On Tue, Oct 20, 2020 at 09:18:58AM +0300, Kirill A. Shutemov wrote: > If the protected memory feature enabled, unmap guest memory from > kernel's direct mappings. > > Migration and KSM is disabled for protected memory as it would require a > special treatment. > > Signed-off-by: Kirill A.

Re: [PATCH 1/2] mm/memory_hotplug: allow marking of memory sections as hotpluggable

2020-10-21 Thread Mike Rapoport
On Sat, Oct 17, 2020 at 11:36:39AM +0200, David Hildenbrand wrote: > On 17.10.20 10:26, Mike Rapoport wrote: > > On Fri, Oct 16, 2020 at 07:02:23PM -0700, Sudarshan Rajagopalan wrote: > >> Certain architectures such as arm64 doesn't allow boot memory to be > >> offlin

Re: [PATCH] lib/test_free_pages: Add basic progress indicators

2020-10-18 Thread Mike Rapoport
On Sun, Oct 18, 2020 at 04:01:46PM +0100, Matthew Wilcox wrote: > On Sun, Oct 18, 2020 at 04:39:27PM +0200, Geert Uytterhoeven wrote: > > Hi Matthew, > > > > On Sun, Oct 18, 2020 at 4:25 PM Matthew Wilcox wrote: > > > On Sun, Oct 18, 2020 at 04:04:45PM +0200, Geert Uytterhoeven wrote: > > > >

Re: [PATCH 1/2] mm/memory_hotplug: allow marking of memory sections as hotpluggable

2020-10-17 Thread Mike Rapoport
be set with this new bit. > > Signed-off-by: Sudarshan Rajagopalan > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Mike Rapoport > Cc: Anshuman Khandual > Cc: David Hildenbrand > Cc: Mark Rutland > Cc: Steven Price > Cc: Logan Gunthorpe > Cc: Suren Baghdas

Re: [External] Re: [PATCH] mm: proc: add Sock to /proc/meminfo

2020-10-13 Thread Mike Rapoport
On Tue, Oct 13, 2020 at 08:21:13AM -0700, Randy Dunlap wrote: > On 10/13/20 8:12 AM, Mike Rapoport wrote: > > On Tue, Oct 13, 2020 at 07:43:59AM -0700, Randy Dunlap wrote: > >> On 10/13/20 1:09 AM, Mike Rapoport wrote: > >>> On Mon, Oct 12, 2020 at 05:53

Re: [External] Re: [PATCH] mm: proc: add Sock to /proc/meminfo

2020-10-13 Thread Mike Rapoport
On Tue, Oct 13, 2020 at 07:43:59AM -0700, Randy Dunlap wrote: > On 10/13/20 1:09 AM, Mike Rapoport wrote: > > On Mon, Oct 12, 2020 at 05:53:01PM +0800, Muchun Song wrote: > >> On Mon, Oct 12, 2020 at 5:24 PM Eric Dumazet > >> wrote: > >>> > &

Re: [PATCH v6 55/80] memblock: get rid of a :c:type leftover

2020-10-13 Thread Mike Rapoport
--^ > > As, on Sphinx 3.x, the right markup is c:struct:`foo`. > > So, let's remove it, relying on automarkup.py to convert it. > > Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Mike Rapoport > --- > mm/memblock.c | 4 ++-- > 1 file changed, 2 insertion

Re: [External] Re: [PATCH] mm: proc: add Sock to /proc/meminfo

2020-10-13 Thread Mike Rapoport
> > greater. > > > > > > > This is great, but you have not addressed my feedback. > > > > TCP memory allocations are bounded by /proc/sys/net/ipv4/tcp_mem > > > > Fact that the memory is forward allocated or not is a detail. > > > >

Re: [PATCH] mm: proc: add Sock to /proc/meminfo

2020-10-11 Thread Mike Rapoport
On Sat, Oct 10, 2020 at 06:38:54PM +0800, Muchun Song wrote: > The amount of memory allocated to sockets buffer can become significant. > However, we do not display the amount of memory consumed by sockets > buffer. In this case, knowing where the memory is consumed by the kernel > is very

Re: [PATCH v6 3/6] mm: introduce memfd_secret system call to create "secret" memory areas

2020-10-11 Thread Mike Rapoport
On Wed, Sep 30, 2020 at 08:11:28PM +, Edgecombe, Rick P wrote: > On Wed, 2020-09-30 at 13:35 +0300, Mike Rapoport wrote: > > > > Our thinking was that copy_*user() would work in the context of the > > process that "owns" the secretmem and gup() would not allo

[PATCH] ARC: SMP: fix typo and use "come up" instead of "comeup"

2020-10-05 Thread Mike Rapoport
From: Mike Rapoport When a secondary CPU fails to come up, there is a missing space in the log: Timeout: CPU1 FAILED to comeup !!! Fix it. Signed-off-by: Mike Rapoport --- arch/arc/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arc/kernel/smp.c

Re: [PATCH] man2: new page describing memfd_secret() system call

2020-10-05 Thread Mike Rapoport
Hi Alex, On Sat, Oct 03, 2020 at 11:32:43AM +0200, Alejandro Colomar wrote: > Hi Mike and Michael, I'll add the note to the man page, thanks! > Ping. :) > > Thanks, > > Alex > > On 2020-09-24 16:55, Alejandro Colomar wrote: > > * Mike Rapoport

Re: [PATCH v6 5/6] mm: secretmem: use PMD-size pages to amortize direct map fragmentation

2020-10-01 Thread Mike Rapoport
On Wed, Sep 30, 2020 at 04:09:28PM +0100, Matthew Wilcox wrote: > On Wed, Sep 30, 2020 at 01:27:45PM +0300, Mike Rapoport wrote: > > On Tue, Sep 29, 2020 at 05:15:52PM +0200, Peter Zijlstra wrote: > > > On Tue, Sep 29, 2020 at 05:58:13PM +0300, Mike Rapoport wrote: > >

Re: [PATCH v4 22/52] docs: get rid of :c:type explicit declarations for structs

2020-09-30 Thread Mike Rapoport
| 2 +- > Documentation/vm/memory-model.rst | 6 ++--- > mm/ksm.c | 2 +- > mm/memblock.c | 4 ++-- Reviewed-by: Mike Rapoport > 30 files changed, 93 insertions(+), 93 deletions(-) >

Re: [PATCH v4 19/52] memblock: get rid of a :c:type leftover

2020-09-30 Thread Mike Rapoport
Hello Mauro, On Wed, Sep 30, 2020 at 03:24:42PM +0200, Mauro Carvalho Chehab wrote: > chanseset b3a7bb1851c8 ("docs: get rid of :c:type explicit declarations for > structs") > removed several :c:type: markups, except by one. > > Now, Sphinx 3.x complains about it: > >

Re: [PATCH v6 3/6] mm: introduce memfd_secret system call to create "secret" memory areas

2020-09-30 Thread Mike Rapoport
On Tue, Sep 29, 2020 at 08:06:03PM +, Edgecombe, Rick P wrote: > On Tue, 2020-09-29 at 16:06 +0300, Mike Rapoport wrote: > > On Tue, Sep 29, 2020 at 04:58:44AM +, Edgecombe, Rick P wrote: > > > On Thu, 2020-09-24 at 16:29 +0300, Mike Rapoport wrote: > > > > I

Re: [PATCH v6 5/6] mm: secretmem: use PMD-size pages to amortize direct map fragmentation

2020-09-30 Thread Mike Rapoport
On Tue, Sep 29, 2020 at 05:15:52PM +0200, Peter Zijlstra wrote: > On Tue, Sep 29, 2020 at 05:58:13PM +0300, Mike Rapoport wrote: > > On Tue, Sep 29, 2020 at 04:12:16PM +0200, Peter Zijlstra wrote: > > > > It will drop them down to 4k pages. Given enough inodes, and allocatin

Re: [PATCH v6 5/6] mm: secretmem: use PMD-size pages to amortize direct map fragmentation

2020-09-30 Thread Mike Rapoport
On Tue, Sep 29, 2020 at 04:12:16PM +0200, Peter Zijlstra wrote: > On Tue, Sep 29, 2020 at 04:05:29PM +0300, Mike Rapoport wrote: > > On Fri, Sep 25, 2020 at 09:41:25AM +0200, Peter Zijlstra wrote: > > > On Thu, Sep 24, 2020 at 04:29:03PM +0300, Mike Rapoport wrote: > >

Re: [PATCH v2] page_alloc: Fix freeing non-compound pages

2020-09-30 Thread Mike Rapoport
On Tue, Sep 29, 2020 at 03:06:22PM +0100, Matthew Wilcox wrote: > On Tue, Sep 29, 2020 at 10:26:22AM +0300, Mike Rapoport wrote: > > This sentence presumes existing description/prior knowledge about > > put_page(). > > > > Maybe > > > > This function ca

<    3   4   5   6   7   8   9   10   11   12   >