Commit c89ab04f authored by Mike Rapoport's avatar Mike Rapoport Committed by Linus Torvalds
Browse files

mm/sparse: cleanup the code surrounding memory_present()



After removal of CONFIG_HAVE_MEMBLOCK_NODE_MAP we have two equivalent
functions that call memory_present() for each region in memblock.memory:
sparse_memory_present_with_active_regions() and membocks_present().

Moreover, all architectures have a call to either of these functions
preceding the call to sparse_init() and in the most cases they are called
one after the other.

Mark the regions from memblock.memory as present during sparce_init() by
making sparse_init() call memblocks_present(), make memblocks_present()
and memory_present() functions static and remove redundant
sparse_memory_present_with_active_regions() function.

Also remove no longer required HAVE_MEMORY_PRESENT configuration option.

Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20200712083130.22919-1-rppt@kernel.org


Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6cda7204
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -141,11 +141,8 @@ sections:
  `mem_section` objects and the number of rows is calculated to fit
  all the memory sections.

The architecture setup code should call :c:func:`memory_present` for
each active memory range or use :c:func:`memblocks_present` or
:c:func:`sparse_memory_present_with_active_regions` wrappers to
initialize the memory sections. Next, the actual memory maps should be
set up using :c:func:`sparse_init`.
The architecture setup code should call sparse_init() to
initialize the memory sections and the memory maps.

With SPARSEMEM there are two possible ways to convert a PFN to the
corresponding `struct page` - a "classic sparse" and "sparse
+2 −7
Original line number Diff line number Diff line
@@ -243,13 +243,8 @@ void __init bootmem_init(void)
		      (phys_addr_t)max_low_pfn << PAGE_SHIFT);

	/*
	 * Sparsemem tries to allocate bootmem in memory_present(),
	 * so must be done after the fixed reservations
	 */
	memblocks_present();

	/*
	 * sparse_init() needs the bootmem allocator up and running.
	 * sparse_init() tries to allocate memory from memblock, so must be
	 * done after the fixed reservations
	 */
	sparse_init();

+2 −4
Original line number Diff line number Diff line
@@ -430,11 +430,9 @@ void __init bootmem_init(void)
#endif

	/*
	 * Sparsemem tries to allocate bootmem in memory_present(), so must be
	 * done after the fixed reservations.
	 * sparse_init() tries to allocate memory from memblock, so must be
	 * done after the fixed reservations
	 */
	memblocks_present();

	sparse_init();
	zone_sizes_init(min, max);

+0 −1
Original line number Diff line number Diff line
@@ -600,7 +600,6 @@ void __init paging_init(void)

	max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;

	sparse_memory_present_with_active_regions(MAX_NUMNODES);
	sparse_init();

#ifdef CONFIG_VIRTUAL_MEM_MAP
+0 −3
Original line number Diff line number Diff line
@@ -172,9 +172,6 @@ void __init setup_memory(void)
				  &memblock.memory, 0);
	}

	/* XXX need to clip this if using highmem? */
	sparse_memory_present_with_active_regions(0);

	paging_init();
}

Loading