]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
slab: Add SL_pfmemalloc flag
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 11 Jun 2025 15:59:07 +0000 (16:59 +0100)
committerVlastimil Babka <vbabka@suse.cz>
Wed, 18 Jun 2025 11:06:26 +0000 (13:06 +0200)
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>
Link: https://patch.msgid.link/20250611155916.2579160-5-willy@infradead.org
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
mm/slab.h
mm/slub.c

index 32785ff3470a89e693a013bcfba44ab531dbff1d..248b34c839b7ca39cf14e139c62d116efb97d30f 100644 (file)
--- 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));
index 15d92c736af5771faebebfa656e9107ed3bb8761..d44be423dd50753e31671f9940269908830c4996 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
  * 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
 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
  */