From: "David Hildenbrand (Red Hat)" <davidhildenbrandkernel@gmail.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>, linux-mm@kvack.org
Cc: vishal.moola@gmail.com, Andrew Morton <akpm@linux-foundation.org>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>, Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Matthew Wilcox <willy@infradead.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/ptdesc: Derive from the compound head in page_ptdesc()
Date: Mon, 10 Nov 2025 09:53:38 +0100 [thread overview]
Message-ID: <048f6173-f538-46eb-b0dd-70f1aaa79562@gmail.com> (raw)
In-Reply-To: <20251110063725.3118037-1-anshuman.khandual@arm.com>
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@linux-foundation.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Mike Rapoport <rppt@kernel.org>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Matthew Wilcox <willy@infradead.org>
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.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.
next prev parent reply other threads:[~2025-11-10 8:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 6:37 [PATCH] mm/ptdesc: Derive from the compound head in page_ptdesc() Anshuman Khandual
2025-11-10 8:53 ` David Hildenbrand (Red Hat) [this message]
2025-11-11 1:51 ` Anshuman Khandual
2025-11-10 13:38 ` Matthew Wilcox
2025-11-11 3:32 ` Anshuman Khandual
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=048f6173-f538-46eb-b0dd-70f1aaa79562@gmail.com \
--to=davidhildenbrandkernel@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=vishal.moola@gmail.com \
--cc=willy@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).