From: David Hildenbrand <david@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
mm-commits@vger.kernel.org, vbabka@suse.cz, sfr@canb.auug.org.au,
rppt@kernel.org, lorenzo.stoakes@oracle.com, jcmvbkbc@gmail.com
Subject: Re: + mm-constify-highmem-related-functions-for-improved-const-correctness-fix.patch added to mm-unstable branch
Date: Thu, 4 Sep 2025 08:37:11 +0200 [thread overview]
Message-ID: <3100ea45-ea18-498a-866c-a04c2f453db6@redhat.com> (raw)
In-Reply-To: <20250904025957.EC982C4CEE7@smtp.kernel.org>
On 04.09.25 04:59, Andrew Morton wrote:
>
> The patch titled
> Subject: mm-constify-highmem-related-functions-for-improved-const-correctness-fix
> has been added to the -mm mm-unstable branch. Its filename is
> mm-constify-highmem-related-functions-for-improved-const-correctness-fix.patch
>
> This patch will shortly appear at
> https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-constify-highmem-related-functions-for-improved-const-correctness-fix.patch
>
> This patch will later appear in the mm-unstable branch at
> git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
>
> Before you just go and hit "reply", please:
> a) Consider who else should be cc'ed
> b) Prefer to cc a suitable mailing list as well
> c) Ideally: find the original patch on the mailing list and do a
> reply-to-all to that, adding suitable additional cc's
>
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
>
> The -mm tree is included into linux-next via the mm-everything
> branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> and is updated there every 2-3 working days
>
> ------------------------------------------------------
> From: Andrew Morton <akpm@linux-foundation.org>
> Subject: mm-constify-highmem-related-functions-for-improved-const-correctness-fix
> Date: Wed Sep 3 07:51:59 PM PDT 2025
>
> nastily "fix" folio_page()
>
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> include/linux/page-flags.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/include/linux/page-flags.h~mm-constify-highmem-related-functions-for-improved-const-correctness-fix
> +++ a/include/linux/page-flags.h
> @@ -316,9 +316,9 @@ static __always_inline unsigned long _co
> * check that the page number lies within @folio; the caller is presumed
> * to have a reference to the page.
> */
> -static inline struct page *folio_page(struct folio *folio, unsigned long n)
> +static inline struct page *folio_page(const struct folio *folio, unsigned long n)
> {
> - return &folio->page + n;
> + return (struct page *)(&folio->page + n);
> }
>
> static __always_inline int PageTail(const struct page *page)
> _
>
I think we should do the following. And I'm wondering if we should squash that
into the relevant nth_page patch instead:
From 6ada1d36d18969db587ab647757a9538ee1d09a6 Mon Sep 17 00:00:00 2001
From: David Hildenbrand <david@redhat.com>
Date: Thu, 4 Sep 2025 08:35:24 +0200
Subject: [PATCH] fixup folio_page() const correctness
Signed-off-by: David Hildenbrand <david@redhat.com>
---
include/linux/page-flags.h | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index faf17ca211b4f..3a9e73abea3e3 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -307,6 +307,12 @@ static __always_inline unsigned long _compound_head(const struct page *page)
const struct page *: (const struct folio *)_compound_head(p), \
struct page *: (struct folio *)_compound_head(p)))
+static inline const struct page *_folio_page(const struct folio *folio,
+ unsigned long n)
+{
+ return &folio->page + n;
+}
+
/**
* folio_page - Return a page from a folio.
* @folio: The folio.
@@ -316,10 +322,9 @@ static __always_inline unsigned long _compound_head(const struct page *page)
* check that the page number lies within @folio; the caller is presumed
* to have a reference to the page.
*/
-static inline struct page *folio_page(struct folio *folio, unsigned long n)
-{
- return &folio->page + n;
-}
+#define folio_page(f, n) (_Generic((f), \
+ const struct folio *: (const struct page *)_folio_page(f, n), \
+ struct folio *: (struct page *)_folio_page(f, n)))
static __always_inline int PageTail(const struct page *page)
{
--
2.50.1
--
Cheers
David / dhildenb
next prev parent reply other threads:[~2025-09-04 6:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 2:59 + mm-constify-highmem-related-functions-for-improved-const-correctness-fix.patch added to mm-unstable branch Andrew Morton
2025-09-04 6:37 ` David Hildenbrand [this message]
2025-09-04 7:57 ` Vlastimil Babka
2025-09-04 9:16 ` David Hildenbrand
2025-09-04 9:28 ` Vlastimil Babka
2025-09-04 9:40 ` David Hildenbrand
2025-09-04 9:48 ` Vlastimil Babka
2025-09-04 10:01 ` David Hildenbrand
2025-09-04 13:06 ` Matthew Wilcox
2025-09-04 13:15 ` David Hildenbrand
2025-09-21 20:05 ` Andrew Morton
2025-09-23 9:02 ` David Hildenbrand
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=3100ea45-ea18-498a-866c-a04c2f453db6@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=jcmvbkbc@gmail.com \
--cc=lorenzo.stoakes@oracle.com \
--cc=mm-commits@vger.kernel.org \
--cc=rppt@kernel.org \
--cc=sfr@canb.auug.org.au \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.