[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260110040217.1927971-5-viro@zeniv.linux.org.uk>
Date: Sat, 10 Jan 2026 04:02:06 +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 04/15] turn thread_cache static-duration
... 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 <viro@...iv.linux.org.uk>
---
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 <linux/unwind_deferred.h>
#include <linux/pgalloc.h>
#include <linux/uaccess.h>
+#include <linux/slab-static.h>
#include <asm/mmu_context.h>
#include <asm/cacheflush.h>
@@ -422,7 +423,8 @@ static void free_thread_stack(struct task_struct *tsk)
#else /* !(THREAD_SIZE >= PAGE_SIZE) */
-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)
static void thread_stack_free_rcu(struct rcu_head *rh)
{
@@ -453,10 +455,10 @@ static void free_thread_stack(struct task_struct *tsk)
void thread_stack_cache_init(void)
{
- thread_stack_cache = 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 == NULL);
}
#endif /* THREAD_SIZE >= PAGE_SIZE */
--
2.47.3
Powered by blists - more mailing lists