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
28622862 bool allow_pagefault);
28632863 #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */
28642864
2865−extern struct page_ext_operations debug_guardpage_ops;
2866−
28672865 #ifdef CONFIG_DEBUG_PAGEALLOC
28682866 extern unsigned int _debug_guardpage_minorder;
28692867 DECLARE_STATIC_KEY_FALSE(_debug_guardpage_enabled);
@@ -2880,16 +2878,10 @@ static inline bool debug_guardpage_enabled(void) · 10 unmodified lines
28802878
28812879 static inline bool page_is_guard(struct page *page)
28822880 {
2883− struct page_ext *page_ext;
2884−
28852881 if (!debug_guardpage_enabled())
28862882 return false;
28872883
2888− page_ext = lookup_page_ext(page);
2889− if (unlikely(!page_ext))
2890− return false;
2891−
2892− return test_bit(PAGE_EXT_DEBUG_GUARD, &page_ext->flags);
2884+ return PageGuard(page);
28932885 }
28942886 #else
28952887 static 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
703703 #define PG_offline 0x00000100
704704 #define PG_kmemcg 0x00000200
705705 #define PG_table 0x00000400
706+#define PG_guard 0x00000800
706707
707708 #define PageType(page, flag) \
708709 ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
@@ -754,6 +755,11 @@ PAGE_TYPE_OPS(Kmemcg, kmemcg) · 45 unmodified lines
754755 */
755756 PAGE_TYPE_OPS(Table, table)
756757
758+/*
759+ * Marks guardpages used with debug_pagealloc.
760+ */
761+PAGE_TYPE_OPS(Guard, guard)
762+
757763 extern bool is_free_buddy_page(struct page *page);
758764
759765 __PAGEFLAG(Isolated, isolated, PF_ANY);
include/linux/page_ext.h+0−1
@@ -17,7 +17,6 @@ struct page_ext_operations { · 16 unmodified lines
1717 #ifdef CONFIG_PAGE_EXTENSION
1818
1919 enum page_ext_flags {
20− PAGE_EXT_DEBUG_GUARD,
2120 PAGE_EXT_OWNER,
2221 #if defined(CONFIG_IDLE_PAGE_TRACKING) && !defined(CONFIG_64BIT)
2322 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