Re: [PATCH 1/3] mm: Print head flags in dump_page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-06-30 04:59, Matthew Wilcox wrote:
...
How about ...
[   38.049155] flags: 0x17ffe000000000e(anon|referenced|uptodate|dirty|compound)

That is, change pageflag_names[] to print 'head' as 'compound' and move the
'anon' or 'ksm' to look like a pageflag.  Also CMA.  Like this:

+++ b/include/trace/events/mmflags.h
@@ -96,7 +96,7 @@
         {1UL << PG_private,             "private"       },              \
         {1UL << PG_private_2,           "private_2"     },              \
         {1UL << PG_writeback,           "writeback"     },              \
-       {1UL << PG_head,                "head"          },              \
+       {1UL << PG_head,                "compound"      },              \
         {1UL << PG_mappedtodisk,        "mappedtodisk"  },              \
         {1UL << PG_reclaim,             "reclaim"       },              \
         {1UL << PG_swapbacked,          "swapbacked"    },              \
+++ b/mm/debug.c
@@ -54,7 +54,7 @@ void __dump_page(struct page *page, const char *reason)
          * state for debugging, it should be fine to accept a bit of
          * inaccuracy here due to racing.
          */
-       bool page_cma = is_migrate_cma_page(page);
+       char *cma = is_migrate_cma_page(page) ? "|cma" : "";
         int mapcount;
         char *type = "";
@@ -71,6 +71,10 @@ void __dump_page(struct page *page, const char *reason)
         if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) {
                 /* Corrupt page, cannot call page_mapping */
                 mapping = page->mapping;
+               if ((unsigned long)mapping & PAGE_MAPPING_ANON)
+                       mapping = NULL;
+               mapping = (struct address_space *)
+                               ((unsigned long)mapping & ~PAGE_MAPPING_FLAGS);
                 head = page;
                 compound = false;
         } else {
[...]
         if (PageKsm(page))
-               type = "ksm ";
+               type = "ksm|";
         else if (PageAnon(page))
-               type = "anon ";
-       else if (mapping) {
+               type = "anon|";
+
+       BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS + 1);
+       pr_warn("flags: %#lx(%s%pGp%s)\n", page->flags, type, &page->flags,
+                       cma);
+
+       if (mapping) {
                 const struct inode *host;
                 const struct address_space_operations *a_ops;
@@ -163,11 +167,6 @@ void __dump_page(struct page *page, const char *reason)
                 }
         }
  out_mapping:
-       BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS + 1);
-
-       pr_warn("%sflags: %#lx(%pGp)%s\n", type, head->flags, &head->flags,
-               page_cma ? " CMA" : "");
-
  hex_only:
         print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32,
                         sizeof(unsigned long), page,

Can also delete the 'out_mapping' label this way.

OK, so after applying that on top of your original series, and your
line-break approach, here's what the output looks like for regular
and THP, head and tail pages (all involving FOLL_PIN):

THP FOLL_PIN page: head page:

[   42.360473] page:0000000025f35fdb refcount:513 mapcount:1 mapping:0000000000000000 index:0x0
[   42.368012] head:0000000025f35fdb order:9 compound_mapcount:1 compound_pincount:512
[   42.374761] flags: 0x17ffe000001000e(anon|referenced|uptodate|dirty|compound)
[   42.380994] raw: 017ffe000001000e ffffffff83649ca0 ffffea0020c80008 ffff888898091901
[   42.387822] raw: 0000000000000000 0000000000000000 00000201ffffffff 0000000000000000
[   42.394680] page dumped because: gup_benchmark: head page: dump_page test

THP FOLL_PIN page: tail page:

[   42.408222] page:00000000803d233b refcount:513 mapcount:1 mapping:0000000000000000 index:0x11
[   42.415850] head:0000000025f35fdb order:9 compound_mapcount:1 compound_pincount:512
[   42.422607] flags: 0x17ffe0000000000(anon|)
[   42.425772] raw: 017ffe0000000000 ffffea0020c98001 ffffea0020c98448 dead000000000400
[   42.432636] raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
[   42.439490] head: 017ffe000001000e ffffffff83649ca0 ffffea0020c80008 ffff888898091901
[   42.446431] head: 0000000000000000 0000000000000000 00000201ffffffff 0000000000000000
[   42.453355] page dumped because: gup_benchmark: tail page: dump_page test

Non-THP FOLL_PIN page: head page:

[   41.513677] page:00000000190e28ba refcount:1025 mapcount:1 mapping:0000000000000000 index:0x0
[   41.521331] flags: 0x17ffe0000080034(anon|uptodate|lru|active|swapbacked)
[   41.527189] raw: 017ffe0000080034 ffffea002228db08 ffffea0022215108 ffff888898090191
[   41.534020] raw: 0000000000000000 0000000000000000 0000040100000000 0000000000000000
[   41.540863] page dumped because: gup_benchmark: head page: dump_page test

Non-THP FOLL_PIN page: tail page:

[   41.554472] page:00000000696a8210 refcount:1025 mapcount:1 mapping:0000000000000000 index:0x11
[   41.562230] flags: 0x17ffe0000080034(anon|uptodate|lru|active|swapbacked)
[   41.568073] raw: 017ffe0000080034 ffffea0022195688 ffffea0021a4e608 ffff888898090191
[   41.574940] raw: 0000000000000011 0000000000000000 0000040100000000 0000000000000000
[   41.581768] page dumped because: gup_benchmark: tail page: dump_page test


(I really like it that we're debating this ... it feels like we've been
in a bit of a push-pull with the debug patches over the years)


Yes, it's good that we're pausing a moment to polish this up. Lots of goodness
here and I like the above output.

thanks,
--
John Hubbard
NVIDIA




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux