Skip to content

Commit

Permalink
mm: handle hashdist initialization in mm/mm_init.c
Browse files Browse the repository at this point in the history
The hashdist variable must be initialized before the first call to
alloc_large_system_hash() and free_area_init() looks like a better place
for it than page_alloc_init().

Move hashdist handling to mm/mm_init.c

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Mike Rapoport (IBM) <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
Reviewed-by: Vlastimil Babka <[email protected]>
Cc: Doug Berger <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
rppt authored and akpm00 committed Apr 6, 2023
1 parent 9420f89 commit 534ef4e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
22 changes: 22 additions & 0 deletions mm/mm_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,25 @@ int __meminit early_pfn_to_nid(unsigned long pfn)

return nid;
}

int hashdist = HASHDIST_DEFAULT;

static int __init set_hashdist(char *str)
{
if (!str)
return 0;
hashdist = simple_strtoul(str, &str, 0);
return 1;
}
__setup("hashdist=", set_hashdist);

static inline void fixup_hashdist(void)
{
if (num_node_state(N_MEMORY) == 1)
hashdist = 0;
}
#else
static inline void fixup_hashdist(void) {}
#endif /* CONFIG_NUMA */

#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
Expand Down Expand Up @@ -1855,6 +1874,9 @@ void __init free_area_init(unsigned long *max_zone_pfn)
}

memmap_init();

/* disable hash distribution for systems with a single node */
fixup_hashdist();
}

/**
Expand Down
18 changes: 0 additions & 18 deletions mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6393,28 +6393,10 @@ static int page_alloc_cpu_online(unsigned int cpu)
return 0;
}

#ifdef CONFIG_NUMA
int hashdist = HASHDIST_DEFAULT;

static int __init set_hashdist(char *str)
{
if (!str)
return 0;
hashdist = simple_strtoul(str, &str, 0);
return 1;
}
__setup("hashdist=", set_hashdist);
#endif

void __init page_alloc_init(void)
{
int ret;

#ifdef CONFIG_NUMA
if (num_node_state(N_MEMORY) == 1)
hashdist = 0;
#endif

ret = cpuhp_setup_state_nocalls(CPUHP_PAGE_ALLOC,
"mm/page_alloc:pcp",
page_alloc_cpu_online,
Expand Down

0 comments on commit 534ef4e

Please sign in to comment.