diff options
author | Vlastimil Babka <vbabka@suse.cz> | 2017-02-22 18:41:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-22 19:41:27 -0500 |
commit | 13ad59df67f19788f6c22985b1a33e466eceb643 (patch) | |
tree | 98644ed581610f3af1d52f01963627e94317f2cd /mm/page_alloc.c | |
parent | 76741e776a37973a3e398d504069b3e55c5cc866 (diff) |
mm, page_alloc: avoid page_to_pfn() when merging buddies
On architectures that allow memory holes, page_is_buddy() has to perform
page_to_pfn() to check for the memory hole. After the previous patch,
we have the pfn already available in __free_one_page(), which is the
only caller of page_is_buddy(), so move the check there and avoid
page_to_pfn().
Link: http://lkml.kernel.org/r/20161216120009.20064-2-vbabka@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Johannes Weiner <hannes@cmpxchg.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.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 49d40261f8c4..af65c4eedc79 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -714,7 +714,7 @@ static inline void rmv_page_order(struct page *page) | |||
714 | /* | 714 | /* |
715 | * This function checks whether a page is free && is the buddy | 715 | * This function checks whether a page is free && is the buddy |
716 | * we can do coalesce a page and its buddy if | 716 | * we can do coalesce a page and its buddy if |
717 | * (a) the buddy is not in a hole && | 717 | * (a) the buddy is not in a hole (check before calling!) && |
718 | * (b) the buddy is in the buddy system && | 718 | * (b) the buddy is in the buddy system && |
719 | * (c) a page and its buddy have the same order && | 719 | * (c) a page and its buddy have the same order && |
720 | * (d) a page and its buddy are in the same zone. | 720 | * (d) a page and its buddy are in the same zone. |
@@ -729,9 +729,6 @@ static inline void rmv_page_order(struct page *page) | |||
729 | static inline int page_is_buddy(struct page *page, struct page *buddy, | 729 | static inline int page_is_buddy(struct page *page, struct page *buddy, |
730 | unsigned int order) | 730 | unsigned int order) |
731 | { | 731 | { |
732 | if (!pfn_valid_within(page_to_pfn(buddy))) | ||
733 | return 0; | ||
734 | |||
735 | if (page_is_guard(buddy) && page_order(buddy) == order) { | 732 | if (page_is_guard(buddy) && page_order(buddy) == order) { |
736 | if (page_zone_id(page) != page_zone_id(buddy)) | 733 | if (page_zone_id(page) != page_zone_id(buddy)) |
737 | return 0; | 734 | return 0; |
@@ -808,6 +805,9 @@ continue_merging: | |||
808 | while (order < max_order - 1) { | 805 | while (order < max_order - 1) { |
809 | buddy_pfn = __find_buddy_pfn(pfn, order); | 806 | buddy_pfn = __find_buddy_pfn(pfn, order); |
810 | buddy = page + (buddy_pfn - pfn); | 807 | buddy = page + (buddy_pfn - pfn); |
808 | |||
809 | if (!pfn_valid_within(buddy_pfn)) | ||
810 | goto done_merging; | ||
811 | if (!page_is_buddy(page, buddy, order)) | 811 | if (!page_is_buddy(page, buddy, order)) |
812 | goto done_merging; | 812 | goto done_merging; |
813 | /* | 813 | /* |
@@ -862,7 +862,7 @@ done_merging: | |||
862 | * so it's less likely to be used soon and more likely to be merged | 862 | * so it's less likely to be used soon and more likely to be merged |
863 | * as a higher order page | 863 | * as a higher order page |
864 | */ | 864 | */ |
865 | if ((order < MAX_ORDER-2) && pfn_valid_within(page_to_pfn(buddy))) { | 865 | if ((order < MAX_ORDER-2) && pfn_valid_within(buddy_pfn)) { |
866 | struct page *higher_page, *higher_buddy; | 866 | struct page *higher_page, *higher_buddy; |
867 | combined_pfn = buddy_pfn & pfn; | 867 | combined_pfn = buddy_pfn & pfn; |
868 | higher_page = page + (combined_pfn - pfn); | 868 | higher_page = page + (combined_pfn - pfn); |