[RFC][PATCH 03/24] kernel/sched: Move thread stack to its own structure
From: Dave Hansen
Date: Wed Oct 21 2026 - 15:52:13 EST
Right now, the thread stack is directly declared in 'thread_union'.
There is shortly going to be more than one stack. Give all the stacks
their own structure instead of declaring *a* stack directly.
---
b/include/linux/sched.h | 6 +++++-
b/mm/kasan/report.c | 6 +++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff -puN include/linux/sched.h~alloc_thread_stack_node-3 include/linux/sched.h
--- a/include/linux/sched.h~alloc_thread_stack_node-3 2026-10-21 12:36:33.575872729 -0700
+++ b/include/linux/sched.h 2026-10-21 12:36:33.613872802 -0700
@@ -1986,12 +1986,16 @@ extern void ia64_set_curr_task(int cpu,
void yield(void);
+struct thread_stacks {
+ unsigned long stack[THREAD_SIZE/sizeof(long)];
+};
+
union thread_union {
struct task_struct task;
#ifndef CONFIG_THREAD_INFO_IN_TASK
struct thread_info thread_info;
#endif
- unsigned long stack[THREAD_SIZE/sizeof(long)];
+ struct thread_stacks stacks;
};
#ifndef CONFIG_THREAD_INFO_IN_TASK
diff -puN mm/kasan/report.c~alloc_thread_stack_node-3 mm/kasan/report.c
--- a/mm/kasan/report.c~alloc_thread_stack_node-3 2026-10-21 12:36:33.610872797 -0700
+++ b/mm/kasan/report.c 2026-10-21 12:36:33.613872802 -0700
@@ -365,9 +365,9 @@ static inline bool kernel_or_module_addr
static inline bool init_task_stack_addr(const void *addr)
{
- return addr >= (void *)&init_thread_union.stack &&
- (addr <= (void *)&init_thread_union.stack +
- sizeof(init_thread_union.stack));
+ return addr >= (void *)&init_thread_union.stacks.stack &&
+ (addr <= (void *)&init_thread_union.stacks.stack +
+ sizeof(init_thread_union.stacks.stack));
}
static void print_address_description(void *addr, u8 tag,
_