linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Christoph Lameter <cl@gentwo.org>,
	David Rientjes <rientjes@google.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Harry Yoo <harry.yoo@oracle.com>,
	linux-mm@kvack.org
Subject: [PATCH v2 04/11] slab: Add SL_pfmemalloc flag
Date: Wed, 11 Jun 2025 16:59:07 +0100	[thread overview]
Message-ID: <20250611155916.2579160-5-willy@infradead.org> (raw)
In-Reply-To: <20250611155916.2579160-1-willy@infradead.org>

Give slab its own name for this flag.  Move the implementation from
slab.h to slub.c since it's only used inside slub.c.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Harry Yoo <harry.yoo@oracle.com>
---
 mm/slab.h | 24 ------------------------
 mm/slub.c | 21 +++++++++++++++++++++
 2 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/mm/slab.h b/mm/slab.h
index 32785ff3470a..248b34c839b7 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -167,30 +167,6 @@ static_assert(IS_ALIGNED(offsetof(struct slab, freelist), sizeof(freelist_aba_t)
  */
 #define slab_page(s) folio_page(slab_folio(s), 0)
 
-/*
- * If network-based swap is enabled, sl*b must keep track of whether pages
- * were allocated from pfmemalloc reserves.
- */
-static inline bool slab_test_pfmemalloc(const struct slab *slab)
-{
-	return folio_test_active(slab_folio(slab));
-}
-
-static inline void slab_set_pfmemalloc(struct slab *slab)
-{
-	folio_set_active(slab_folio(slab));
-}
-
-static inline void slab_clear_pfmemalloc(struct slab *slab)
-{
-	folio_clear_active(slab_folio(slab));
-}
-
-static inline void __slab_clear_pfmemalloc(struct slab *slab)
-{
-	__folio_clear_active(slab_folio(slab));
-}
-
 static inline void *slab_address(const struct slab *slab)
 {
 	return folio_address(slab_folio(slab));
diff --git a/mm/slub.c b/mm/slub.c
index 2bf1ad8a70ce..8a1df2ad26ed 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -187,6 +187,7 @@
  * enum slab_flags - How the slab flags bits are used.
  * @SL_locked: Is locked with slab_lock()
  * @SL_partial: On the per-node partial list
+ * @SL_pfmemalloc: Was allocated from PF_MEMALLOC reserves
  *
  * The slab flags share space with the page flags but some bits have
  * different interpretations.  The high bits are used for information
@@ -195,6 +196,7 @@
 enum slab_flags {
 	SL_locked = PG_locked,
 	SL_partial = PG_workingset,	/* Historical reasons for this bit */
+	SL_pfmemalloc = PG_active,	/* Historical reasons for this bit */
 };
 
 /*
@@ -648,6 +650,25 @@ static inline unsigned int slub_get_cpu_partial(struct kmem_cache *s)
 }
 #endif /* CONFIG_SLUB_CPU_PARTIAL */
 
+/*
+ * If network-based swap is enabled, slub must keep track of whether memory
+ * were allocated from pfmemalloc reserves.
+ */
+static inline bool slab_test_pfmemalloc(const struct slab *slab)
+{
+	return test_bit(SL_pfmemalloc, &slab->flags);
+}
+
+static inline void slab_set_pfmemalloc(struct slab *slab)
+{
+	set_bit(SL_pfmemalloc, &slab->flags);
+}
+
+static inline void __slab_clear_pfmemalloc(struct slab *slab)
+{
+	__clear_bit(SL_pfmemalloc, &slab->flags);
+}
+
 /*
  * Per slab locking using the pagelock
  */
-- 
2.47.2



  parent reply	other threads:[~2025-06-11 15:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11 15:59 [PATCH v2 00/11] Various slab improvements Matthew Wilcox (Oracle)
2025-06-11 15:59 ` [PATCH v2 01/11] doc: Move SLUB documentation to the admin guide Matthew Wilcox (Oracle)
2025-06-11 15:59 ` [PATCH v2 02/11] slab: Rename slab->__page_flags to slab->flags Matthew Wilcox (Oracle)
2025-06-11 15:59 ` [PATCH v2 03/11] slab: Add SL_partial flag Matthew Wilcox (Oracle)
2025-06-11 15:59 ` Matthew Wilcox (Oracle) [this message]
2025-06-11 15:59 ` [PATCH v2 05/11] slub: Fix a documentation build error for krealloc() Matthew Wilcox (Oracle)
2025-06-11 15:59 ` [PATCH v2 06/11] doc: Add slab internal kernel-doc Matthew Wilcox (Oracle)
2025-06-17 14:03   ` Vlastimil Babka
2025-06-17 14:16     ` Matthew Wilcox
2025-06-11 15:59 ` [PATCH v2 07/11] vmcoreinfo: Remove documentation of PG_slab and PG_hugetlb Matthew Wilcox (Oracle)
2025-06-11 15:59 ` [PATCH v2 08/11] proc: Remove mention of PG_slab Matthew Wilcox (Oracle)
2025-06-11 15:59 ` [PATCH v2 09/11] kfence: " Matthew Wilcox (Oracle)
2025-06-11 15:59 ` [PATCH v2 10/11] memcg_slabinfo: Fix use " Matthew Wilcox (Oracle)
2025-06-11 15:59 ` [PATCH v2 11/11] slab: Update MAINTAINERS entry Matthew Wilcox (Oracle)
2025-06-15 21:51   ` David Rientjes
2025-06-16  7:24   ` Harry Yoo
2025-06-23 12:28 ` [PATCH v2 00/11] Various slab improvements Vlastimil Babka

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=20250611155916.2579160-5-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=cl@gentwo.org \
    --cc=harry.yoo@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=vbabka@suse.cz \
    /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;
as well as URLs for NNTP newsgroup(s).