From: "Gregory Price (Meta)" N_MEMORY is set in free_area_init() and online_pages(), and cleared in offline_pages(). Centralize those updates in node_set/clear_memory_state(), so states that subdivide N_MEMORY can be published together with it. Behavior is unchanged. Signed-off-by: Gregory Price (Meta) --- mm/internal.h | 3 +++ mm/memory_hotplug.c | 4 ++-- mm/mm_init.c | 8 ++++---- mm/page_alloc.c | 10 ++++++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index de4593b3e3b6..c102e0f498bf 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -62,6 +62,9 @@ void lru_add_drain_cpu_zone(struct zone *zone); void folio_deactivate(struct folio *folio); void folio_mark_lazyfree(struct folio *folio); +void node_set_memory_state(int nid); +void node_clear_memory_state(int nid); + /* mm/vmscan.c */ unsigned long zone_reclaimable_pages(struct zone *zone); unsigned long try_to_free_pages(struct zonelist *zonelist, int order, diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index e5024f934932..e5cb770e4b09 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1197,7 +1197,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages, adjust_present_page_count(pfn_to_page(pfn), group, nr_pages); if (node_arg.nid >= 0) - node_set_state(nid, N_MEMORY); + node_set_memory_state(nid); /* * Check whether we are adding normal memory to the node for the first * time. @@ -2165,7 +2165,7 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages, * list. Otherwise this node would still appear in the fallback lists. */ if (node_arg.nid >= 0) - node_clear_state(node, N_MEMORY); + node_clear_memory_state(node); if (!populated_zone(zone)) { zone_pcp_reset(zone); build_all_zonelists(NULL); diff --git a/mm/mm_init.c b/mm/mm_init.c index a9d848c92678..46fe9a274a7a 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1763,11 +1763,13 @@ static void __init free_area_init_node(int nid) lru_gen_init_pgdat(pgdat); } -/* Any regular or high memory on that node? */ +/* Publish the memory states of a node that has present pages. */ static void __init check_for_memory(pg_data_t *pgdat) { enum zone_type zone_type; + node_set_memory_state(pgdat->node_id); + for (zone_type = 0; zone_type <= ZONE_MOVABLE - 1; zone_type++) { struct zone *zone = &pgdat->node_zones[zone_type]; if (populated_zone(zone)) { @@ -1924,10 +1926,8 @@ static void __init free_area_init(void) *memory-less node. The pgdat will get fully initialized by *hotadd_init_pgdat() when memory is hotplugged into this node. */ - if (pgdat->node_present_pages) { - node_set_state(nid, N_MEMORY); + if (pgdat->node_present_pages) check_for_memory(pgdat); - } } calc_nr_kernel_pages(); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index aa1ed599c7c6..88d507f93b1a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -208,6 +208,16 @@ nodemask_t node_states[NR_NODE_STATES] __read_mostly = { }; EXPORT_SYMBOL(node_states); +void __meminit node_set_memory_state(int nid) +{ + node_set_state(nid, N_MEMORY); +} + +void __meminit node_clear_memory_state(int nid) +{ + node_clear_state(nid, N_MEMORY); +} + gfp_t gfp_allowed_mask __read_mostly = GFP_BOOT_MASK; #ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE -- 2.56.1