diff options
author | Joonsoo Kim <iamjoonsoo.kim@lge.com> | 2014-12-12 19:55:01 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-13 15:42:46 -0500 |
commit | 2847cf95c68fa5fa391c58a669e761c4b0c8fc57 (patch) | |
tree | b80abdf81c5e0a67e6a707cdddca18ed7829073a /mm | |
parent | 4308ce17f6e1c404276484f6e4e0bf496a95982f (diff) |
mm/debug-pagealloc: cleanup page guard code
Page guard is used by debug-pagealloc feature. Currently, it is
open-coded, but, I think that more abstraction of it makes core page
allocator code more readable.
There is no functional difference.
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Gioh Kim <gioh.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/page_alloc.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index df542feaac3b..2e8b7f39605a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -439,18 +439,29 @@ static int __init debug_guardpage_minorder_setup(char *buf) | |||
439 | } | 439 | } |
440 | __setup("debug_guardpage_minorder=", debug_guardpage_minorder_setup); | 440 | __setup("debug_guardpage_minorder=", debug_guardpage_minorder_setup); |
441 | 441 | ||
442 | static inline void set_page_guard_flag(struct page *page) | 442 | static inline void set_page_guard(struct zone *zone, struct page *page, |
443 | unsigned int order, int migratetype) | ||
443 | { | 444 | { |
444 | __set_bit(PAGE_DEBUG_FLAG_GUARD, &page->debug_flags); | 445 | __set_bit(PAGE_DEBUG_FLAG_GUARD, &page->debug_flags); |
446 | INIT_LIST_HEAD(&page->lru); | ||
447 | set_page_private(page, order); | ||
448 | /* Guard pages are not available for any usage */ | ||
449 | __mod_zone_freepage_state(zone, -(1 << order), migratetype); | ||
445 | } | 450 | } |
446 | 451 | ||
447 | static inline void clear_page_guard_flag(struct page *page) | 452 | static inline void clear_page_guard(struct zone *zone, struct page *page, |
453 | unsigned int order, int migratetype) | ||
448 | { | 454 | { |
449 | __clear_bit(PAGE_DEBUG_FLAG_GUARD, &page->debug_flags); | 455 | __clear_bit(PAGE_DEBUG_FLAG_GUARD, &page->debug_flags); |
456 | set_page_private(page, 0); | ||
457 | if (!is_migrate_isolate(migratetype)) | ||
458 | __mod_zone_freepage_state(zone, (1 << order), migratetype); | ||
450 | } | 459 | } |
451 | #else | 460 | #else |
452 | static inline void set_page_guard_flag(struct page *page) { } | 461 | static inline void set_page_guard(struct zone *zone, struct page *page, |
453 | static inline void clear_page_guard_flag(struct page *page) { } | 462 | unsigned int order, int migratetype) {} |
463 | static inline void clear_page_guard(struct zone *zone, struct page *page, | ||
464 | unsigned int order, int migratetype) {} | ||
454 | #endif | 465 | #endif |
455 | 466 | ||
456 | static inline void set_page_order(struct page *page, unsigned int order) | 467 | static inline void set_page_order(struct page *page, unsigned int order) |
@@ -581,12 +592,7 @@ static inline void __free_one_page(struct page *page, | |||
581 | * merge with it and move up one order. | 592 | * merge with it and move up one order. |
582 | */ | 593 | */ |
583 | if (page_is_guard(buddy)) { | 594 | if (page_is_guard(buddy)) { |
584 | clear_page_guard_flag(buddy); | 595 | clear_page_guard(zone, buddy, order, migratetype); |
585 | set_page_private(buddy, 0); | ||
586 | if (!is_migrate_isolate(migratetype)) { | ||
587 | __mod_zone_freepage_state(zone, 1 << order, | ||
588 | migratetype); | ||
589 | } | ||
590 | } else { | 596 | } else { |
591 | list_del(&buddy->lru); | 597 | list_del(&buddy->lru); |
592 | zone->free_area[order].nr_free--; | 598 | zone->free_area[order].nr_free--; |
@@ -861,23 +867,17 @@ static inline void expand(struct zone *zone, struct page *page, | |||
861 | size >>= 1; | 867 | size >>= 1; |
862 | VM_BUG_ON_PAGE(bad_range(zone, &page[size]), &page[size]); | 868 | VM_BUG_ON_PAGE(bad_range(zone, &page[size]), &page[size]); |
863 | 869 | ||
864 | #ifdef CONFIG_DEBUG_PAGEALLOC | 870 | if (IS_ENABLED(CONFIG_DEBUG_PAGEALLOC) && |
865 | if (high < debug_guardpage_minorder()) { | 871 | high < debug_guardpage_minorder()) { |
866 | /* | 872 | /* |
867 | * Mark as guard pages (or page), that will allow to | 873 | * Mark as guard pages (or page), that will allow to |
868 | * merge back to allocator when buddy will be freed. | 874 | * merge back to allocator when buddy will be freed. |
869 | * Corresponding page table entries will not be touched, | 875 | * Corresponding page table entries will not be touched, |
870 | * pages will stay not present in virtual address space | 876 | * pages will stay not present in virtual address space |
871 | */ | 877 | */ |
872 | INIT_LIST_HEAD(&page[size].lru); | 878 | set_page_guard(zone, &page[size], high, migratetype); |
873 | set_page_guard_flag(&page[size]); | ||
874 | set_page_private(&page[size], high); | ||
875 | /* Guard pages are not available for any usage */ | ||
876 | __mod_zone_freepage_state(zone, -(1 << high), | ||
877 | migratetype); | ||
878 | continue; | 879 | continue; |
879 | } | 880 | } |
880 | #endif | ||
881 | list_add(&page[size].lru, &area->free_list[migratetype]); | 881 | list_add(&page[size].lru, &area->free_list[migratetype]); |
882 | area->nr_free++; | 882 | area->nr_free++; |
883 | set_page_order(&page[size], high); | 883 | set_page_order(&page[size], high); |