* [PATCH v1] mm: convert folio_page() back to a macro
@ 2025-09-23 14:00 David Hildenbrand
2025-09-23 15:31 ` Kiryl Shutsemau
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: David Hildenbrand @ 2025-09-23 14:00 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, David Hildenbrand, Andrew Morton, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
In commit 73b3294b1152 ("mm: simplify folio_page() and folio_page_idx()")
we converted folio_page() into a static inline function. However
briefly afterwards in commit a847b17009ec ("mm: constify highmem related
functions for improved const-correctness") we had to add some nasty
const-away casting to make the compiler happy when checking const
correctness.
So let's just convert it back to a simple macro so the compiler can
check const correctness properly. There is the alternative of
using a _Generic() similar to page_folio(), but there is not a lot of
benefit compared to just using a simple macro.
Cc: Andrew Morton <akpm@linux-foundation.org>
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>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
include/linux/page-flags.h | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 568011930e358..48e27768e7ba9 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -316,10 +316,7 @@ 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(const struct folio *folio, unsigned long n)
-{
- return (struct page *)(&folio->page + n);
-}
+#define folio_page(folio, n) (&(folio)->page + (n))
static __always_inline int PageTail(const struct page *page)
{
--
2.51.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] mm: convert folio_page() back to a macro
2025-09-23 14:00 [PATCH v1] mm: convert folio_page() back to a macro David Hildenbrand
@ 2025-09-23 15:31 ` Kiryl Shutsemau
2025-09-24 3:11 ` Lance Yang
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Kiryl Shutsemau @ 2025-09-23 15:31 UTC (permalink / raw)
To: David Hildenbrand
Cc: linux-kernel, linux-mm, Andrew Morton, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
On Tue, Sep 23, 2025 at 04:00:58PM +0200, David Hildenbrand wrote:
> In commit 73b3294b1152 ("mm: simplify folio_page() and folio_page_idx()")
> we converted folio_page() into a static inline function. However
> briefly afterwards in commit a847b17009ec ("mm: constify highmem related
> functions for improved const-correctness") we had to add some nasty
> const-away casting to make the compiler happy when checking const
> correctness.
>
> So let's just convert it back to a simple macro so the compiler can
> check const correctness properly. There is the alternative of
> using a _Generic() similar to page_folio(), but there is not a lot of
> benefit compared to just using a simple macro.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> 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>
> Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Kiryl Shutsemau <kas@kernel.org>
--
Kiryl Shutsemau / Kirill A. Shutemov
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] mm: convert folio_page() back to a macro
2025-09-23 14:00 [PATCH v1] mm: convert folio_page() back to a macro David Hildenbrand
2025-09-23 15:31 ` Kiryl Shutsemau
@ 2025-09-24 3:11 ` Lance Yang
2025-09-24 8:17 ` SeongJae Park
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Lance Yang @ 2025-09-24 3:11 UTC (permalink / raw)
To: David Hildenbrand
Cc: linux-kernel, linux-mm, Andrew Morton, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
On Wed, Sep 24, 2025 at 12:44 AM David Hildenbrand <david@redhat.com> wrote:
>
> In commit 73b3294b1152 ("mm: simplify folio_page() and folio_page_idx()")
> we converted folio_page() into a static inline function. However
> briefly afterwards in commit a847b17009ec ("mm: constify highmem related
> functions for improved const-correctness") we had to add some nasty
> const-away casting to make the compiler happy when checking const
> correctness.
>
> So let's just convert it back to a simple macro so the compiler can
> check const correctness properly. There is the alternative of
> using a _Generic() similar to page_folio(), but there is not a lot of
> benefit compared to just using a simple macro.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> 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>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
LGTM. Feel free to add:
Reviewed-by: Lance Yang <lance.yang@linux.dev>
> include/linux/page-flags.h | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 568011930e358..48e27768e7ba9 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -316,10 +316,7 @@ 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(const struct folio *folio, unsigned long n)
> -{
> - return (struct page *)(&folio->page + n);
> -}
> +#define folio_page(folio, n) (&(folio)->page + (n))
>
> static __always_inline int PageTail(const struct page *page)
> {
> --
> 2.51.0
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] mm: convert folio_page() back to a macro
2025-09-23 14:00 [PATCH v1] mm: convert folio_page() back to a macro David Hildenbrand
2025-09-23 15:31 ` Kiryl Shutsemau
2025-09-24 3:11 ` Lance Yang
@ 2025-09-24 8:17 ` SeongJae Park
2025-09-24 8:57 ` Dev Jain
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: SeongJae Park @ 2025-09-24 8:17 UTC (permalink / raw)
To: David Hildenbrand
Cc: SeongJae Park, linux-kernel, linux-mm, Andrew Morton,
Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
On Tue, 23 Sep 2025 16:00:58 +0200 David Hildenbrand <david@redhat.com> wrote:
> In commit 73b3294b1152 ("mm: simplify folio_page() and folio_page_idx()")
> we converted folio_page() into a static inline function. However
> briefly afterwards in commit a847b17009ec ("mm: constify highmem related
> functions for improved const-correctness") we had to add some nasty
> const-away casting to make the compiler happy when checking const
> correctness.
>
> So let's just convert it back to a simple macro so the compiler can
> check const correctness properly. There is the alternative of
> using a _Generic() similar to page_folio(), but there is not a lot of
> benefit compared to just using a simple macro.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> 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>
> Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] mm: convert folio_page() back to a macro
2025-09-23 14:00 [PATCH v1] mm: convert folio_page() back to a macro David Hildenbrand
` (2 preceding siblings ...)
2025-09-24 8:17 ` SeongJae Park
@ 2025-09-24 8:57 ` Dev Jain
2025-09-24 16:45 ` Suren Baghdasaryan
2025-09-24 18:48 ` Vishal Moola (Oracle)
2025-09-25 1:01 ` Wei Yang
5 siblings, 1 reply; 8+ messages in thread
From: Dev Jain @ 2025-09-24 8:57 UTC (permalink / raw)
To: David Hildenbrand, linux-kernel
Cc: linux-mm, Andrew Morton, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko
On 23/09/25 7:30 pm, David Hildenbrand wrote:
> In commit 73b3294b1152 ("mm: simplify folio_page() and folio_page_idx()")
> we converted folio_page() into a static inline function. However
> briefly afterwards in commit a847b17009ec ("mm: constify highmem related
> functions for improved const-correctness") we had to add some nasty
> const-away casting to make the compiler happy when checking const
> correctness.
>
> So let's just convert it back to a simple macro so the compiler can
> check const correctness properly. There is the alternative of
> using a _Generic() similar to page_folio(), but there is not a lot of
> benefit compared to just using a simple macro.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> 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>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
Reviewed-by: Dev Jain <dev.jain@arm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] mm: convert folio_page() back to a macro
2025-09-24 8:57 ` Dev Jain
@ 2025-09-24 16:45 ` Suren Baghdasaryan
0 siblings, 0 replies; 8+ messages in thread
From: Suren Baghdasaryan @ 2025-09-24 16:45 UTC (permalink / raw)
To: Dev Jain
Cc: David Hildenbrand, linux-kernel, linux-mm, Andrew Morton,
Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Michal Hocko
On Wed, Sep 24, 2025 at 1:57 AM Dev Jain <dev.jain@arm.com> wrote:
>
>
> On 23/09/25 7:30 pm, David Hildenbrand wrote:
> > In commit 73b3294b1152 ("mm: simplify folio_page() and folio_page_idx()")
> > we converted folio_page() into a static inline function. However
> > briefly afterwards in commit a847b17009ec ("mm: constify highmem related
> > functions for improved const-correctness") we had to add some nasty
> > const-away casting to make the compiler happy when checking const
> > correctness.
> >
> > So let's just convert it back to a simple macro so the compiler can
> > check const correctness properly. There is the alternative of
> > using a _Generic() similar to page_folio(), but there is not a lot of
> > benefit compared to just using a simple macro.
> >
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > 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>
> > Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
> > ---
>
> Reviewed-by: Dev Jain <dev.jain@arm.com>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] mm: convert folio_page() back to a macro
2025-09-23 14:00 [PATCH v1] mm: convert folio_page() back to a macro David Hildenbrand
` (3 preceding siblings ...)
2025-09-24 8:57 ` Dev Jain
@ 2025-09-24 18:48 ` Vishal Moola (Oracle)
2025-09-25 1:01 ` Wei Yang
5 siblings, 0 replies; 8+ messages in thread
From: Vishal Moola (Oracle) @ 2025-09-24 18:48 UTC (permalink / raw)
To: David Hildenbrand
Cc: linux-kernel, linux-mm, Andrew Morton, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
On Tue, Sep 23, 2025 at 04:00:58PM +0200, David Hildenbrand wrote:
> In commit 73b3294b1152 ("mm: simplify folio_page() and folio_page_idx()")
> we converted folio_page() into a static inline function. However
> briefly afterwards in commit a847b17009ec ("mm: constify highmem related
> functions for improved const-correctness") we had to add some nasty
> const-away casting to make the compiler happy when checking const
> correctness.
>
> So let's just convert it back to a simple macro so the compiler can
> check const correctness properly. There is the alternative of
> using a _Generic() similar to page_folio(), but there is not a lot of
> benefit compared to just using a simple macro.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> 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>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1] mm: convert folio_page() back to a macro
2025-09-23 14:00 [PATCH v1] mm: convert folio_page() back to a macro David Hildenbrand
` (4 preceding siblings ...)
2025-09-24 18:48 ` Vishal Moola (Oracle)
@ 2025-09-25 1:01 ` Wei Yang
5 siblings, 0 replies; 8+ messages in thread
From: Wei Yang @ 2025-09-25 1:01 UTC (permalink / raw)
To: David Hildenbrand
Cc: linux-kernel, linux-mm, Andrew Morton, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
On Tue, Sep 23, 2025 at 04:00:58PM +0200, David Hildenbrand wrote:
>In commit 73b3294b1152 ("mm: simplify folio_page() and folio_page_idx()")
>we converted folio_page() into a static inline function. However
>briefly afterwards in commit a847b17009ec ("mm: constify highmem related
>functions for improved const-correctness") we had to add some nasty
>const-away casting to make the compiler happy when checking const
>correctness.
>
>So let's just convert it back to a simple macro so the compiler can
>check const correctness properly. There is the alternative of
>using a _Generic() similar to page_folio(), but there is not a lot of
>benefit compared to just using a simple macro.
>
>Cc: Andrew Morton <akpm@linux-foundation.org>
>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>
>Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-09-25 1:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-23 14:00 [PATCH v1] mm: convert folio_page() back to a macro David Hildenbrand
2025-09-23 15:31 ` Kiryl Shutsemau
2025-09-24 3:11 ` Lance Yang
2025-09-24 8:17 ` SeongJae Park
2025-09-24 8:57 ` Dev Jain
2025-09-24 16:45 ` Suren Baghdasaryan
2025-09-24 18:48 ` Vishal Moola (Oracle)
2025-09-25 1:01 ` Wei Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox