All of lore.kernel.org
 help / color / mirror / Atom feed
* [merged mm-stable] mm-simplify-folio_page-and-folio_page_idx.patch removed from -mm tree
@ 2025-09-21 21:23 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2025-09-21 21:23 UTC (permalink / raw)
  To: mm-commits, ziy, richard.weiyang, lorenzo.stoakes, david, akpm


The quilt patch titled
     Subject: mm: simplify folio_page() and folio_page_idx()
has been removed from the -mm tree.  Its filename was
     mm-simplify-folio_page-and-folio_page_idx.patch

This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: David Hildenbrand <david@redhat.com>
Subject: mm: simplify folio_page() and folio_page_idx()
Date: Mon, 1 Sep 2025 17:03:33 +0200

Now that a single folio/compound page can no longer span memory sections
in problematic kernel configurations, we can stop using nth_page() in
folio_page() and folio_page_idx().

While at it, turn both macros into static inline functions and add kernel
doc for folio_page_idx().

Link: https://lkml.kernel.org/r/20250901150359.867252-13-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/mm.h         |   16 ++++++++++++++--
 include/linux/page-flags.h |    5 ++++-
 2 files changed, 18 insertions(+), 3 deletions(-)

--- a/include/linux/mm.h~mm-simplify-folio_page-and-folio_page_idx
+++ a/include/linux/mm.h
@@ -210,10 +210,8 @@ extern unsigned long sysctl_admin_reserv
 
 #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
 #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
-#define folio_page_idx(folio, p)	(page_to_pfn(p) - folio_pfn(folio))
 #else
 #define nth_page(page,n) ((page) + (n))
-#define folio_page_idx(folio, p)	((p) - &(folio)->page)
 #endif
 
 /* to align the pointer to the (next) page boundary */
@@ -225,6 +223,20 @@ extern unsigned long sysctl_admin_reserv
 /* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */
 #define PAGE_ALIGNED(addr)	IS_ALIGNED((unsigned long)(addr), PAGE_SIZE)
 
+/**
+ * folio_page_idx - Return the number of a page in a folio.
+ * @folio: The folio.
+ * @page: The folio page.
+ *
+ * This function expects that the page is actually part of the folio.
+ * The returned number is relative to the start of the folio.
+ */
+static inline unsigned long folio_page_idx(const struct folio *folio,
+		const struct page *page)
+{
+	return page - &folio->page;
+}
+
 static inline struct folio *lru_to_folio(struct list_head *head)
 {
 	return list_entry((head)->prev, struct folio, lru);
--- a/include/linux/page-flags.h~mm-simplify-folio_page-and-folio_page_idx
+++ a/include/linux/page-flags.h
@@ -316,7 +316,10 @@ 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.
  */
-#define folio_page(folio, n)	nth_page(&(folio)->page, n)
+static inline struct page *folio_page(struct folio *folio, unsigned long n)
+{
+	return &folio->page + n;
+}
 
 static __always_inline int PageTail(const struct page *page)
 {
_

Patches currently in -mm which might be from david@redhat.com are



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-09-21 21:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-21 21:23 [merged mm-stable] mm-simplify-folio_page-and-folio_page_idx.patch removed from -mm tree Andrew Morton

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.