From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BC3E248F73; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; cv=none; b=I2JL5ItujKQl+5ZmqtoUYq83aSA2jZVlIma2RbtgQYHh45d+laTiQ2HmqalM/pFKguj2obggJ1kwEa8VuD69DfpduLJ38h4xVpmVY1rG+Dafk+M1tGVbNsDXnVIyBJIkPMGE8F0Qwj7ZSgr4k3l0lOnuYoVbXGVb/Z+FU6kmo4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; c=relaxed/simple; bh=HOsK/G56W4aJSsighlbNaxoXSE0SWAUvdOsMg4W6JqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eTHzSEQMf6bCZ+P+0ttJc6tbxYM8TmMmvsZAsjVEe+gmjjF5g9qHcndJm5lcrlPkKBOY5ME96eyReXN8HfPGfWseQnrXfpABZ13b39Wkb3GAw/FYcRTbL2zjgS2xY7+lywg+y/v9JOXhCvQe81MpL8aqy7NKh4yqTQ2L42O8kUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=HSRxtOhp; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="HSRxtOhp" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=Alv7P4uLpxdxMD2oNaydKzkEIOwEPgrlWZHJemiwZ9Q=; b=HSRxtOhpMmaEouMQr/0/lYOM/I qgQUuo0j8DPxV4mM+vI3CLx7moN8FzGu/b9+Lm039eQa0I4Zcm2bKlGuejHfqZP+UghkZEL+g8B41 tKO7jjHY32xsn88QfbgW2QCe//hF3o/ckmKNn0QYjqG/DBvegOWChUgqDNMKsRXIIzpJPSNv2LU6I xQ0wFbMvXF2ABC5l4RB3QfxPGcuF0p6kxppzBCMeDe/J22kflfNl5x7j2Blv19cnr/vZjPqz3CZc0 cGdexsOCdNtgPIp+4aD5j4Kt0/wkXDfUq5wMgcGAKW3bP5DtuP11QFxUIqrZ/+H3k3IwdheUoJzSR xgCg4lYQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB8-000000085Z6-0p2j; Sat, 10 Jan 2026 04:02:18 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 01/15] static kmem_cache instances for core caches Date: Sat, 10 Jan 2026 04:02:03 +0000 Message-ID: <20260110040217.1927971-2-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" kmem_cache_create() and friends create new instances of struct kmem_cache and return pointers to those. Quite a few things in core kernel are allocated from such caches; each allocation involves dereferencing an assign-once pointer and for sufficiently hot ones that dereferencing does show in profiles. There had been patches floating around switching some of those to runtime_const infrastructure. Unfortunately, it's arch-specific and most of the architectures lack it. There's an alternative approach applicable at least to the caches that are never destroyed, which covers a lot of them. No matter what, runtime_const for pointers is not going to be faster than plain &, so if we had struct kmem_cache instances with static storage duration, we would be at least no worse off than we are with runtime_const variants. There are obstacles to doing that, but they turn out to be easy to deal with. 1) as it is, struct kmem_cache is opaque for anything outside of a few files in mm/*; that avoids serious headache with header dependencies, etc., and it's not something we want to lose. Solution: struct kmem_cache_opaque, with the size and alignment identical to struct kmem_cache. Calculation of size and alignment can be done via the same mechanism we use for asm-offsets.h and rq-offsets.h, with build-time check for mismatches. With that done, we get an opaque type defined in linux/slab-static.h that can be used for declaring those caches. In linux/slab.h we add a forward declaration of kmem_cache_opaque + helper (to_kmem_cache()) converting a pointer to kmem_cache_opaque into pointer to kmem_cache. 2) real constructor of kmem_cache needs to be taught to deal with preallocated instances. That turns out to be easy - we already pass an obscene amount of optional arguments via struct kmem_cache_args, so we can stash the pointer to preallocated instance in there. Changes in mm/slab_common.c are very minor - we should treat preallocated caches as unmergable, use the instance passed to us instead of allocating a new one and we should not free them. That's it. Note that slab-static.h is needed only in places that create such instances; all users need only slab.h (and they can be modular, unlike runtime_const-based approach). That covers the instances that never get destroyed. Quite a few fall into that category, but there's a major exception - anything in modules must be destroyed before the module gets removed. For example, filesystems that have their inodes allocated from a private kmem_cache can't make use of that technics for their inode allocations, etc. It's not that hard to deal with, but for now let's just ban including slab-static.h from modules. Signed-off-by: Al Viro --- Kbuild | 13 +++++++- include/linux/slab-static.h | 65 +++++++++++++++++++++++++++++++++++++ include/linux/slab.h | 7 ++++ mm/kmem_cache_size.c | 20 ++++++++++++ mm/slab_common.c | 30 ++++++++--------- mm/slub.c | 7 ++++ 6 files changed, 126 insertions(+), 16 deletions(-) create mode 100644 include/linux/slab-static.h create mode 100644 mm/kmem_cache_size.c diff --git a/Kbuild b/Kbuild index 13324b4bbe23..eb985a6614eb 100644 --- a/Kbuild +++ b/Kbuild @@ -45,13 +45,24 @@ kernel/sched/rq-offsets.s: $(offsets-file) $(rq-offsets-file): kernel/sched/rq-offsets.s FORCE $(call filechk,offsets,__RQ_OFFSETS_H__) =20 +# generate kmem_cache_size.h + +kmem_cache_size-file :=3D include/generated/kmem_cache_size.h + +targets +=3D mm/kmem_cache_size.s + +mm/kmem_cache_size.s: $(rq-offsets-file) + +$(kmem_cache_size-file): mm/kmem_cache_size.s FORCE + $(call filechk,offsets,__KMEM_CACHE_SIZE_H__) + # Check for missing system calls =20 quiet_cmd_syscalls =3D CALL $< cmd_syscalls =3D $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_sysca= lls_flags) =20 PHONY +=3D missing-syscalls -missing-syscalls: scripts/checksyscalls.sh $(rq-offsets-file) +missing-syscalls: scripts/checksyscalls.sh $(kmem_cache_size-file) $(call cmd,syscalls) =20 # Check the manual modification of atomic headers diff --git a/include/linux/slab-static.h b/include/linux/slab-static.h new file mode 100644 index 000000000000..47b2220b4988 --- /dev/null +++ b/include/linux/slab-static.h @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_SLAB_STATIC_H +#define _LINUX_SLAB_STATIC_H + +#ifdef MODULE +#error "can't use that in modules" +#endif + +#include + +/* same size and alignment as struct kmem_cache: */ +struct kmem_cache_opaque { + unsigned char opaque[KMEM_CACHE_SIZE]; +} __aligned(KMEM_CACHE_ALIGN); + +#define __KMEM_CACHE_SETUP(cache, name, size, flags, ...) \ + __kmem_cache_create_args((name), (size), \ + &(struct kmem_cache_args) { \ + .preallocated =3D (cache), \ + __VA_ARGS__}, (flags)) + +static inline int +kmem_cache_setup_usercopy(struct kmem_cache *s, + const char *name, unsigned int size, + unsigned int align, slab_flags_t flags, + unsigned int useroffset, unsigned int usersize, + void (*ctor)(void *)) +{ + struct kmem_cache *res; + res =3D __KMEM_CACHE_SETUP(s, name, size, flags, + .align =3D align, + .ctor =3D ctor, + .useroffset =3D useroffset, + .usersize =3D usersize); + if (IS_ERR(res)) + return PTR_ERR(res); + return 0; +} + +static inline int +kmem_cache_setup(struct kmem_cache *s, + const char *name, unsigned int size, + unsigned int align, slab_flags_t flags, + void (*ctor)(void *)) +{ + struct kmem_cache *res; + res =3D __KMEM_CACHE_SETUP(s, name, size, flags, + .align =3D align, + .ctor =3D ctor); + if (IS_ERR(res)) + return PTR_ERR(res); + return 0; +} + +#define KMEM_CACHE_SETUP(s, __struct, __flags) \ + __KMEM_CACHE_SETUP((s), #__struct, sizeof(struct __struct), (__flags), \ + .align =3D __alignof__(struct __struct)) + +#define KMEM_CACHE_SETUP_USERCOPY(s, __struct, __flags, __field) \ + __KMEM_CACHE_SETUP((s), #__struct, sizeof(struct __struct), (__flags), \ + .align =3D __alignof__(struct __struct), \ + .useroffset =3D offsetof(struct __struct, __field), \ + .usersize =3D sizeof_field(struct __struct, __field)) + +#endif diff --git a/include/linux/slab.h b/include/linux/slab.h index 2482992248dc..f16c784148b4 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -261,11 +261,17 @@ enum _slab_flag_bits { =20 struct list_lru; struct mem_cgroup; +struct kmem_cache_opaque; /* * struct kmem_cache related prototypes */ bool slab_is_available(void); =20 +static inline struct kmem_cache *to_kmem_cache(struct kmem_cache_opaque *p) +{ + return (struct kmem_cache *)p; +} + /** * struct kmem_cache_args - Less common arguments for kmem_cache_create() * @@ -366,6 +372,7 @@ struct kmem_cache_args { * %0 means no sheaves will be created. */ unsigned int sheaf_capacity; + struct kmem_cache *preallocated; }; =20 struct kmem_cache *__kmem_cache_create_args(const char *name, diff --git a/mm/kmem_cache_size.c b/mm/kmem_cache_size.c new file mode 100644 index 000000000000..1ddbfa41a507 --- /dev/null +++ b/mm/kmem_cache_size.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Generate definitions needed by the preprocessor. + * This code generates raw asm output which is post-processed + * to extract and format the required data. + */ + +#define COMPILE_OFFSETS +#include +#include "slab.h" + +int main(void) +{ + /* The constants to put into include/generated/kmem_cache_size.h */ + DEFINE(KMEM_CACHE_SIZE, sizeof(struct kmem_cache)); + DEFINE(KMEM_CACHE_ALIGN, __alignof(struct kmem_cache)); + /* End of constants */ + + return 0; +} diff --git a/mm/slab_common.c b/mm/slab_common.c index eed7ea556cb1..81a413b44afb 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -224,33 +224,30 @@ static struct kmem_cache *create_cache(const char *na= me, struct kmem_cache_args *args, slab_flags_t flags) { - struct kmem_cache *s; + struct kmem_cache *s =3D args->preallocated; int err; =20 /* If a custom freelist pointer is requested make sure it's sane. */ - err =3D -EINVAL; if (args->use_freeptr_offset && (args->freeptr_offset >=3D object_size || !(flags & SLAB_TYPESAFE_BY_RCU) || !IS_ALIGNED(args->freeptr_offset, __alignof__(freeptr_t)))) - goto out; + return ERR_PTR(-EINVAL); =20 - err =3D -ENOMEM; - s =3D kmem_cache_zalloc(kmem_cache, GFP_KERNEL); - if (!s) - goto out; + if (!s) { + s =3D kmem_cache_zalloc(kmem_cache, GFP_KERNEL); + if (!s) + return ERR_PTR(-ENOMEM); + } err =3D do_kmem_cache_create(s, name, object_size, args, flags); - if (err) - goto out_free_cache; - + if (unlikely(err)) { + if (!args->preallocated) + kmem_cache_free(kmem_cache, s); + return ERR_PTR(err); + } s->refcount =3D 1; list_add(&s->list, &slab_caches); return s; - -out_free_cache: - kmem_cache_free(kmem_cache, s); -out: - return ERR_PTR(err); } =20 /** @@ -324,6 +321,9 @@ struct kmem_cache *__kmem_cache_create_args(const char = *name, object_size - args->usersize < args->useroffset)) args->usersize =3D args->useroffset =3D 0; =20 + if (args->preallocated) + flags |=3D SLAB_NO_MERGE; + if (!args->usersize && !args->sheaf_capacity) s =3D __kmem_cache_alias(name, object_size, args->align, flags, args->ctor); diff --git a/mm/slub.c b/mm/slub.c index 861592ac5425..41fe79b3f055 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -47,6 +47,7 @@ #include #include #include +#include #include =20 #include "internal.h" @@ -8491,6 +8492,12 @@ void __init kmem_cache_init(void) boot_kmem_cache_node; int node; =20 + /* verify that kmem_cache_opaque is correct */ + BUILD_BUG_ON(sizeof(struct kmem_cache) !=3D + sizeof(struct kmem_cache_opaque)); + BUILD_BUG_ON(__alignof(struct kmem_cache) !=3D + __alignof(struct kmem_cache_opaque)); + if (debug_guardpage_minorder()) slub_max_order =3D 0; =20 --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63C13500963; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; cv=none; b=om30xKkfyD+/H20dwE6iSypC0q5l2Dhfwtzy2FBPaepOI7km6X/aZVFyFdvfzCrXGTf+wLVOsq1WoR/6Oq97OeuaQDPsPaDYybEwctBUDz3OznVJW1jJCZdggBUro10QPwO1iY0VSON0SnbFpWZFvzUTHEP2sXa7tRYCgCMRMss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; c=relaxed/simple; bh=FNJ/LAWDZhf/4UGECsNoVJF3S9MIQgpyO8vZJlbx1Wc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RTx4sRFVTKbZByfSN4bUGGdQi/NSt0Nnj3H1sZ6pWM+T+uq2DVWqxcaWI8KnjBS9AwHdWRz/34YyKbOazA9up/ukYpS+L53qC+fMEtDe8LLlEgVKsDGv5Bf6qBpJE+WlHiV5CW6nsys2bK1GdPGhqVL7eu9jcP3Ddu1NoA5ogUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=TFa5gVdr; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="TFa5gVdr" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=ISNZFsbhMluGOOgPJOf7PuXZbW/+Y33dgsD1DeUdNV0=; b=TFa5gVdrJvHVBG1sACtJpPQTOx +glfX5twmsJHBvGQUd7Lw6Y+eEtRTXV77LC0AUyJHDPFml5kDOFay7oyDroqQn4vCJRcljjNA0aSz +QxWiTMVa86jafeoaXLMOWXtREF0YYii1VtGCQNHJh1BFZtaezyAEKZpJWWDXIm0Ld71UF4NIazsu GqDPFmAj1U/RyGs0YUSxdga4Vb0FbVSPchaXbqR40LpZ96DTfeku9RnQvxIVIwt4DEl3yIAUpfWmI 4Ca+Fwlz7Q31GJeuKZ2e9DoUwKZLhy+hSK5pcPJPtymhmyfb1WBOr8Uia9RNWzOz5VlLooAzzSV/i JZInNl/g==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB8-000000085ZD-1yqq; Sat, 10 Jan 2026 04:02:18 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 02/15] allow static-duration kmem_cache in modules Date: Sat, 10 Jan 2026 04:02:04 +0000 Message-ID: <20260110040217.1927971-3-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" We need to make sure that instance in a module will get to slab_kmem_cache_release() before the module data gets freed. That's only a problem on sysfs setups - otherwise it'll definitely be finished before kmem_cache_destroy() returns. Note that modules themselves have sysfs-exposed attributes, so a similar problem already exists there. That's dealt with by having mod_sysfs_teardown() wait for refcount of module->mkobj.kobj reaching zero. Let's make use of that - have static-duration-in-module kmem_cache instances grab a reference to that kobject upon setup and drop it in the end of slab_kmem_cache_release(). Let setup helpers store the kobjetct to be pinned in kmem_cache_args->owner (for preallocated; if somebody manually sets it for non-preallocated case, it'll be ignored). That would be &THIS_MODULE->mkobj.kobj for a module and NULL in built-in. If sysfs is enabled and we are dealing with preallocated instance, let create_cache() grab and stash that reference in kmem_cache->owner and let slab_kmem_cache_release() drop it instead of freeing kmem_cache instance. Signed-off-by: Al Viro --- include/linux/slab-static.h | 12 ++++++++---- include/linux/slab.h | 4 ++++ mm/slab.h | 1 + mm/slab_common.c | 16 ++++++++++++++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/include/linux/slab-static.h b/include/linux/slab-static.h index 47b2220b4988..16d1564b4a4b 100644 --- a/include/linux/slab-static.h +++ b/include/linux/slab-static.h @@ -2,10 +2,7 @@ #ifndef _LINUX_SLAB_STATIC_H #define _LINUX_SLAB_STATIC_H =20 -#ifdef MODULE -#error "can't use that in modules" -#endif - +#include #include =20 /* same size and alignment as struct kmem_cache: */ @@ -13,9 +10,16 @@ struct kmem_cache_opaque { unsigned char opaque[KMEM_CACHE_SIZE]; } __aligned(KMEM_CACHE_ALIGN); =20 +#ifdef MODULE +#define THIS_MODULE_KOBJ &THIS_MODULE->mkobj.kobj +#else +#define THIS_MODULE_KOBJ NULL +#endif + #define __KMEM_CACHE_SETUP(cache, name, size, flags, ...) \ __kmem_cache_create_args((name), (size), \ &(struct kmem_cache_args) { \ + .owner =3D THIS_MODULE_KOBJ, \ .preallocated =3D (cache), \ __VA_ARGS__}, (flags)) =20 diff --git a/include/linux/slab.h b/include/linux/slab.h index f16c784148b4..dc1aeb14a12b 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -60,6 +60,7 @@ enum _slab_flag_bits { #ifdef CONFIG_SLAB_OBJ_EXT _SLAB_NO_OBJ_EXT, #endif + _SLAB_PREALLOCATED, _SLAB_FLAGS_LAST_BIT }; =20 @@ -244,6 +245,8 @@ enum _slab_flag_bits { #define SLAB_NO_OBJ_EXT __SLAB_FLAG_UNUSED #endif =20 +#define SLAB_PREALLOCATED __SLAB_FLAG_BIT(_SLAB_PREALLOCATED) + /* * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests. * @@ -373,6 +376,7 @@ struct kmem_cache_args { */ unsigned int sheaf_capacity; struct kmem_cache *preallocated; + struct kobject *owner; }; =20 struct kmem_cache *__kmem_cache_create_args(const char *name, diff --git a/mm/slab.h b/mm/slab.h index e767aa7e91b0..9ff9a0a3b164 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -249,6 +249,7 @@ struct kmem_cache { struct list_head list; /* List of slab caches */ #ifdef CONFIG_SYSFS struct kobject kobj; /* For sysfs */ + struct kobject *owner; /* keep that pinned while alive */ #endif #ifdef CONFIG_SLAB_FREELIST_HARDENED unsigned long random; diff --git a/mm/slab_common.c b/mm/slab_common.c index 81a413b44afb..a854e6872acd 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -245,6 +245,12 @@ static struct kmem_cache *create_cache(const char *nam= e, kmem_cache_free(kmem_cache, s); return ERR_PTR(err); } +#ifdef CONFIG_SYSFS + if (flags & SLAB_PREALLOCATED) { + s->owner =3D args->owner; + kobject_get(s->owner); + } +#endif s->refcount =3D 1; list_add(&s->list, &slab_caches); return s; @@ -322,7 +328,7 @@ struct kmem_cache *__kmem_cache_create_args(const char = *name, args->usersize =3D args->useroffset =3D 0; =20 if (args->preallocated) - flags |=3D SLAB_NO_MERGE; + flags |=3D SLAB_NO_MERGE | SLAB_PREALLOCATED; =20 if (!args->usersize && !args->sheaf_capacity) s =3D __kmem_cache_alias(name, object_size, args->align, flags, @@ -481,7 +487,13 @@ void slab_kmem_cache_release(struct kmem_cache *s) { __kmem_cache_release(s); kfree_const(s->name); - kmem_cache_free(kmem_cache, s); + if (!(s->flags & SLAB_PREALLOCATED)) { + kmem_cache_free(kmem_cache, s); + return; + } +#ifdef CONFIG_SYSFS + kobject_put(s->owner); +#endif } =20 void kmem_cache_destroy(struct kmem_cache *s) --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BA4523EAA0; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; cv=none; b=r1dDuG30FUT9IyjitDbFmg2yE/CRGcY1C0VSRTBVvEU96jGZB6NwLXEm6/85bMd0dc5uhEs5dnP1xPdPZiDuTA89r5PhkAGl19bxLEj2AwF9QSjkLm4isbrVhgEPoTN7HTCsYVHXuJZQFQbTphZhIH84szQLA0gDJ8JqJ03bWhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; c=relaxed/simple; bh=O4u0xjxsdKbS8YkQu1uKS+MgZTwPfSlRodR8Tchnb9s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OrAnpNqtDBdKyCQx/vD+8vrQNlQgh1DabVgyUyEeTrGMCAYbs601q3EmfwuOdqXhOQk5D8oefyIIpgLhjRWqO1nquYrZarEWrwEUfMyjrK68ODT7ckm197FJBgN1GmEpOYtm1PwxeV+7eWoXMDcRdt4Pxk6lUZdy1xkWwn43oZg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=SxSiiOot; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="SxSiiOot" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=W8Fdz/ANVjFzaC5C2LEX2ZRigSyjCLczPh/9G8T8FCI=; b=SxSiiOot8AA10l4sV3FTpcNVzq ZE0zHgefZleVJgi6kBLkLofKrHPFazzukPus92tmZxNb5439rkcKmReOtnbF+5Q3lbm97QlLUTupS ic7hmMaryQL9yU95IjWGQ2xIYSp+NkXLaZtUR0LjAtizMR+fJQ/p7+4Sn5dTBqhye+EKo3k0824WB 3hWOEbzWMIaNo3kSKqmDqd71OIHpwQGrz4NH97LPBhdRgKC5UiM30ovJtgU+H/4ivS34HkRlBvtKE xfHp0U4XFPRWVzxYbbhOZm6aeA+lmMhcu4x4sNd+RGXv3GAhl9KO6H6WPagEoVPs3BDQxqOwq6MVd RcYsnavg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB8-000000085ZK-2mo4; Sat, 10 Jan 2026 04:02:18 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 03/15] make mnt_cache static-duration Date: Sat, 10 Jan 2026 04:02:05 +0000 Message-ID: <20260110040217.1927971-4-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" Signed-off-by: Al Viro --- fs/namespace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index c58674a20cad..9a9882df463d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -34,6 +34,7 @@ #include #include #include +#include =20 #include "pnode.h" #include "internal.h" @@ -85,7 +86,8 @@ static u64 mnt_id_ctr =3D MNT_UNIQUE_ID_OFFSET; =20 static struct hlist_head *mount_hashtable __ro_after_init; static struct hlist_head *mountpoint_hashtable __ro_after_init; -static struct kmem_cache *mnt_cache __ro_after_init; +static struct kmem_cache_opaque __mnt_cache; +#define mnt_cache to_kmem_cache(&__mnt_cache) static DECLARE_RWSEM(namespace_sem); static HLIST_HEAD(unmounted); /* protected by namespace_sem */ static LIST_HEAD(ex_mountpoints); /* protected by namespace_sem */ @@ -5997,7 +5999,7 @@ void __init mnt_init(void) { int err; =20 - mnt_cache =3D kmem_cache_create("mnt_cache", sizeof(struct mount), + kmem_cache_setup(mnt_cache, "mnt_cache", sizeof(struct mount), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, NULL); =20 mount_hashtable =3D alloc_large_system_hash("Mount-cache", --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BAD523EAB8; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; cv=none; b=PP0XUkxccz4lelAn3/NZVC+5OtcCQlJcazy4z6cZH3IjnvBopPo+pqqTv3LTxwa2veEF6P13MhyeEv48GbckYrBTNIrBFUe6+Kv/BTLQ3XY+/foCdFhk0iWygm+/DP9O9CjTIEnq90Tp+00qOsbQV+zjbppFi0/gzhIJjUkT3L8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; c=relaxed/simple; bh=NJm9T4Xvc9CNzStnNdFdP+G6pT0rhJsSFSegC9dhyfM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DvPPDga4gJXRjB/dmwAXkZazVHO7OrkAFTYY9h9hlmNbVHlggMVesHvZX0qI7dZcDvipWW6gpFenvN8ndL4Aupue+SSCq38pls7V06hJp9MjBg1Sw2gOQdRA8/WXIGNfAOZVe1E1hAoFydPbUT4s/8nGxdl5//JYwIsUQDd6B1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=I22B2mc1; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="I22B2mc1" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=FG22dGTQn9arEKy7RAkcNwMcoAOPOCF9+5yic6HqZ3A=; b=I22B2mc10P0NblsrYHwgUXsHoq P4jKS1TQaWbO2FMIiN5/ZAIZmASvGnV19AMyUa8iI4VzAEqXXPphq+j4n9oQeiAXrGNTK1pvOhDcG p7lVVYdoS6mtT/4voowpR1gV2Iz0TSYnRJVfchF8xtAXwmjE+ztiVDckGM8IVMhWf0mv2EIc6r9mB dqEqFa1gohVw3az/3xdOpWauCJxDD5w5hPdTCBeE+seEu0PG+zbkBB4+Or+Yrdqm431zzV/1BOBTH 5VHuSn11VGESC/F007GJdw5QeeKg/CdiwVvqxvkMeO1uu3wFkGYjjEU+SU4DdbyZwICnrCpWnkbs+ Af9eiCzg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB8-000000085ZO-3DkR; Sat, 10 Jan 2026 04:02:18 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 04/15] turn thread_cache static-duration Date: Sat, 10 Jan 2026 04:02:06 +0000 Message-ID: <20260110040217.1927971-5-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" ... and make is SLAB_PANIC instead of simulating it with BUG_ON() - the boot is not going to get to kernel threads, nevermind userland... Signed-off-by: Al Viro --- kernel/fork.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index b1f3915d5f8e..ddd2558f9431 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -108,6 +108,7 @@ #include #include #include +#include =20 #include #include @@ -422,7 +423,8 @@ static void free_thread_stack(struct task_struct *tsk) =20 #else /* !(THREAD_SIZE >=3D PAGE_SIZE) */ =20 -static struct kmem_cache *thread_stack_cache; +static struct kmem_cache_opaque __thread_stack_cache; +#define thread_stack_cache to_kmem_cache(&__thread_stack_cache) =20 static void thread_stack_free_rcu(struct rcu_head *rh) { @@ -453,10 +455,10 @@ static void free_thread_stack(struct task_struct *tsk) =20 void thread_stack_cache_init(void) { - thread_stack_cache =3D kmem_cache_create_usercopy("thread_stack", - THREAD_SIZE, THREAD_SIZE, 0, 0, + kmem_cache_setup_usercopy(thread_stack_cache, "thread_stack", + THREAD_SIZE, THREAD_SIZE, + SLAB_PANIC, 0, THREAD_SIZE, NULL); - BUG_ON(thread_stack_cache =3D=3D NULL); } =20 #endif /* THREAD_SIZE >=3D PAGE_SIZE */ --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63D3B21CC59; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; cv=none; b=utQ4CjZLa1WyNRTjfEY4X4wfrYP7HMEEDdMx64O/4vaTk+f3hUJEFvdgQ15AoeyPtJJthDZi4qRmpZTTleYc1KTCx+3pV1IhybDYInxzAQ9itYW/R5ePy54xKl4XWGpOdfAFQjAEBlq8e6fb83PAuJUE3wRR/VSxc7kCi3d1SvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; c=relaxed/simple; bh=PHiqAo8sfETc1EUDjMcxffd+xcaTBy5CaEWJ25g7Pv0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SVpxdjbIjdZgf9ePflxKIOrg0Fouu+fFz0Nc0LCWGN2yZwejIv+o6mDuAjwNhC8f+MKSL8yR8JCyKglF6ZIMZ7CxyGcODItduNvLQrEu/18aYg6SF0Sz+3/hTSC8JlFS5Nau2RJDLS0XUQ3qZvbnsSWkXBKoQCMJ8HRx4Jyr5lc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=D8udur4h; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="D8udur4h" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=NYQE0/4xpxjm8d68deKwDm3nKFoSSIOI589+d+MkqSY=; b=D8udur4huObW0MeP2JD6P+gkIU SeFREtW5He2AXWOlxBjfeigmkmEF53QTJmJUzNh7IDQh3PHtwQg4A5AXBUUv6GjfnZlBt+WcJkVg8 YKdX97Mm1CugfdSPg3qM6Wk3l+aoysR1sXWj6d6U3lrFF/vJ3lMvrr+kqxZymEAVmrKEmfk8RRE/g co+NMA+99yF9cshfrQlFS6mnZ/zDYCFVyw/FjAvGbuNza6QvjOA36iDXrLf20r7/kANoHmlsYG3nG Ag1HnDnZndRzj1D/IMAt4lmQid3tIeOG/9qNnpmZP+h3wdLuQySYSVGKMvyHk8yZUvdNE/rDWUVM/ bl+lQdPw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB8-000000085ZV-3ZAL; Sat, 10 Jan 2026 04:02:18 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 05/15] turn signal_cache static-duration Date: Sat, 10 Jan 2026 04:02:07 +0000 Message-ID: <20260110040217.1927971-6-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" Signed-off-by: Al Viro --- kernel/fork.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index ddd2558f9431..23ed80d0d6d0 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -465,7 +465,8 @@ void thread_stack_cache_init(void) #endif /* CONFIG_VMAP_STACK */ =20 /* SLAB cache for signal_struct structures (tsk->signal) */ -static struct kmem_cache *signal_cachep; +static struct kmem_cache_opaque signal_cache; +#define signal_cachep to_kmem_cache(&signal_cache) =20 /* SLAB cache for sighand_struct structures (tsk->sighand) */ struct kmem_cache *sighand_cachep; @@ -3024,7 +3025,7 @@ void __init proc_caches_init(void) sizeof(struct sighand_struct), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_TYPESAFE_BY_RCU| SLAB_ACCOUNT, sighand_ctor); - signal_cachep =3D kmem_cache_create("signal_cache", + kmem_cache_setup(signal_cachep, "signal_cache", sizeof(struct signal_struct), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, NULL); --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BD1A25DAEA; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; cv=none; b=hcgjFevz7ShA5wECXeoutP5Hh36/A6c+Gwdk4h9UBTSzVBpLZvldBuJO6XbRRPczoKwkRLGEObICW0592bBPc1m9B7JEWpHbQZ3fqpUPjzFCT2T6WWmUGfFu2QgOFw5kG7FU2Pk6G5M1gFXjNbQJ5ToA9Fu049N3mHjmjVYv5dA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; c=relaxed/simple; bh=1z70lKRknlSdqIBwT8PCoJx1AjZFc/zasivWeZ/Xl+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sjxAJTtsWwhEQpibRkTCtWT4qCzMANowJaSYkOYjfqcnqBM3L5n1HGLhTgoX6N9II1ZzeCJpeF0W8LU85uY1+igPVbCN0AVibi2SywVC4ES34flxrbo0w5f/EaJfmHzGLHEFnemzsItsuqlAlG3nkM554BijPlj6zoL5reioKIY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=uIeicvqc; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="uIeicvqc" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=C4O95Yl5s9/wxYDLNk10/lpMX9to528i2PgDiiXFfe4=; b=uIeicvqcAdjQez8e5XGTZuq3uz 6pS0Ua/0N3dsxZ2P0OYuhho5eQYhm8j5ts0/CncmYHbn2ywGNTTy5KC3FHlhWVGZn2wyYThkjwQQ0 cE0FyzqFQ2kKz1tX0H6hqCLWfhEb0ON24pcs/3/u/pkkck/NsFbbQl/3HMm01OEdHVC7dlv5T46Qb nR1lUjs3EuFSE1COSZX0yzMLd/O8jVHjHoFsVjoX/6y5oBwuyQWrixRMI2puUEPJv46OI20VFefKP 3zW/jVVbFNBDQlVmIihiNwNBe/IGLJldpZ27pFYSW9GvdZhX3I8upLGg45KAl59J/3Psr+vg0vJ3M Z2X0m9Ww==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB8-000000085Zh-4B9a; Sat, 10 Jan 2026 04:02:19 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 06/15] turn bh_cachep static-duration Date: Sat, 10 Jan 2026 04:02:08 +0000 Message-ID: <20260110040217.1927971-7-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" Signed-off-by: Al Viro --- fs/buffer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 838c0c571022..c8ec1b440880 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -50,6 +50,7 @@ #include #include #include +#include =20 #include "internal.h" =20 @@ -2990,7 +2991,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) =20 /* * Once the number of bh's in the machine exceeds this level, we start @@ -3149,7 +3151,7 @@ void __init buffer_init(void) unsigned long nrpages; int ret; =20 - bh_cachep =3D 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 --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BCB3257821; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017665; cv=none; b=fD9+gJRBVyIz9VgYmHxT9Fz2dZG2eGRwbj7VMMbzhuSxjT8rIhLtKFmH3zPb1M4J0QNqTac9V9drucY5Hqlj+71VfzZkKtV4Obeb2a9juAPpCyYRqA2NghB2jXnv4Q3pJmqO14u/hVLZOMpxFmDVcVTLy8ONE9afpH1qxrlAl+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017665; c=relaxed/simple; bh=nIq7e+rawtNUm9rzBQBhgYlmP2Kc8+05Ksj6TyvdJPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MxBfOxELbjhjpbHo2QJ4XKWdUMsXH3Q12URz2vfbGx4iOD5GXaH6CwWQaZp5gujdOO5z/Q74mjRB8V87Dptd9lG0D3wXrtkcqf/qn5Hda0nwwqdIF0LhUj8uKhsLgO7urnS3Mj3Ghb4D8JqmpQ5vnjEnT2XglzrLzi6CvQeW1YE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=Ph0ALkCK; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="Ph0ALkCK" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=yUfjq/cQTQJkqeTRHOq+fL1zvjNTzJMLDYauRTOdnO4=; b=Ph0ALkCKCYTptUv3Vhh2Nuf1mQ UzC/xvzrJz+R3J3N/IkPvbgNT1VUADc/P60p4M/p/Tfq6b9AXo6PGR3Of00BGb+nbV9qVolGywIbS 4qlo33yOoLuLmpyw2pOMWqa7n9v2oYj6UNpSK8TyJ6IALmXPL1V6S4wGvXIRu3c2PHMAszgXra1Zx RDyZOAVhrtqim+rwGW5UZwP8r462a3XK7qSyBsjUm18blsC9tazRwWxQ0q9Xo3rZJ1umbB3Y4ABzA Ng6Ot50qgrd/rdusNTPlFmP8ns+Dg58Djbg2pW6P5sCBpbxN/X4RCmKJDjInPW6qJ88rFRRYXE8Rh V7y4NNhA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB9-000000085Zl-0In6; Sat, 10 Jan 2026 04:02:19 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 07/15] turn dentry_cache static-duration Date: Sat, 10 Jan 2026 04:02:09 +0000 Message-ID: <20260110040217.1927971-8-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" No need to bother with runtime_const() for it anymore... Signed-off-by: Al Viro --- fs/dcache.c | 8 ++++---- include/asm-generic/vmlinux.lds.h | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index dc2fff4811d1..43d3b4fbedcc 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "internal.h" #include "mount.h" =20 @@ -86,8 +87,8 @@ __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock); =20 EXPORT_SYMBOL(rename_lock); =20 -static struct kmem_cache *__dentry_cache __ro_after_init; -#define dentry_cache runtime_const_ptr(__dentry_cache) +static struct kmem_cache_opaque __dentry_cache; +#define dentry_cache to_kmem_cache(&__dentry_cache) =20 const struct qstr empty_name =3D QSTR_INIT("", 0); EXPORT_SYMBOL(empty_name); @@ -3265,10 +3266,9 @@ static void __init dcache_init(void) * but it is probably not worth it because of the cache nature * of the dcache. */ - __dentry_cache =3D KMEM_CACHE_USERCOPY(dentry, + KMEM_CACHE_SETUP_USERCOPY(dentry_cache, dentry, SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_ACCOUNT, d_shortname.string); - runtime_const_init(ptr, __dentry_cache); =20 /* Hash may have been set up in dcache_init_early */ if (!hashdist) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 8ca130af301f..6997f6301260 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -971,8 +971,7 @@ =20 #define RUNTIME_CONST_VARIABLES \ RUNTIME_CONST(shift, d_hash_shift) \ - RUNTIME_CONST(ptr, dentry_hashtable) \ - RUNTIME_CONST(ptr, __dentry_cache) + RUNTIME_CONST(ptr, dentry_hashtable) =20 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test= .h */ #define KUNIT_TABLE() \ --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B9EB21CC62; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017665; cv=none; b=GD1woIepOAYEMFsk6h55wESKccdJzXUwQY35fL6Wsqxnpk6W5VODhjWrSxf548G8NbHlcHw+eHEZsP9Dbqfmbx1CMqjH7deaO3S0OQr8KvONfxeCKfHFA3rPXMEYCLvX/K79BTLWAwCd2W24g/a1BEpBKO/ILDGCShOvjJLVuQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017665; c=relaxed/simple; bh=/Fxeuk3ccHNpOshNBMvbMMZnp2Y6kg7XC0l52OcvO5w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=biCEeBQbOS0IK6eR352pvxcHc8814hNn6qEU+K6Sc21gNqhJ34FA3LaP9IDnNgif8wsB8HjOukT55Dr+gkFKn4HaymnAlvZ/3znZvQEL4dua8CqmHMHexIj0AWX6TYWIpfo3U7F7gFjUqmrq7vICNubOIpKz7WMYM2uHkoyyd1k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=fZ4Ftxdd; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="fZ4Ftxdd" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=CTpW02raswBuv7j7RpZQuDcsunwQZN7ImQgsqrvpB7w=; b=fZ4FtxddXrGcwLpzr5s/FIqFbB tMxLMY7PP8xJ+h3pkLDGWDJvBfoOPykJWICv5M7n6CLyrscU/1vvKkICS5fMdQLksiYTpks+lAT/j yaf2Nck2v1MEaSrOQ51NyY9XDb4xxQCLA4120symgE1+/jEwVxScShqAC9f52Ssn/Yv35gz0uT5aM M2ial3P8740gYYBH5gtpEAtVq+7kXYjvo+u2th+jqNf5tw4iZBYAspR/JZzscHqYDZD8wYhS4d7T1 TbgyA/Y7GhBQsaDBIzXriLR41PDddd4ajz3E3AFYlJQiaiDAbjN8IqxW+ZvLCB0UcR/sHIicmC8d8 Ustmky9w==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB9-000000085Zv-10L5; Sat, 10 Jan 2026 04:02:19 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 08/15] turn files_cachep static-duration Date: Sat, 10 Jan 2026 04:02:10 +0000 Message-ID: <20260110040217.1927971-9-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" Signed-off-by: Al Viro --- include/linux/fdtable.h | 3 ++- kernel/fork.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index c45306a9f007..f2d553f99c58 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h @@ -113,6 +113,7 @@ int iterate_fd(struct files_struct *, unsigned, extern int close_fd(unsigned int fd); extern struct file *file_close_fd(unsigned int fd); =20 -extern struct kmem_cache *files_cachep; +extern struct kmem_cache_opaque files_cache; +#define files_cachep to_kmem_cache(&files_cache) =20 #endif /* __LINUX_FDTABLE_H */ diff --git a/kernel/fork.c b/kernel/fork.c index 23ed80d0d6d0..8c4d9a81ef42 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -472,7 +472,7 @@ static struct kmem_cache_opaque signal_cache; struct kmem_cache *sighand_cachep; =20 /* SLAB cache for files_struct structures (tsk->files) */ -struct kmem_cache *files_cachep; +struct kmem_cache_opaque files_cache; =20 /* SLAB cache for fs_struct structures (tsk->fs) */ struct kmem_cache *fs_cachep; @@ -3029,7 +3029,7 @@ void __init proc_caches_init(void) sizeof(struct signal_struct), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, NULL); - files_cachep =3D kmem_cache_create("files_cache", + kmem_cache_setup(files_cachep, "files_cache", sizeof(struct files_struct), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, NULL); --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63CE41F099C; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; cv=none; b=VhurK6BhL9t0rNFHilsi9RkEChIwpGFxgiclpHrxt5l2ZttzpkzelGMX2ftRGfc3xpc3yVCv+fQkg4jg9J7uzltBu5p9ugjwk79+zocu2xDiwiKXDzrYCIoEdRZsZvjn7Q4mOVnnSx5a2G59iq8lVCRzFGl078+fyMGVA6AbZgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; c=relaxed/simple; bh=5SW9UpEv0nLK1coY4sVVriH3zUD3HiwNzi3GEA3rco4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jZhK0PjvyAubEPwBm2p3A+AAxKriH0OvXWxSsrKZMiHYhclcpv4Lh0tGwKf6bwClYkLekTiN/kixo75YnfwGLqSrQikTKan8lhq1Z/tLmzLVGnX6bczDkNfZrf8K/Op2z/SfYcIEJdZK2BDiSNm6jfspSiI3lSDEb91X6+JA9Z8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=EWcjovho; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="EWcjovho" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=x+neKtrh0OJd7QapgofbeDN3yfzvNs3usU5t8bvxpKQ=; b=EWcjovhosAsZq5017xsM1Oft92 V/GTFzIUMfeDDs7239l/el5uh/Cs+WzxyiLaXiMlERUrz/B80QmG3x/pUh1w9B2ygcQoS0S2z8cdl Ke8FCpzvFyuooLXf7Rnspy1z4Wb7bRF9XKK7a1DZrVKyOy1x44fWvOk+ME3BhrPhfpevGW7svE4PI /M53EWbRUU644eS1Sy7xFkXyIVHeTYjLnYw1TGSGytr3GpgqTqryoQWrTFljJvN16EgDBmQKh6s8M +E4X4cx0Y2kwNCxutzyCvR8U/pFxAJiPsHWuL3hlt9U7UhhO7/Edd/w+6drozjnuw3lTY9J84Jwbp utsmtJyg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB9-000000085Zy-1Thv; Sat, 10 Jan 2026 04:02:19 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 09/15] make filp and bfilp caches static-duration Date: Sat, 10 Jan 2026 04:02:11 +0000 Message-ID: <20260110040217.1927971-10-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" 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 --- 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 #include #include +#include =20 #include =20 @@ -38,8 +39,10 @@ static struct files_stat_struct files_stat =3D { }; =20 /* 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) =20 static struct percpu_counter nr_files __cacheline_aligned_in_smp; =20 @@ -587,19 +590,20 @@ void fput_close(struct file *file) =20 void __init files_init(void) { - struct kmem_cache_args args =3D { - .use_freeptr_offset =3D true, - .freeptr_offset =3D offsetof(struct file, f_freeptr), - }; - - filp_cachep =3D 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 =3D true, + .freeptr_offset =3D 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 =3D true, + .freeptr_offset =3D offsetof(struct backing_file, + bf_freeptr)); =20 - args.freeptr_offset =3D offsetof(struct backing_file, bf_freeptr); - bfilp_cachep =3D 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); } =20 --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B17D28000F; Sat, 10 Jan 2026 04:01:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017666; cv=none; b=TAQ/iYu2MCJmqS3EA8KRFn01BJuJzWihjmwd4mCOldhVurwCg9LbTg1LrV6zRRxrmSMrc55fbilX7mritFm5JFousjh2Hyy4W054Coht3OpXSkClSttS6ADFfEu3FTCalP03xBWDkZA91OwRQwqS5tTJyYgS9uTPXsSdGkPSsjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017666; c=relaxed/simple; bh=nDDYa9kywW5zHPIcGx5PvS5DCNEit9wcqj0oxAhsAuc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SPdyvKWkW9BpUzGK+aWetgBqmhCQjytFZ4jRb1JEX7iiOSbk8mRWF7ZcI5rTbJ1UBg6Yma9ywggZ8TgfCOHrYFerjbTkWqD5fxHuNTCJrsuZaPgEgcAoq4rDV9FCsK0auWXeroOSV7yWBXKKOPBzBN+KHFACiivU81e2sW9Rgk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=JuDAyOtt; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="JuDAyOtt" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=UhChjjCCXpU6xJa0nBtwbeFUsSVl7UkLK9s6DFk/TOI=; b=JuDAyOttjDWAomFXe/G26EAstH eziFSZvGfJLCNUkI3ZhzWZrXM+ggkH2+DrfPYk9cP5NDfTLY3GYpQL2FEe4dpHA7Fy9ELsmhRXw2s vwduAcN6U0XxZoXkdDG8vpryGRGUmhMk3NQTkwBfB8rPvT53/EyjGrU5HKfbWuRPo2QTAZki5lPXH C7L+6BSbR2jJELUCuMh5MKbXAL4WUltdf2XVZIJzFFDNKJUbx2eY326t2QM6LI3tRucSvmOra7cHP TUE4Ek2tzoqwLNaq+hP+bZHVdc51V73kqKeGlgawrINN2Z4wb74+9mjzrwy+n85obY3QDmx3fYLp4 N9YNaYhw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB9-000000085a8-1yly; Sat, 10 Jan 2026 04:02:19 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 10/15] turn sighand_cache static-duration Date: Sat, 10 Jan 2026 04:02:12 +0000 Message-ID: <20260110040217.1927971-11-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" Signed-off-by: Al Viro --- include/linux/signal.h | 3 ++- kernel/fork.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/signal.h b/include/linux/signal.h index f19816832f05..a0c7fee8b22a 100644 --- a/include/linux/signal.h +++ b/include/linux/signal.h @@ -323,7 +323,8 @@ static inline void disallow_signal(int sig) kernel_sigaction(sig, SIG_IGN); } =20 -extern struct kmem_cache *sighand_cachep; +extern struct kmem_cache_opaque sighand_cache; +#define sighand_cachep to_kmem_cache(&sighand_cache) =20 extern bool unhandled_signal(struct task_struct *tsk, int sig); =20 diff --git a/kernel/fork.c b/kernel/fork.c index 8c4d9a81ef42..d5b7e4d51596 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -469,7 +469,7 @@ static struct kmem_cache_opaque signal_cache; #define signal_cachep to_kmem_cache(&signal_cache) =20 /* SLAB cache for sighand_struct structures (tsk->sighand) */ -struct kmem_cache *sighand_cachep; +struct kmem_cache_opaque sighand_cache; =20 /* SLAB cache for files_struct structures (tsk->files) */ struct kmem_cache_opaque files_cache; @@ -3021,7 +3021,7 @@ void __init mm_cache_init(void) =20 void __init proc_caches_init(void) { - sighand_cachep =3D kmem_cache_create("sighand_cache", + kmem_cache_setup(sighand_cachep, "sighand_cache", sizeof(struct sighand_struct), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_TYPESAFE_BY_RCU| SLAB_ACCOUNT, sighand_ctor); --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4873B280A29; Sat, 10 Jan 2026 04:01:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017666; cv=none; b=avQKeeRSA2hjAbCmx6GUOg6jAnYT4A44CjCfkpcv8I4SjgPkzgibqxqyX2QFMBx7cwU+5hZeIiqbTc88EvU/yviM7M3MLqsQqeNnaJwLH5vlkVWKrfpu/1kNbjn6ZVr5a4p4PxbQkj+X424ddxbQcXV6Sk65YnZDf2OiFR4Imd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017666; c=relaxed/simple; bh=tKP1aoJsMshShmP7ntwoPS9EYaOrFv/7/uBuq6JO8AE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=utyglzB5/UFDStq/iqZzGbKrDabTVNCkyBVqOFz2ZqBy5QafOLI6hN4VTx1damoFgoXWzlrk6uG3dHLWiz6INzkZlWl/tG/w/ZCOtqjMNRfQR1VlO2Ks0Qoy6dRI4CvYuQuoTkgCvPb9LPz706fNOREi0vtX+xIApCzvqh6oN1E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=HIWKl4Pf; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="HIWKl4Pf" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=QpWF0f2SP02fz5D0RQUbdZlrc1oKAOcosJWDE+NgvuA=; b=HIWKl4PfjCkBCTB/oOEIVkqj+Z 5YZATPeRZsWeb5vCSUWK70sBsvb74NkrcRaT0oNRKQE4hJQ5UBuYKTklpm3XIvq1nU3MB8Jz+gMND tC+3u4TJG4qPy/Osswy1K8O5OgMZKWvJa4TeC58hXAly6rJvcF6Vzyd8wcETf7aibPEz9N3gcfixj 2n9si2f/S8XjgWiMe/3QCRqzvSlg7n84lcXieqIx51vwa1zc3yb3/uS/tvoHF0nzLqCDcLB51T9Wr U6/+JW5R9eXd0o6pSLUjxrxzEpnR06tjBb8qthBJ+kLFOPV9RQIe06B2i9RWSmbeyC9JsHc+pZGV0 RwJtMCUw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB9-000000085aC-2Hni; Sat, 10 Jan 2026 04:02:19 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 11/15] turn mm_cachep static-duration Date: Sat, 10 Jan 2026 04:02:13 +0000 Message-ID: <20260110040217.1927971-12-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" Signed-off-by: Al Viro --- kernel/fork.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index d5b7e4d51596..f83ca2f5826f 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -478,7 +478,8 @@ struct kmem_cache_opaque files_cache; struct kmem_cache *fs_cachep; =20 /* SLAB cache for mm_struct structures (tsk->mm) */ -static struct kmem_cache *mm_cachep; +static struct kmem_cache_opaque mm_cache; +#define mm_cachep to_kmem_cache(&mm_cache) =20 static void account_kernel_stack(struct task_struct *tsk, int account) { @@ -3011,7 +3012,7 @@ void __init mm_cache_init(void) */ mm_size =3D sizeof(struct mm_struct) + cpumask_size() + mm_cid_size(); =20 - mm_cachep =3D kmem_cache_create_usercopy("mm_struct", + kmem_cache_setup_usercopy(mm_cachep, "mm_struct", mm_size, ARCH_MIN_MMSTRUCT_ALIGN, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, offsetof(struct mm_struct, saved_auxv), --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63C6A1E5B95; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017665; cv=none; b=epO55RM8p/PGZQc8fwlw5ml1Yz5y+5f1ZwtbhMfYQyTpS9I3yez2fTgKa3a4bagMGnq8OwZbiQ1cpXd48e4FqcelikzGCwGnvHAGMok7QnOJIMtyP5ff4SDxEPWH2jBc9uhrnInC+z47BWMAjmZdtNH58xFjJEl3iwL+HTD7uYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017665; c=relaxed/simple; bh=1EBxgGRCUwO9vaV3rC9PJKIwxsWCiMe5NYVBWFnMIbo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xpi83ge56fLSqk0XmxlcVgNQi765VYgtfcsxIQSC6+N+7lF//yaFzbDGQhBNf1DRVN2FK9nZrp05HpKYlZhtsLeVgt8l9Z+IE0lu007qHm3eglq9ZrF5CItSyu6ovsqLj2Olzu3O1BIKGmTfsqXBy5nkauZhDEpV72O5nyxQguE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=f7gmULfr; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="f7gmULfr" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=l2LUE689TUBjRJhqWoI4FSTJJqCMuaDthYKZkiYtSho=; b=f7gmULfr1QczamnpQvpHORoB4Y cZlsW62CiHl2hZNjtSkrAMYnzAg+3ee4NzKQD0cwRhquSK8F9gIfJ55AnPDVTVn9irnM/Z4tVByIo mNFfBFW/wtmlpUsXUkMbOAMkVaYS+Plk/C56B9IAwv6/tGEwb/U8D4KAW4Rmy84/s1u/9SnOxy/Yg OW32w/DQT73dGjLsm4GxcsQqJZJEflD08QiKHs0aH4w1/hmnRzseN7XuTSLbTjuX3oWpFMtUSiJhS xuXBl4Li9Uu6V4rIOFZ2+yJcSbT9wwml/ntSivby0LL+rtss9AuCL2xRHuodRJy6wp38eRtGM5k4a Qj0W5Xpw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB9-000000085aJ-2fZG; Sat, 10 Jan 2026 04:02:19 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 12/15] turn task_struct_cachep static-duration Date: Sat, 10 Jan 2026 04:02:14 +0000 Message-ID: <20260110040217.1927971-13-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" Signed-off-by: Al Viro --- kernel/fork.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index f83ca2f5826f..8f0dfefd82f0 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -178,7 +178,8 @@ void __weak arch_release_task_struct(struct task_struct= *tsk) { } =20 -static struct kmem_cache *task_struct_cachep; +static struct kmem_cache_opaque task_struct_cache; +#define task_struct_cachep to_kmem_cache(&task_struct_cache) =20 static inline struct task_struct *alloc_task_struct_node(int node) { @@ -860,7 +861,7 @@ void __init fork_init(void) =20 /* create a slab on which task_structs can be allocated */ task_struct_whitelist(&useroffset, &usersize); - task_struct_cachep =3D kmem_cache_create_usercopy("task_struct", + kmem_cache_setup_usercopy(task_struct_cachep, "task_struct", arch_task_struct_size, align, SLAB_PANIC|SLAB_ACCOUNT, useroffset, usersize, NULL); --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BBC524886E; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017663; cv=none; b=RNotleiCT/UgIJSLqABgEUNzupdrJ87ORK+e+XuPPkWMkskrY6EbX3Q2EqIizSG4cgMORcsK4l5V6+ouPJkJioCS7uPheF893Ve+GDGU6eAwS2t+UVciL3IEjQpbIh8YWgR1QXX+d+Tii9v+rNTTQqiQGS+vlpqnKy369+wFAKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017663; c=relaxed/simple; bh=IAZXWAAcaNEVY8U33HnNuOqtDlieHsk/IADRiAay1vg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qoQzFru/ma7h9SohcqK/+R79O94Dpjwdvm5x8/QcJa8+ymOVwBslpaiAcr9w3oF/Ihll4Eg/ZkcJzV/pqEiRb973zJYTJr7ERDeO+B/NoKp7VTVaAnVjSMgEONWd+NU/v4OJW+Cs6fh4D2vO9QAUAPC1PtygpUQtWqQxTpPkV3U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=CtBErUQT; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="CtBErUQT" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=FrXzQAEQRN298A9NQXfa3gY+X4zzBUHVMqaG/R1D29c=; b=CtBErUQTAXH/3cLPj67RwvcyhW ryWQnyPYSRafAowodNlS0AvWy733kBuE9+h7IhJiHjAQ9iU/yzwCBuEe8F9jJckk+7N3MRq5J+Cnc 6IwEOdL3DsgX8jug7rORJZdd8zNsU4/hbYM8jU8H3QZKyBgAiYLrC9TVmW8ZVYszNLtwTgdYBxV0b nVsa1mbnwlBePuWqPJGK4vsLG5AP55DHst4o9End3tQgKWjANgtlkKkqy4fHB9DRjGYfXl5WXsOb+ tJnj58l3hruE99YoqpFDJxbiiAcPgVIcDL78yinTJkivfey8BoG2BHhvIRtgq7o9XpLtFHn3xyIgt J6F7Pp9g==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB9-000000085b2-38Zo; Sat, 10 Jan 2026 04:02:19 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 13/15] turn fs_cachep static-duration Date: Sat, 10 Jan 2026 04:02:15 +0000 Message-ID: <20260110040217.1927971-14-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" Signed-off-by: Al Viro --- include/linux/fs_struct.h | 3 ++- kernel/fork.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h index 0070764b790a..e8c9fac5b7b7 100644 --- a/include/linux/fs_struct.h +++ b/include/linux/fs_struct.h @@ -15,7 +15,8 @@ struct fs_struct { struct path root, pwd; } __randomize_layout; =20 -extern struct kmem_cache *fs_cachep; +extern struct kmem_cache_opaque fs_struct_cache; +#define fs_cachep to_kmem_cache(&fs_struct_cache) =20 extern void exit_fs(struct task_struct *); extern void set_fs_root(struct fs_struct *, const struct path *); diff --git a/kernel/fork.c b/kernel/fork.c index 8f0dfefd82f0..7262abd0d2a4 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -476,7 +476,7 @@ struct kmem_cache_opaque sighand_cache; struct kmem_cache_opaque files_cache; =20 /* SLAB cache for fs_struct structures (tsk->fs) */ -struct kmem_cache *fs_cachep; +struct kmem_cache_opaque fs_struct_cache; =20 /* SLAB cache for mm_struct structures (tsk->mm) */ static struct kmem_cache_opaque mm_cache; @@ -3035,7 +3035,7 @@ void __init proc_caches_init(void) sizeof(struct files_struct), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, NULL); - fs_cachep =3D kmem_cache_create("fs_cache", + kmem_cache_setup(fs_cachep, "fs_cache", sizeof(struct fs_struct), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, NULL); --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75B39263F2D; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017665; cv=none; b=cCWn1J1XwErbyIth6YeXQfrYgLMW83OiBaGGGJHwqUPOj9nN2AbbYWm32Pz5Hb0dLR/tb8m+oOPQj1vJLXMvTdOQTDyEwzSZvgsBOBDmWdijb8sWtHn2l2fbQxhTMnAJ69W9oq+BzvLkQPSY2kRQtPKgckqfsMOmoAS91I6bI+Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017665; c=relaxed/simple; bh=tyt5Oy8tVn91F6R2eWYXAplR9rpkriHJ4FuYBIUUxHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b7ENnJibmwskGlsWC69Q3X+/jkvvJ/fkpEcpVyBX3YVsUlzI67uAgF9jwBnY0U9Jp/i5h+gE78WBE5ke7I67N2mT8ADla/WzjHk77/Zl7u1mnE1TT81gKZAPU9eiV86fHBiqDsJ7Fwe1A1PVkFgscX7Y1hvSPiLyg0l4aiUmt5U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=Oh21CGyR; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="Oh21CGyR" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=tZf11oaVG8ivyzTNge5GHP/XJRZoy6qcj6JDxNkRnvE=; b=Oh21CGyRYIJtmhTTrv3WWAHFZk WyKnrb9+Lq4dJ6PThShkmi1OBPCSSw0dGVcCPQVYJzxTD9REu8ry8b21xI+yIW46s0d3s/AsKI0sE 9DkUQ085pME+pCzCFJRGrbI/IRLOu5GG31NzMy2zbS+0OzxlXKMBNvJ52aq/eOvb7fH2BLtjku4fW hth0ZhhYJ1LWjAd71v02+xhnE4OiGdzZAP8pTQjm9k9jSnvothmroIKhCdLJZ4IARdo4me8gbPKXi Ocw9Tp2vCBQFtSeAdZHH3UeJTO2nwVOfCcniJG6O3gbWtHtN7NF0fMZmW8F14o5Wo2bwqfDf3uan/ VN38yy2Q==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB9-000000085bC-3YyP; Sat, 10 Jan 2026 04:02:19 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 14/15] turn inode_cachep static-duration Date: Sat, 10 Jan 2026 04:02:16 +0000 Message-ID: <20260110040217.1927971-15-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" Signed-off-by: Al Viro --- fs/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 521383223d8a..7c212696ba67 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #define CREATE_TRACE_POINTS #include @@ -76,7 +77,8 @@ EXPORT_SYMBOL(empty_aops); static DEFINE_PER_CPU(unsigned long, nr_inodes); static DEFINE_PER_CPU(unsigned long, nr_unused); =20 -static struct kmem_cache *inode_cachep __ro_after_init; +static struct kmem_cache_opaque inode_cache; +#define inode_cachep to_kmem_cache(&inode_cache) =20 static long get_nr_inodes(void) { @@ -2564,7 +2566,7 @@ void __init inode_init_early(void) void __init inode_init(void) { /* inode slab cache */ - inode_cachep =3D kmem_cache_create("inode_cache", + kmem_cache_setup(inode_cachep, "inode_cache", sizeof(struct inode), 0, (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC| --=20 2.47.3 From nobody Sun Feb 8 09:11:06 2026 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87AA9264612; Sat, 10 Jan 2026 04:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; cv=none; b=T0JEky1itfShpnvX07tJp7xJdkpiGQIApTqVwEFTvlaeQGn1NvyaqwuKc8V6lVeDG/1XWG0myd4FRu706VUSnvZvrQmf/omwAuy47F66fIm8XSX7qBDh1zr29niyDvWKRWdylsXVW7JaAEePto98t0NKeaQlS/r0zIWst0I3HmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768017664; c=relaxed/simple; bh=R3+dA4EAyRwrgvNP9FBPFL2sJ7/lrZCYooL51j5axck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KQozPgniysSSd5e2MBI7oGPzwcoefZUUVG78QC1+Ko4UTRzPQAiorWhzwH8cYmdAJMxcXyhD0KRFJi6jvXzwnWetSyCj9qiy03FqIzvZ8kg/rMnGO2pPKyW9b2zP1KDsVQtuj8Y2ASyYbou0rqD+onQDAferSbb8sMg+V6sMvb8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=UCQfyOdz; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="UCQfyOdz" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=QCWdpDl4N4sktQZ+Ts9iZqQsXsj7d3665CaBWGAPwDA=; b=UCQfyOdzDZjFMBc1nym2fqKTz5 hEis14KZ+aFKVUiJ55w1Cjubl5boGYR+H5HZkYXoBp7+H7nn0gsaIrIRZuuItBCfabpEFtRGS9NCS ImpKNwREPXgDlx4eUtYTNsxxQPZgnDet1kk77OBiNPZkxlZakSP+5VRmE6oX3Ymnd1wrcf5d4wyRP dJprEz1xZYAvWD4W3XCZ7t/2QBEutEByZGtcso5I1zhbQg1+vZnJ3glOMXCTpmZ5Gy7DAzYj58Mb7 WeAv16ORuWZtjaZDHIBVFSaMqScRQJaM3cCP02UwkfY1xAuAmST5nTeyS60QfTLoKZuQR7UwH7iDE d5ileZTw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99 #2 (Red Hat Linux)) id 1veQB9-000000085bK-3zxy; Sat, 10 Jan 2026 04:02:19 +0000 From: Al Viro To: linux-mm@kvack.org Cc: Vlastimil Babka , Harry Yoo , linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Jan Kara , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [RFC PATCH 15/15] turn ufs_inode_cache static-duration Date: Sat, 10 Jan 2026 04:02:17 +0000 Message-ID: <20260110040217.1927971-16-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> References: <20260110040217.1927971-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Al Viro Content-Type: text/plain; charset="utf-8" A modular example I used for testing... Signed-off-by: Al Viro --- fs/ufs/super.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 6e4585169f94..440229a5b6c9 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -90,6 +90,7 @@ #include #include #include +#include =20 #include "ufs_fs.h" #include "ufs.h" @@ -1354,7 +1355,8 @@ static int ufs_statfs(struct dentry *dentry, struct k= statfs *buf) return 0; } =20 -static struct kmem_cache * ufs_inode_cachep; +static struct kmem_cache_opaque ufs_inode_cache; +#define ufs_inode_cachep to_kmem_cache(&ufs_inode_cache) =20 static struct inode *ufs_alloc_inode(struct super_block *sb) { @@ -1384,16 +1386,13 @@ static void init_once(void *foo) =20 static int __init init_inodecache(void) { - ufs_inode_cachep =3D kmem_cache_create_usercopy("ufs_inode_cache", + return kmem_cache_setup_usercopy(ufs_inode_cachep, "ufs_inode_cache", sizeof(struct ufs_inode_info), 0, (SLAB_RECLAIM_ACCOUNT | SLAB_ACCOUNT), offsetof(struct ufs_inode_info, i_u1.i_symlink), sizeof_field(struct ufs_inode_info, i_u1.i_symlink), init_once); - if (ufs_inode_cachep =3D=3D NULL) - return -ENOMEM; - return 0; } =20 static void destroy_inodecache(void) --=20 2.47.3