aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2014-06-04 19:10:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 19:54:08 -0400
commitd34c5fa06fade08a689fc171bf756fba2858ae73 (patch)
tree68e67f14ce1a98d11bed2a105d6c7047aedfab71 /mm/page_alloc.c
parent664eeddeef6539247691197c1ac124d4aa872ab6 (diff)
mm: page_alloc: only check the zone id check if pages are buddies
A node/zone index is used to check if pages are compatible for merging but this happens unconditionally even if the buddy page is not free. Defer the calculation as long as possible. Ideally we would check the zone boundary but nodes can overlap. Signed-off-by: Mel Gorman <mgorman@suse.de> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Rik van Riel <riel@redhat.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Jan Kara <jack@suse.cz> Cc: Michal Hocko <mhocko@suse.cz> Cc: Hugh Dickins <hughd@google.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Theodore Ts'o <tytso@mit.edu> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a2955e101715..da526905b4a5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -509,16 +509,26 @@ static inline int page_is_buddy(struct page *page, struct page *buddy,
509 if (!pfn_valid_within(page_to_pfn(buddy))) 509 if (!pfn_valid_within(page_to_pfn(buddy)))
510 return 0; 510 return 0;
511 511
512 if (page_zone_id(page) != page_zone_id(buddy))
513 return 0;
514
515 if (page_is_guard(buddy) && page_order(buddy) == order) { 512 if (page_is_guard(buddy) && page_order(buddy) == order) {
516 VM_BUG_ON_PAGE(page_count(buddy) != 0, buddy); 513 VM_BUG_ON_PAGE(page_count(buddy) != 0, buddy);
514
515 if (page_zone_id(page) != page_zone_id(buddy))
516 return 0;
517
517 return 1; 518 return 1;
518 } 519 }
519 520
520 if (PageBuddy(buddy) && page_order(buddy) == order) { 521 if (PageBuddy(buddy) && page_order(buddy) == order) {
521 VM_BUG_ON_PAGE(page_count(buddy) != 0, buddy); 522 VM_BUG_ON_PAGE(page_count(buddy) != 0, buddy);
523
524 /*
525 * zone check is done late to avoid uselessly
526 * calculating zone/node ids for pages that could
527 * never merge.
528 */
529 if (page_zone_id(page) != page_zone_id(buddy))
530 return 0;
531
522 return 1; 532 return 1;
523 } 533 }
524 return 0; 534 return 0;