Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Vlastimil Babka <vbabka@kernel.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Harry Yoo <harry@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
	David Rientjes <rientjes@google.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	linux-mm@kvack.org
Subject: [PATCH] slab: Remove slab_folio()
Date: Wed, 23 Sep 2026 19:36:51 +0100	[thread overview]
Message-ID: <20260923183655.3364885-1-willy@infradead.org> (raw)

This is the final step of divorcing struct slab from struct folio.
It's still tied to struct page, but there are no more mentions of folios
in the slab code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/slab.h | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/mm/slab.h b/mm/slab.h
index 8fd6835e4235..3ae7e70c27ff 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -149,21 +149,6 @@ static_assert(sizeof(struct slab) <= sizeof(struct page));
 static_assert(IS_ALIGNED(offsetof(struct slab, freelist), sizeof(struct freelist_counters)));
 #endif
 
-/**
- * slab_folio - The folio allocated for a slab
- * @s: The slab.
- *
- * Slabs are allocated as folios that contain the individual objects and are
- * using some fields in the first struct page of the folio - those fields are
- * now accessed by struct slab. It is occasionally necessary to convert back to
- * a folio in order to communicate with the rest of the mm.  Please use this
- * helper function instead of casting yourself, as the implementation may change
- * in the future.
- */
-#define slab_folio(s)		(_Generic((s),				\
-	const struct slab *:	(const struct folio *)s,		\
-	struct slab *:		(struct folio *)s))
-
 /**
  * page_slab - Converts from struct page to its slab.
  * @page: A page which may or may not belong to a slab.
@@ -184,15 +169,16 @@ static inline struct slab *page_slab(const struct page *page)
  * slab_page - The first struct page allocated for a slab
  * @s: The slab.
  *
- * A convenience wrapper for converting slab to the first struct page of the
- * underlying folio, to communicate with code not yet converted to folio or
- * struct slab.
+ * A convenience wrapper for returning the first page allocated to this slab.
+ * to communicate with code not yet converted to struct slab.
  */
-#define slab_page(s) folio_page(slab_folio(s), 0)
+#define slab_page(s) 		(_Generic((s),				\
+	const struct slab *:	(const struct page *)s,			\
+	struct slab *:		(struct page *)s))
 
 static inline void *slab_address(const struct slab *slab)
 {
-	return folio_address(slab_folio(slab));
+	return page_address(slab_page(slab));
 }
 
 static inline int slab_nid(const struct slab *slab)
@@ -212,7 +198,7 @@ static inline struct slab *virt_to_slab(const void *addr)
 
 static inline int slab_order(const struct slab *slab)
 {
-	return folio_order(slab_folio(slab));
+	return compound_order(slab_page(slab));
 }
 
 static inline size_t slab_size(const struct slab *slab)
-- 
2.47.3



             reply	other threads:[~2026-09-23 18:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 18:36 Matthew Wilcox (Oracle) [this message]
2026-09-23 19:19 ` [PATCH] slab: Remove slab_folio() Gregory Price
2026-09-23 19:45 ` Harry Yoo
2026-09-23 20:11   ` Vlastimil Babka (SUSE)
2026-09-23 20:41     ` Matthew Wilcox
2026-09-24  7:41       ` Vlastimil Babka (SUSE)
2026-09-24 17:43 ` Harry Yoo (Meta)
2026-09-25  8:08 ` Vlastimil Babka (SUSE)
2026-09-25  8:35 ` Hao Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260923183655.3364885-1-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=hao.li@linux.dev \
    --cc=harry@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox