Skip to content

Commit 81e78b7

Browse files
davidhildenbrandakpm00
authored andcommitted
mm: convert folio_page() back to a macro
In commit 73b3294 ("mm: simplify folio_page() and folio_page_idx()") we converted folio_page() into a static inline function. However briefly afterwards in commit a847b17 ("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. Link: https://lkml.kernel.org/r/20250923140058.2020023-1-david@redhat.com Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Kiryl Shutsemau <kas@kernel.org> Reviewed-by: SeongJae Park <sj@kernel.org> Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com> Reviewed-by: Dev Jain <dev.jain@arm.com> Reviewed-by: Suren Baghdasaryan <surenb@google.com> Reviewed-by: Lance Yang <lance.yang@linux.dev> Reviewed-by: Wei Yang <richard.weiyang@gmail.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: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 1acc369 commit 81e78b7

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

include/linux/page-flags.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,7 @@ static __always_inline unsigned long _compound_head(const struct page *page)
316316
* check that the page number lies within @folio; the caller is presumed
317317
* to have a reference to the page.
318318
*/
319-
static inline struct page *folio_page(const struct folio *folio, unsigned long n)
320-
{
321-
return (struct page *)(&folio->page + n);
322-
}
319+
#define folio_page(folio, n) (&(folio)->page + (n))
323320

324321
static __always_inline int PageTail(const struct page *page)
325322
{

0 commit comments

Comments
 (0)