mm/debug: print only page mapcount (excluding folio entire mapcount) in __dump_folio()
authorDavid Hildenbrand <david@redhat.com>
Tue, 9 Apr 2024 19:23:00 +0000 (21:23 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 6 May 2024 00:53:31 +0000 (17:53 -0700)
Let's simplify and only print the page mapcount: we already print the
large folio mapcount and the entire folio mapcount for large folios
separately; that should be sufficient to figure out what's happening.

While at it, print the page mapcount also if it had an underflow,
filtering out only typed pages.

Link: https://lkml.kernel.org/r/20240409192301.907377-18-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Hugh Dickins <hughd@google.com>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Richard Chang <richardycc@google.com>
Cc: Rich Felker <dalias@libc.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Yin Fengwei <fengwei.yin@intel.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/debug.c

index d064db42af54e0fb66b228d579006077995bed91..69e524c3e6012ee78773730f3dd6bbabd9b2cb5a 100644 (file)
@@ -55,15 +55,10 @@ static void __dump_folio(struct folio *folio, struct page *page,
                unsigned long pfn, unsigned long idx)
 {
        struct address_space *mapping = folio_mapping(folio);
-       int mapcount = atomic_read(&page->_mapcount) + 1;
+       int mapcount = atomic_read(&page->_mapcount);
        char *type = "";
 
-       /* Open-code page_mapcount() to avoid looking up a stale folio */
-       if (mapcount < 0)
-               mapcount = 0;
-       if (folio_test_large(folio))
-               mapcount += folio_entire_mapcount(folio);
-
+       mapcount = page_type_has_type(mapcount) ? 0 : mapcount + 1;
        pr_warn("page: refcount:%d mapcount:%d mapping:%p index:%#lx pfn:%#lx\n",
                        folio_ref_count(folio), mapcount, mapping,
                        folio->index + idx, pfn);