lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 22 May 2024 13:32:14 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Sukrit Bhatnagar <Sukrit.Bhatnagar@...y.com>
Cc: Petr Mladek <pmladek@...e.com>, Steven Rostedt <rostedt@...dmis.org>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Sergey Senozhatsky <senozhatsky@...omium.org>,
	Jonathan Corbet <corbet@....net>, Christoph Lameter <cl@...ux.com>,
	Pekka Enberg <penberg@...nel.org>,
	David Rientjes <rientjes@...gle.com>,
	Joonsoo Kim <iamjoonsoo.kim@....com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Vlastimil Babka <vbabka@...e.cz>,
	Roman Gushchin <roman.gushchin@...ux.dev>,
	Hyeonggon Yoo <42.hyeyoo@...il.com>,
	Masami Hiramatsu <mhiramat@...nel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-mm@...ck.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] mm: debug: print correct information for slab folios

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?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ