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: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20200712083130.22919-1-rppt@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Mike Rapoport
2020-08-06 23:24:02 -07:00
committed by Linus Torvalds
parent 6cda72047e
commit c89ab04feb
23 changed files with 19 additions and 101 deletions
+12 -8
View File
@@ -249,7 +249,7 @@ void __init subsection_map_init(unsigned long pfn, unsigned long nr_pages)
#endif
/* Record a memory area against a node. */
void __init memory_present(int nid, unsigned long start, unsigned long end)
static void __init memory_present(int nid, unsigned long start, unsigned long end)
{
unsigned long pfn;
@@ -285,11 +285,11 @@ void __init memory_present(int nid, unsigned long start, unsigned long end)
}
/*
* Mark all memblocks as present using memory_present(). This is a
* convenience function that is useful for a number of arches
* to mark all of the systems memory as present during initialization.
* Mark all memblocks as present using memory_present().
* This is a convenience function that is useful to mark all of the systems
* memory as present during initialization.
*/
void __init memblocks_present(void)
static void __init memblocks_present(void)
{
struct memblock_region *reg;
@@ -574,9 +574,13 @@ failed:
*/
void __init sparse_init(void)
{
unsigned long pnum_begin = first_present_section_nr();
int nid_begin = sparse_early_nid(__nr_to_section(pnum_begin));
unsigned long pnum_end, map_count = 1;
unsigned long pnum_end, pnum_begin, map_count = 1;
int nid_begin;
memblocks_present();
pnum_begin = first_present_section_nr();
nid_begin = sparse_early_nid(__nr_to_section(pnum_begin));
/* Setup pageblock_order for HUGETLB_PAGE_SIZE_VARIABLE */
set_pageblock_order();