[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260110040217.1927971-10-viro@zeniv.linux.org.uk>
Date: Sat, 10 Jan 2026 04:02:11 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: linux-mm@...ck.org
Cc: Vlastimil Babka <vbabka@...e.cz>,
Harry Yoo <harry.yoo@...cle.com>,
linux-fsdevel@...r.kernel.org,
Linus Torvalds <torvalds@...ux-foundation.org>,
Christian Brauner <brauner@...nel.org>,
Jan Kara <jack@...e.cz>,
Mateusz Guzik <mguzik@...il.com>,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH 09/15] make filp and bfilp caches static-duration
As much as I hate it, the name "filp" is a part of userland ABI at this
point - scripts grepping for it in /proc/slabinfo do exist ;-/
Signed-off-by: Al Viro <viro@...iv.linux.org.uk>
---
fs/file_table.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/fs/file_table.c b/fs/file_table.c
index cd4a3db4659a..18a992b40109 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -27,6 +27,7 @@
#include <linux/task_work.h>
#include <linux/swap.h>
#include <linux/kmemleak.h>
+#include <linux/slab-static.h>
#include <linux/atomic.h>
@@ -38,8 +39,10 @@ static struct files_stat_struct files_stat = {
};
/* SLAB cache for file structures */
-static struct kmem_cache *filp_cachep __ro_after_init;
-static struct kmem_cache *bfilp_cachep __ro_after_init;
+static struct kmem_cache_opaque file_cache;
+static struct kmem_cache_opaque backing_file_cache;
+#define filp_cachep to_kmem_cache(&file_cache)
+#define bfilp_cachep to_kmem_cache(&backing_file_cache)
static struct percpu_counter nr_files __cacheline_aligned_in_smp;
@@ -587,19 +590,20 @@ void fput_close(struct file *file)
void __init files_init(void)
{
- struct kmem_cache_args args = {
- .use_freeptr_offset = true,
- .freeptr_offset = offsetof(struct file, f_freeptr),
- };
-
- filp_cachep = kmem_cache_create("filp", sizeof(struct file), &args,
- SLAB_HWCACHE_ALIGN | SLAB_PANIC |
- SLAB_ACCOUNT | SLAB_TYPESAFE_BY_RCU);
+ __KMEM_CACHE_SETUP(filp_cachep, "filp", sizeof(struct file),
+ SLAB_HWCACHE_ALIGN | SLAB_PANIC |
+ SLAB_ACCOUNT | SLAB_TYPESAFE_BY_RCU,
+ .use_freeptr_offset = true,
+ .freeptr_offset = offsetof(struct file,
+ f_freeptr));
+
+ __KMEM_CACHE_SETUP(bfilp_cachep, "bfilp", sizeof(struct backing_file),
+ SLAB_HWCACHE_ALIGN | SLAB_PANIC |
+ SLAB_ACCOUNT | SLAB_TYPESAFE_BY_RCU,
+ .use_freeptr_offset = true,
+ .freeptr_offset = offsetof(struct backing_file,
+ bf_freeptr));
- args.freeptr_offset = offsetof(struct backing_file, bf_freeptr);
- bfilp_cachep = kmem_cache_create("bfilp", sizeof(struct backing_file),
- &args, SLAB_HWCACHE_ALIGN | SLAB_PANIC |
- SLAB_ACCOUNT | SLAB_TYPESAFE_BY_RCU);
percpu_counter_init(&nr_files, 0, GFP_KERNEL);
}
--
2.47.3
Powered by blists - more mailing lists