From: Mel Gorman <mgor...@suse.de>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

commit d34c5fa06fade08a689fc171bf756fba2858ae73 upstream.

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 <mgor...@suse.de>
Acked-by: Johannes Weiner <han...@cmpxchg.org>
Acked-by: Rik van Riel <r...@redhat.com>
Cc: Vlastimil Babka <vba...@suse.cz>
Cc: Jan Kara <j...@suse.cz>
Cc: Michal Hocko <mho...@suse.cz>
Cc: Hugh Dickins <hu...@google.com>
Cc: Dave Hansen <dave.han...@intel.com>
Cc: Theodore Ts'o <ty...@mit.edu>
Cc: "Paul E. McKenney" <paul...@linux.vnet.ibm.com>
Cc: Oleg Nesterov <o...@redhat.com>
Cc: Peter Zijlstra <pet...@infradead.org>
Signed-off-by: Andrew Morton <a...@linux-foundation.org>
Signed-off-by: Linus Torvalds <torva...@linux-foundation.org>
Signed-off-by: Mel Gorman <mgor...@suse.de>
Signed-off-by: Jiri Slaby <jsl...@suse.cz>
---
 mm/page_alloc.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index fd2752aabc94..2e7ec3cd7008 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -505,16 +505,26 @@ static inline int page_is_buddy(struct page *page, struct 
page *buddy,
        if (!pfn_valid_within(page_to_pfn(buddy)))
                return 0;
 
-       if (page_zone_id(page) != page_zone_id(buddy))
-               return 0;
-
        if (page_is_guard(buddy) && page_order(buddy) == order) {
                VM_BUG_ON(page_count(buddy) != 0);
+
+               if (page_zone_id(page) != page_zone_id(buddy))
+                       return 0;
+
                return 1;
        }
 
        if (PageBuddy(buddy) && page_order(buddy) == order) {
                VM_BUG_ON(page_count(buddy) != 0);
+
+               /*
+                * zone check is done late to avoid uselessly
+                * calculating zone/node ids for pages that could
+                * never merge.
+                */
+               if (page_zone_id(page) != page_zone_id(buddy))
+                       return 0;
+
                return 1;
        }
        return 0;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to