Skip to content

Commit

Permalink
mm/mm_init.c: remove reset_node_present_pages()
Browse files Browse the repository at this point in the history
reset_node_present_pages() only get called in hotadd_init_pgdat(), move
the action that clear present pages to free_area_init_core_hotplug(), so
the helper can be removed.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Haifeng Xu <[email protected]>
Suggested-by: David Hildenbrand <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Mike Rapoport (IBM) <[email protected]>
Cc: Oscar Salvador <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
hfxsp authored and akpm00 committed Jun 19, 2023
1 parent a668968 commit 32b6a4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
18 changes: 0 additions & 18 deletions mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,16 +1156,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,
return ret;
}

static void reset_node_present_pages(pg_data_t *pgdat)
{
struct zone *z;

for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
z->present_pages = 0;

pgdat->node_present_pages = 0;
}

/* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
static pg_data_t __ref *hotadd_init_pgdat(int nid)
{
Expand All @@ -1188,14 +1178,6 @@ static pg_data_t __ref *hotadd_init_pgdat(int nid)
*/
build_all_zonelists(pgdat);

/*
* When memory is hot-added, all the memory is in offline state. So
* clear all zones' present_pages because they will be updated in
* online_pages() and offline_pages().
* TODO: should be in free_area_init_core_hotplug?
*/
reset_node_present_pages(pgdat);

return pgdat;
}

Expand Down
15 changes: 13 additions & 2 deletions mm/mm_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1509,15 +1509,26 @@ void __ref free_area_init_core_hotplug(struct pglist_data *pgdat)
pgdat->kswapd_order = 0;
pgdat->kswapd_highest_zoneidx = 0;
pgdat->node_start_pfn = 0;
pgdat->node_present_pages = 0;

for_each_online_cpu(cpu) {
struct per_cpu_nodestat *p;

p = per_cpu_ptr(pgdat->per_cpu_nodestats, cpu);
memset(p, 0, sizeof(*p));
}

for (z = 0; z < MAX_NR_ZONES; z++)
zone_init_internals(&pgdat->node_zones[z], z, nid, 0);
/*
* When memory is hot-added, all the memory is in offline state. So
* clear all zones' present_pages and managed_pages because they will
* be updated in online_pages() and offline_pages().
*/
for (z = 0; z < MAX_NR_ZONES; z++) {
struct zone *zone = pgdat->node_zones + z;

zone->present_pages = 0;
zone_init_internals(zone, z, nid, 0);
}
}
#endif

Expand Down

0 comments on commit 32b6a4a

Please sign in to comment.