Discontiguous memory may require the use of nth_page instead of adding to struct page arithmetically. However, discontiguous memory cannot exist within a single folio. The function folio_page is mostly used for accessing a page within a folio, therefore using nth_page for it is overkill. Move it to the only place where it's needed, which is folio_next. Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> diff --git a/include/linux/mm.h b/include/linux/mm.h index 7b1068ddcbb7..5f63ee0770f7 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2115,7 +2115,7 @@ static inline int thp_nr_pages(struct page *page) */ static inline struct folio *folio_next(struct folio *folio) { - return (struct folio *)folio_page(folio, folio_nr_pages(folio)); + return (struct folio *)nth_page(&folio->page, folio_nr_pages(folio)); } /** diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 36d283552f80..ebba355c45a5 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -275,7 +275,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. */ -#define folio_page(folio, n) nth_page(&(folio)->page, n) +#define folio_page(folio, n) (&(folio)->page + (n)) static __always_inline int PageTail(const struct page *page) { -- Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt