Skip to content

Commit

Permalink
mm/memory_hotplug: document why shuffle_zone() is relevant
Browse files Browse the repository at this point in the history
It's not completely obvious why we have to shuffle the complete zone -
introduced in commit e900a91 ("mm: shuffle initial free memory to
improve memory-side-cache utilization") - because some sort of shuffling
is already performed when onlining pages via __free_one_page(), placing
MAX_ORDER-1 pages either to the head or the tail of the freelist.  Let's
document why we have to shuffle the complete zone when exposing larger,
contiguous physical memory areas to the buddy.

Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Michal Hocko <mhocko@suse.com>
Link: http://lkml.kernel.org/r/20200624094741.9918-3-david@redhat.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
David Hildenbrand authored and Linus Torvalds committed Aug 7, 2020
1 parent 56b9413 commit 93146d9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,14 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,
zone->zone_pgdat->node_present_pages += onlined_pages;
pgdat_resize_unlock(zone->zone_pgdat, &flags);

/*
* When exposing larger, physically contiguous memory areas to the
* buddy, shuffling in the buddy (when freeing onlined pages, putting
* them either to the head or the tail of the freelist) is only helpful
* for maintaining the shuffle, but not for creating the initial
* shuffle. Shuffle the whole zone to make sure the just onlined pages
* are properly distributed across the whole freelist.
*/
shuffle_zone(zone);

node_states_set_node(nid, &arg);
Expand Down

0 comments on commit 93146d9

Please sign in to comment.