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] [day] [month] [year] [list]
Message-ID: <048f6173-f538-46eb-b0dd-70f1aaa79562@gmail.com>
Date: Mon, 10 Nov 2025 09:53:38 +0100
From: "David Hildenbrand (Red Hat)" <davidhildenbrandkernel@...il.com>
To: Anshuman Khandual <anshuman.khandual@....com>, linux-mm@...ck.org
Cc: vishal.moola@...il.com, Andrew Morton <akpm@...ux-foundation.org>,
 Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
 "Liam R . Howlett" <Liam.Howlett@...cle.com>,
 Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>,
 Suren Baghdasaryan <surenb@...gle.com>, Michal Hocko <mhocko@...e.com>,
 Matthew Wilcox <willy@...radead.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/ptdesc: Derive from the compound head in page_ptdesc()

On 10.11.25 07:37, Anshuman Khandual wrote:
> struct ptdesc (including all relevant helpers) support multi order compound
> pages. But page_ptdesc() coverts given page into its own ptdesc rather than
> deriving from its compound head as would have been expected otherwise. Just
> change the macro to fetch the struct ptdesc from the compound head instead,
> so that the same struct ptdesc is reached from all tail pages.
> 
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: David Hildenbrand <david@...hat.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
> Cc: Liam R. Howlett <Liam.Howlett@...cle.com>
> Cc: Vlastimil Babka <vbabka@...e.cz>
> Cc: Mike Rapoport <rppt@...nel.org>
> Cc: Suren Baghdasaryan <surenb@...gle.com>
> Cc: Michal Hocko <mhocko@...e.com>
> Cc: Matthew Wilcox <willy@...radead.org>
> Cc: linux-mm@...ck.org
> Cc: linux-kernel@...r.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@....com>
> ---
> This applies on v6.18-rc5
> 
> Found via code inspection. Apparently struct ptdesc could represent a page
> table page which is multi order looking into helpers as ptdesc_nr_pages(),
> __pagetable_ctor/dtor() and pagetable_free() etc. Am I missing something ?
> 
>   include/linux/mm_types.h | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index 90e5790c318f..f7107bc55d1e 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -604,9 +604,9 @@ static_assert(sizeof(struct ptdesc) <= sizeof(struct page));
>   	const struct ptdesc *:		(const struct folio *)(pt),	\
>   	struct ptdesc *:		(struct folio *)(pt)))
>   
> -#define page_ptdesc(p)			(_Generic((p),			\
> -	const struct page *:		(const struct ptdesc *)(p),	\
> -	struct page *:			(struct ptdesc *)(p)))
> +#define page_ptdesc(p)			(_Generic((p),					\
> +	const struct page *:		(const struct ptdesc *)_compound_head(p),	\
> +	struct page *:			(struct ptdesc *)_compound_head(p)))

Well, this adds overhead :)

The real question is when we would be converting from a tail page to a 
ptdesc.

Take a look at pmd_ptdesc()->pmd_pgtable_page() where we avoid looking 
up a tail page in the first place.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ