History

mm, debug_pagealloc: use a page type instead of page_ext flag

When debug_pagealloc is enabled, we currently allocate the page_ext array to mark guard pages with the PAGE_EXT_DEBUG_GUARD flag. Now that we have the page_type field in struct page, we can use that instead, as guard pages are neither PageSlab nor mapped to userspace. This reduces memory overhead when debug_pagealloc is enabled and there are no other features requiring the page_ext array.

Vlastimil Babka committed 7 years ago

Commit 3972f6b1 parent 4462b327 files · +17 −54Browse files

Showing the changes to include/linux (3 of 7 files). Show all

Unified · Split

3 files
  1. include/linux/mm.h +1 −9
  2. include/linux/page-flags.h +6 −0
  3. include/linux/page_ext.h +0 −1
include/linux/mm.h+1−9
@@ -2862,8 +2862,6 @@ extern long copy_huge_page_from_user(struct page *dst_page, · 2861 unmodified lines
2862 bool allow_pagefault);2862 bool allow_pagefault);
2863#endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */2863#endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */
2864 2864
2865extern struct page_ext_operations debug_guardpage_ops;
2866
2867#ifdef CONFIG_DEBUG_PAGEALLOC2865#ifdef CONFIG_DEBUG_PAGEALLOC
2868extern unsigned int _debug_guardpage_minorder;2866extern unsigned int _debug_guardpage_minorder;
2869DECLARE_STATIC_KEY_FALSE(_debug_guardpage_enabled);2867DECLARE_STATIC_KEY_FALSE(_debug_guardpage_enabled);
@@ -2880,16 +2878,10 @@ static inline bool debug_guardpage_enabled(void) · 10 unmodified lines
2880 2878
2881static inline bool page_is_guard(struct page *page)2879static inline bool page_is_guard(struct page *page)
2882{2880{
2883 struct page_ext *page_ext;
2884
2885 if (!debug_guardpage_enabled())2881 if (!debug_guardpage_enabled())
2886 return false;2882 return false;
2887 2883
2888 page_ext = lookup_page_ext(page);2884 return PageGuard(page);
2889 if (unlikely(!page_ext))
2890 return false;
2891
2892 return test_bit(PAGE_EXT_DEBUG_GUARD, &page_ext->flags);
2893}2885}
2894#else2886#else
2895static inline unsigned int debug_guardpage_minorder(void) { return 0; }2887static inline unsigned int debug_guardpage_minorder(void) { return 0; }
include/linux/page-flags.h+6−0
@@ -703,6 +703,7 @@ PAGEFLAG_FALSE(DoubleMap) · 702 unmodified lines
703#define PG_offline 0x00000100703#define PG_offline 0x00000100
704#define PG_kmemcg 0x00000200704#define PG_kmemcg 0x00000200
705#define PG_table 0x00000400705#define PG_table 0x00000400
706#define PG_guard 0x00000800
706 707
707#define PageType(page, flag) \708#define PageType(page, flag) \
708 ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)709 ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
@@ -754,6 +755,11 @@ PAGE_TYPE_OPS(Kmemcg, kmemcg) · 45 unmodified lines
754 */755 */
755PAGE_TYPE_OPS(Table, table)756PAGE_TYPE_OPS(Table, table)
756 757
758/*
759 * Marks guardpages used with debug_pagealloc.
760 */
761PAGE_TYPE_OPS(Guard, guard)
762
757extern bool is_free_buddy_page(struct page *page);763extern bool is_free_buddy_page(struct page *page);
758 764
759__PAGEFLAG(Isolated, isolated, PF_ANY);765__PAGEFLAG(Isolated, isolated, PF_ANY);
include/linux/page_ext.h+0−1
@@ -17,7 +17,6 @@ struct page_ext_operations { · 16 unmodified lines
17#ifdef CONFIG_PAGE_EXTENSION17#ifdef CONFIG_PAGE_EXTENSION
18 18
19enum page_ext_flags {19enum page_ext_flags {
20 PAGE_EXT_DEBUG_GUARD,
21 PAGE_EXT_OWNER,20 PAGE_EXT_OWNER,
22#if defined(CONFIG_IDLE_PAGE_TRACKING) && !defined(CONFIG_64BIT)21#if defined(CONFIG_IDLE_PAGE_TRACKING) && !defined(CONFIG_64BIT)
23 PAGE_EXT_YOUNG,22 PAGE_EXT_YOUNG,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t