]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
mm: mark pages in use for page tables
authorMatthew Wilcox <mawilcox@microsoft.com>
Fri, 8 Jun 2018 00:08:23 +0000 (17:08 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 8 Jun 2018 00:34:37 +0000 (17:34 -0700)
Define a new PageTable bit in the page_type and use it to mark pages in
use as page tables.  This can be helpful when debugging crashdumps or
analysing memory fragmentation.  Add a KPF flag to report these pages to
userspace and update page-types.c to interpret that flag.

Note that only pages currently accounted as NR_PAGETABLES are tracked as
PageTable; this does not include pgd/p4d/pud/pmd pages.  Those will be the
subject of a later patch.

Link: http://lkml.kernel.org/r/20180518194519.3820-4-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Christoph Lameter <cl@linux.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/proc/page.c
include/linux/mm.h
include/linux/page-flags.h
include/uapi/linux/kernel-page-flags.h
tools/vm/page-types.c

index 1491918a33c385394fcaf06ef07dcd7751832c82..792c78a491747e248d99dc613c88e0beb8cffd0c 100644 (file)
@@ -154,6 +154,8 @@ u64 stable_page_flags(struct page *page)
 
        if (PageBalloon(page))
                u |= 1 << KPF_BALLOON;
+       if (PageTable(page))
+               u |= 1 << KPF_PGTABLE;
 
        if (page_is_idle(page))
                u |= 1 << KPF_IDLE;
index d1dc618a56bfdcb43b36c9776fceb5159d9423ef..1dd588b7c64930d9cce02d370bd45029218c1a6a 100644 (file)
@@ -1851,6 +1851,7 @@ static inline bool pgtable_page_ctor(struct page *page)
 {
        if (!ptlock_init(page))
                return false;
+       __SetPageTable(page);
        inc_zone_page_state(page, NR_PAGETABLE);
        return true;
 }
@@ -1858,6 +1859,7 @@ static inline bool pgtable_page_ctor(struct page *page)
 static inline void pgtable_page_dtor(struct page *page)
 {
        pte_lock_deinit(page);
+       __ClearPageTable(page);
        dec_zone_page_state(page, NR_PAGETABLE);
 }
 
index 8c25b28a35aa707c224ead42376b6f6d0a6a78a7..901943e4754b3388b59620c401aff7659d673f45 100644 (file)
@@ -655,6 +655,7 @@ PAGEFLAG_FALSE(DoubleMap)
 #define PG_buddy       0x00000080
 #define PG_balloon     0x00000100
 #define PG_kmemcg      0x00000200
+#define PG_table       0x00000400
 
 #define PageType(page, flag)                                           \
        ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
@@ -693,6 +694,11 @@ PAGE_TYPE_OPS(Balloon, balloon)
  */
 PAGE_TYPE_OPS(Kmemcg, kmemcg)
 
+/*
+ * Marks pages in use as page tables.
+ */
+PAGE_TYPE_OPS(Table, table)
+
 extern bool is_free_buddy_page(struct page *page);
 
 __PAGEFLAG(Isolated, isolated, PF_ANY);
index fa139841ec182d12b8caf2d850a6f977ca1aac0e..21b9113c69da4bb608bf23b58446fde24d682b08 100644 (file)
@@ -35,6 +35,6 @@
 #define KPF_BALLOON            23
 #define KPF_ZERO_PAGE          24
 #define KPF_IDLE               25
-
+#define KPF_PGTABLE            26
 
 #endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */
index a8783f48f77fc7f51c8e510db305f80443d1b279..cce853dca69117652a92c4dfa28682ac11197829 100644 (file)
@@ -131,6 +131,7 @@ static const char * const page_flag_names[] = {
        [KPF_KSM]               = "x:ksm",
        [KPF_THP]               = "t:thp",
        [KPF_BALLOON]           = "o:balloon",
+       [KPF_PGTABLE]           = "g:pgtable",
        [KPF_ZERO_PAGE]         = "z:zero_page",
        [KPF_IDLE]              = "i:idle_page",