[RFC PATCH v3 07/10] make bh_cachep statically allocated

From: Al Viro

Date: Sat Jun 13 2026 - 01:10:24 EST


Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
---
fs/buffer.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index b0b3792b1496..e834f7091f51 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -51,6 +51,7 @@
#include <linux/fscrypt.h>
#include <linux/fsverity.h>
#include <linux/sched/isolation.h>
+#include <linux/slab-static.h>

#include "internal.h"

@@ -2906,7 +2907,8 @@ EXPORT_SYMBOL(try_to_free_buffers);
/*
* Buffer-head allocation
*/
-static struct kmem_cache *bh_cachep __ro_after_init;
+static struct kmem_cache_opaque bh_cache;
+#define bh_cachep to_kmem_cache(&bh_cache)

/*
* Once the number of bh's in the machine exceeds this level, we start
@@ -3065,7 +3067,7 @@ void __init buffer_init(void)
unsigned long nrpages;
int ret;

- bh_cachep = KMEM_CACHE(buffer_head,
+ KMEM_CACHE_SETUP(bh_cachep, buffer_head,
SLAB_RECLAIM_ACCOUNT|SLAB_PANIC);
/*
* Limit the bh occupancy to 10% of ZONE_NORMAL
--
2.47.3