Skip to content

Commit 93146d9

Browse files
davidhildenbrandtorvalds
authored andcommitted
mm/memory_hotplug: document why shuffle_zone() is relevant
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 <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Dan Williams <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Alexander Duyck <[email protected]> Cc: Dan Williams <[email protected]> Cc: Michal Hocko <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 56b9413 commit 93146d9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mm/memory_hotplug.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,14 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,
831831
zone->zone_pgdat->node_present_pages += onlined_pages;
832832
pgdat_resize_unlock(zone->zone_pgdat, &flags);
833833

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

836844
node_states_set_node(nid, &arg);

0 commit comments

Comments
 (0)