Re: [PATCH v1] mm: convert folio_page() back to a macro

From: Suren Baghdasaryan
Date: Wed Sep 24 2025 - 12:45:54 EST


On Wed, Sep 24, 2025 at 1:57 AM Dev Jain <dev.jain@xxxxxxx> 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@xxxxxxxxxxxxxxxxxxxx>
> > Cc: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
> > Cc: "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx>
> > Cc: Vlastimil Babka <vbabka@xxxxxxx>
> > Cc: Mike Rapoport <rppt@xxxxxxxxxx>
> > Cc: Suren Baghdasaryan <surenb@xxxxxxxxxx>
> > Cc: Michal Hocko <mhocko@xxxxxxxx>
> > Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>

Reviewed-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>

> > ---
>
> Reviewed-by: Dev Jain <dev.jain@xxxxxxx>
>