linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Sukrit Bhatnagar <Sukrit.Bhatnagar@sony.com>
Cc: Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mm: debug: print correct information for slab folios
Date: Wed, 22 May 2024 13:32:14 +0100	[thread overview]
Message-ID: <Zk3lzjVbXVrLW0XR@casper.infradead.org> (raw)
In-Reply-To: <20240522074629.2420423-3-Sukrit.Bhatnagar@sony.com>

On Wed, May 22, 2024 at 04:46:29PM +0900, Sukrit Bhatnagar wrote:
> The function dump_page() prints "anon" even for slab pages.
> This is not correct, especially now that struct slab is separated from
> struct page, and that the slab pages cannot be mapped to userspace.
> 
> [    7.071985] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x102768
> [    7.072602] head: order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
> [    7.073085] anon flags: 0x8000000000000840(slab|head|zone=2)
> [    7.073777] raw: 8000000000000840 ffff8881000419c0 0000000000000000 dead000000000001
> 
> This debugging output may be misleading, and it is not easy to understand
> unless we read the source code.
> 
> If the folio tests true for slab, do not print information that does not
> apply to it. Instead, print the slab flags stored in the kmem_cache field.
> 
> [    7.248722] page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888103e6aa87>
> [    7.249135] head: order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
> [    7.249429] slab flags: 0x8000000000000840(slab|head|zone=2)
> [    7.249664] cache flags: 0x10310(HWCACHE_ALIGN|PANIC|TYPESAFE_BY_RCU|CMPXCHG_DOUBLE)
> [    7.249999] raw: 8000000000000000 ffffea00040f9a01 ffffea00040f9bc8 dead000000000400

You haven't tested this against the current codebase ...

> @@ -98,6 +101,8 @@ static void __dump_folio(struct folio *folio, struct page *page,
>  		is_migrate_cma_folio(folio, pfn) ? " CMA" : "");
>  	if (page_has_type(&folio->page))
>  		pr_warn("page_type: %pGt\n", &folio->page.page_type);
> +	else if (folio_test_slab(folio))
> +		pr_warn("cache flags: %pGs\n", &((struct slab *)&folio->page)->slab_cache->flags);
>  

... because page_has_type() is now true for slab; there is no more
PG_slab.  I think you also want:

	folio_slab(folio)->slab_cache->flags

Anyway, we have print_slab_info() which is currently static in slub.c.
Maybe that needs to become non-static and dump_page() should call that
for slabs?


  reply	other threads:[~2024-05-22 12:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-22  7:46 [PATCH 0/2] Improve dump_page() output for slab pages Sukrit Bhatnagar
2024-05-22  7:46 ` [PATCH 1/2] mm: printk: introduce new format %pGs for slab flags Sukrit Bhatnagar
2024-05-22 20:25   ` kernel test robot
2024-05-22  7:46 ` [PATCH 2/2] mm: debug: print correct information for slab folios Sukrit Bhatnagar
2024-05-22 12:32   ` Matthew Wilcox [this message]
2024-05-27 10:46     ` Sukrit.Bhatnagar
2024-05-22 14:11 ` [PATCH 0/2] Improve dump_page() output for slab pages Matthew Wilcox
2024-05-27 10:48   ` Sukrit.Bhatnagar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zk3lzjVbXVrLW0XR@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=42.hyeyoo@gmail.com \
    --cc=Sukrit.Bhatnagar@sony.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=cl@linux.com \
    --cc=corbet@lwn.net \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=penberg@kernel.org \
    --cc=pmladek@suse.com \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox