* Re: [PATCH v2] sparc64: increase kernel thread stack size to 32K [not found] <f3719bb0-e892-49cc-af82-79e2569a8a90@gmail.com> @ 2026-08-31 19:04 ` Tony Rodriguez 0 siblings, 0 replies; 7+ messages in thread From: Tony Rodriguez @ 2026-08-31 19:04 UTC (permalink / raw) To: Stian Halseth, Andreas Larsson, davem, sparclinux Cc: LKML, David Laight, John Paul Adrian Glaubitz, thuth, Linux kernel regressions list, nroach44 Hello Stian, **Revised for clarity. Thanks for following up on this. As I mentioned to Andreas back in May/June 2026, the current combined stack usage is already very close to the 32K limit. If you need an immediate workaround, increasing the stack to 64K is probably the best option to provide enough headroom and avoid the stack overflow panics we are currently seeing. While I haven't observed any panics with a 32K stack on kernel 7.1 so far, operating so close to the boundary is still a significant concern. It is worth noting that sparc64 definitely crashes with a 16K stack. Additionally, the Nvidia/Mellanox mlx5 driver allocates a large stack on sparc64, which pushes usage to the 32K boundary, and other drivers might do the same. Therefore, a 64K stack is far more ideal. Regarding the kernel compilation, when I build the kernel with -fstack-usage to generate .su files on the 7.1 kernel, the static analysis shows stack frames for USB core functions. For example: hub_event: 2457 bytes (static) hub_activate: 1892 bytes (static) usb_control_msg: 1248 bytes (static) However, my runtime stack tracing paints a dramatically different picture: STACKTRACE: hub_event():entry: 31856 bytes used STACKTRACE: hub_activate():entry: 31680 bytes used STACKTRACE: usb_control_msg():entry: 30768 bytes used P.S. I haven't actually tested a 64K stack yet—I am offering this recommendation primarily based on how close the current usage is to the 32K boundary. Regards, Tony On 8/31/26 10:29 AM, Stian Halseth wrote: > From: Tony Rodriguez<unixpro1970@gmail.com> > > Kernel stacks on sparc64 are 16K and this is no longer enough: > several machines (SPARC T5-2 among them) panic early in boot during > USB hub enumeration with "corrupted stack end detected inside > scheduler". sparc has not been converted to THREAD_INFO_IN_TASK, so > thread_info sits at the bottom of the kernel stack and a marginal > overflow corrupts it first; CONFIG_SCHED_STACK_END_CHECK then fires > from __schedule long after the deep path has unwound, which is why > the reported backtraces look shallow. > > Measurements with CONFIG_STACK_TRACER on an UltraSPARC T4-1 show the > problem is frame count, not any single large frame. The high-water > mark of an ordinary successful boot is 12616 of 16384 bytes (77%), > reached in hub_probe() with a printk console flush and then a timer > interrupt (which runs on the task stack, and whose scheduler tick > performs load balancing and IPI delivery) stacked on top. Of the 66 > frames in that path the largest is 408 bytes, and ~85% of them are > 176-224 bytes - at or just above the SPARC V9 ABI minimum frame > (128-byte register window save area plus 48-byte argument save > area). An equivalent call chain on x86-64 costs roughly a third of > the stack, so a 16K stack on sparc64 provides far less effective > call depth than on other 64-bit architectures. > > Double THREAD_SIZE to 32K (four 8K pages). The PAGE_SHIFT > conditionals are dropped: sparc64 only supports 8K base pages, so > the other branches were dead code. Kernel stacks become order-2 > allocations; sparc64 has no VMAP_STACK, but stacks are allocated > once per thread and the trade against boot-time panics is a good > one. > > Link:https://lore.kernel.org/all/20260519075809.8993-1-unixpro1970@gmail.com/ > Signed-off-by: Tony Rodriguez<unixpro1970@gmail.com> > [stian: reduced the diff to the THREAD_* defines, measured stack > usage with CONFIG_STACK_TRACER and rewrote the changelog] > Signed-off-by: Stian Halseth<stian@itx.no> > --- > v2: > - drop the CONFIG_SPARC64 / PAGE_SHIFT conditional chain from v1; > thread_info_64.h is only built on sparc64 and only 8K pages are > supported, so define the three constants unconditionally > - replace the panic backtrace in the changelog with stack tracer > measurements answering David Laight's review comments: > https://lore.kernel.org/all/20260520144104.618c75ca@pumpkin/ > - retitled from "unify thread stack sizing and add explicit 32KB > stack"; the sizing logic for other configurations is unchanged > > Tested on an UltraSPARC T4-1, booted with the stack tracer armed > ("stacktrace") before and after this patch. The boot high-water mark > is 12616 bytes on both kernels - the worst path (hub_probe with a > printk and a timer interrupt on top) is deterministic - i.e. 77% of > the 16K stack before, 38% of the 32K stack after. DEBUG_STACK_USAGE > agrees: the peak boot-time task shows 9208 bytes left of 16K before > vs 25592 bytes left of 32K after (7176 bytes used in both). > > arch/sparc/include/asm/thread_info_64.h | 15 +++------------ > 1 file changed, 3 insertions(+), 12 deletions(-) > > diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h > --- a/arch/sparc/include/asm/thread_info_64.h > +++ b/arch/sparc/include/asm/thread_info_64.h > @@ -99,13 +99,8 @@ > #define FAULT_CODE_BLKCOMMIT 0x10 /* Use blk-commit ASI in copy_page */ > #define FAULT_CODE_BAD_RA 0x20 /* Bad RA for sun4v */ > > -#if PAGE_SHIFT == 13 > -#define THREAD_SIZE (2*PAGE_SIZE) > -#define THREAD_SHIFT (PAGE_SHIFT + 1) > -#else /* PAGE_SHIFT == 13 */ > -#define THREAD_SIZE PAGE_SIZE > -#define THREAD_SHIFT PAGE_SHIFT > -#endif /* PAGE_SHIFT == 13 */ > +#define THREAD_SIZE (4 * PAGE_SIZE) > +#define THREAD_SHIFT (PAGE_SHIFT + 2) > > /* > * macros/functions for gaining access to the thread information structure > @@ -128,11 +123,7 @@ > #endif > > /* thread information allocation */ > -#if PAGE_SHIFT == 13 > -#define THREAD_SIZE_ORDER 1 > -#else /* PAGE_SHIFT == 13 */ > -#define THREAD_SIZE_ORDER 0 > -#endif /* PAGE_SHIFT == 13 */ > +#define THREAD_SIZE_ORDER 2 > > #define __thread_flag_byte_ptr(ti) \ > ((unsigned char *)(&((ti)->flags))) > -- > 2.53.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 0/1] sparc64: unify thread stack sizing and add explicit 32KB stack
@ 2026-05-19 7:57 Tony Rodriguez
2026-08-31 17:29 ` [PATCH v2] sparc64: increase kernel thread stack size to 32K Stian Halseth
0 siblings, 1 reply; 7+ messages in thread
From: Tony Rodriguez @ 2026-05-19 7:57 UTC (permalink / raw)
To: davem, sparclinux
Cc: linux-kernel, andreas, thuth, regressions, glaubitz, unixpro1970
This patch fixes a reproducible stack exhaustion issue on SPARC64
that occurs during USB hub enumeration. This regression may have
started sometime after kernel v6.12. With the default 16KB kernel
stack, the following panic is triggered early in boot:
[ 25.528399] Call Trace:
[ 25.528403] [<0000000000433cd4>] dump_stack+0x8/0x18
[ 25.528419] [<00000000004297ac>] vpanic+0xdc/0x318
[ 25.528429] [<0000000000429a0c>] panic+0x24/0x30
[ 25.528436] [<0000000000be2280>] __schedule+0xa8/0x7bc
[ 25.528445] [<0000000000be2b60>] schedule+0x24/0x4c
[ 25.528452] [<0000000000be6970>] schedule_timeout+0xc8/0xe4
[ 25.528459] [<0000000000be3318>] __wait_for_common+0x78/0xf0
[ 25.528466] [<0000000000be3550>] wait_for_completion_timeout+0x1c/0x2c
[ 25.528473] [<000000001005e2f4>] usb_start_wait_urb+0x68/0x128 [usbcore]
[ 25.528502] [<000000001005e468>] usb_control_msg+0xb4/0xf8 [usbcore]
[ 25.528518] [<0000000010051180>] set_port_feature+0x44/0x54 [usbcore]
[ 25.528530] [<00000000100530f0>] hub_power_on+0xc8/0xe8 [usbcore]
[ 25.528543] [<0000000010054fd8>] hub_activate+0x12c/0x644 [usbcore]
[ 25.528557] [<0000000010059438>] hub_probe+0xdd4/0xeb0 [usbcore]
[ 25.528570] [<0000000010062360>] usb_probe_interface+0x234/0x26c [usbcore]
[ 25.528585] [<0000000000a10a40>] really_probe+0x1ac/0x3b0
This is caused by large SPARC64 trapframes, register-window spills,
and deep call paths in usbcore. A 16KB stack is insufficient for
this workload.
The new logic is:
SPARC64:
THREAD_SIZE = 4 * PAGE_SIZE (32KB)
THREAD_SHIFT = PAGE_SHIFT + 2
THREAD_SIZE_ORDER = 2
Non‑SPARC64 with PAGE_SHIFT == 13:
Retains the existing 16KB stack behavior
Fallback:
Retains the existing 8KB stack behavior
Signed-off-by: Tony Rodriguez <unixpro1970@gmail.com>
Tony Rodriguez (1):
sparc64: unify thread stack sizing and add explicit 32KB stack
arch/sparc/include/asm/thread_info_64.h | 28 ++++++++++++-------------
1 file changed, 14 insertions(+), 14 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2] sparc64: increase kernel thread stack size to 32K 2026-05-19 7:57 [PATCH 0/1] sparc64: unify thread stack sizing and add explicit 32KB stack Tony Rodriguez @ 2026-08-31 17:29 ` Stian Halseth 2026-08-31 18:25 ` Tony Rodriguez 0 siblings, 1 reply; 7+ messages in thread From: Stian Halseth @ 2026-08-31 17:29 UTC (permalink / raw) To: andreas, davem, sparclinux Cc: Tony Rodriguez, linux-kernel, david.laight.linux, glaubitz, thuth, regressions, nroach44, Stian Halseth From: Tony Rodriguez <unixpro1970@gmail.com> Kernel stacks on sparc64 are 16K and this is no longer enough: several machines (SPARC T5-2 among them) panic early in boot during USB hub enumeration with "corrupted stack end detected inside scheduler". sparc has not been converted to THREAD_INFO_IN_TASK, so thread_info sits at the bottom of the kernel stack and a marginal overflow corrupts it first; CONFIG_SCHED_STACK_END_CHECK then fires from __schedule long after the deep path has unwound, which is why the reported backtraces look shallow. Measurements with CONFIG_STACK_TRACER on an UltraSPARC T4-1 show the problem is frame count, not any single large frame. The high-water mark of an ordinary successful boot is 12616 of 16384 bytes (77%), reached in hub_probe() with a printk console flush and then a timer interrupt (which runs on the task stack, and whose scheduler tick performs load balancing and IPI delivery) stacked on top. Of the 66 frames in that path the largest is 408 bytes, and ~85% of them are 176-224 bytes - at or just above the SPARC V9 ABI minimum frame (128-byte register window save area plus 48-byte argument save area). An equivalent call chain on x86-64 costs roughly a third of the stack, so a 16K stack on sparc64 provides far less effective call depth than on other 64-bit architectures. Double THREAD_SIZE to 32K (four 8K pages). The PAGE_SHIFT conditionals are dropped: sparc64 only supports 8K base pages, so the other branches were dead code. Kernel stacks become order-2 allocations; sparc64 has no VMAP_STACK, but stacks are allocated once per thread and the trade against boot-time panics is a good one. Link: https://lore.kernel.org/all/20260519075809.8993-1-unixpro1970@gmail.com/ Signed-off-by: Tony Rodriguez <unixpro1970@gmail.com> [stian: reduced the diff to the THREAD_* defines, measured stack usage with CONFIG_STACK_TRACER and rewrote the changelog] Signed-off-by: Stian Halseth <stian@itx.no> --- v2: - drop the CONFIG_SPARC64 / PAGE_SHIFT conditional chain from v1; thread_info_64.h is only built on sparc64 and only 8K pages are supported, so define the three constants unconditionally - replace the panic backtrace in the changelog with stack tracer measurements answering David Laight's review comments: https://lore.kernel.org/all/20260520144104.618c75ca@pumpkin/ - retitled from "unify thread stack sizing and add explicit 32KB stack"; the sizing logic for other configurations is unchanged Tested on an UltraSPARC T4-1, booted with the stack tracer armed ("stacktrace") before and after this patch. The boot high-water mark is 12616 bytes on both kernels - the worst path (hub_probe with a printk and a timer interrupt on top) is deterministic - i.e. 77% of the 16K stack before, 38% of the 32K stack after. DEBUG_STACK_USAGE agrees: the peak boot-time task shows 9208 bytes left of 16K before vs 25592 bytes left of 32K after (7176 bytes used in both). arch/sparc/include/asm/thread_info_64.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h --- a/arch/sparc/include/asm/thread_info_64.h +++ b/arch/sparc/include/asm/thread_info_64.h @@ -99,13 +99,8 @@ #define FAULT_CODE_BLKCOMMIT 0x10 /* Use blk-commit ASI in copy_page */ #define FAULT_CODE_BAD_RA 0x20 /* Bad RA for sun4v */ -#if PAGE_SHIFT == 13 -#define THREAD_SIZE (2*PAGE_SIZE) -#define THREAD_SHIFT (PAGE_SHIFT + 1) -#else /* PAGE_SHIFT == 13 */ -#define THREAD_SIZE PAGE_SIZE -#define THREAD_SHIFT PAGE_SHIFT -#endif /* PAGE_SHIFT == 13 */ +#define THREAD_SIZE (4 * PAGE_SIZE) +#define THREAD_SHIFT (PAGE_SHIFT + 2) /* * macros/functions for gaining access to the thread information structure @@ -128,11 +123,7 @@ #endif /* thread information allocation */ -#if PAGE_SHIFT == 13 -#define THREAD_SIZE_ORDER 1 -#else /* PAGE_SHIFT == 13 */ -#define THREAD_SIZE_ORDER 0 -#endif /* PAGE_SHIFT == 13 */ +#define THREAD_SIZE_ORDER 2 #define __thread_flag_byte_ptr(ti) \ ((unsigned char *)(&((ti)->flags))) -- 2.53.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] sparc64: increase kernel thread stack size to 32K 2026-08-31 17:29 ` [PATCH v2] sparc64: increase kernel thread stack size to 32K Stian Halseth @ 2026-08-31 18:25 ` Tony Rodriguez 2026-08-31 18:54 ` Stian Halseth 0 siblings, 1 reply; 7+ messages in thread From: Tony Rodriguez @ 2026-08-31 18:25 UTC (permalink / raw) To: Stian Halseth, andreas, davem, sparclinux Cc: linux-kernel, david.laight.linux, glaubitz, thuth, regressions, nroach44 Hi Stian, Thanks for following up regarding this, I am currently busy with other tasks. Back in May/June 2026, I also mentioned the following to Andreas: The combined stack usage is already very close to the 32K limit. If you need an immediate workaround, increasing the stack to 64 K may be the better option. That should provide enough headroom to avoid the stack overflow panics we are seeing. As of kernel 7.1, I haven't noticed any panics using a 32K stack, but once again a stack size that is so close to the 32K boundary is a concern. But once again, sparc64 definitely crashes with a 16K stack. The Nvidia/Mellonox mlx5 driver also allocates a big stack on sparc64, which pushes it to the 32K boundary. There may be other drivers that may do so as well. The 64K stack is more ideal. When I compile the kernel with -fstack-usage to generate .su files, on 7.1 kerner, the static analysis shows small stack frames for all USB core functions. For example: hub_event: 2457 bytes (static) hub_activate: 1892 bytes (static) usb_control_msg: 1248 bytes (static) However, my runtime stack tracing shows a dramatically different picture: STACKTRACE: hub_event():entry: 31856 bytes used STACKTRACE: hub_activate():entry: 31680 bytes used STACKTRACE: usb_control_msg():entry: 30768 bytes used PS - I have not tested a 64K stack yet, only 32K, and this is a heads-up recommendation. Tony On 8/31/26 10:29 AM, Stian Halseth wrote: > From: Tony Rodriguez <unixpro1970@gmail.com> > > Kernel stacks on sparc64 are 16K and this is no longer enough: > several machines (SPARC T5-2 among them) panic early in boot during > USB hub enumeration with "corrupted stack end detected inside > scheduler". sparc has not been converted to THREAD_INFO_IN_TASK, so > thread_info sits at the bottom of the kernel stack and a marginal > overflow corrupts it first; CONFIG_SCHED_STACK_END_CHECK then fires > from __schedule long after the deep path has unwound, which is why > the reported backtraces look shallow. > > Measurements with CONFIG_STACK_TRACER on an UltraSPARC T4-1 show the > problem is frame count, not any single large frame. The high-water > mark of an ordinary successful boot is 12616 of 16384 bytes (77%), > reached in hub_probe() with a printk console flush and then a timer > interrupt (which runs on the task stack, and whose scheduler tick > performs load balancing and IPI delivery) stacked on top. Of the 66 > frames in that path the largest is 408 bytes, and ~85% of them are > 176-224 bytes - at or just above the SPARC V9 ABI minimum frame > (128-byte register window save area plus 48-byte argument save > area). An equivalent call chain on x86-64 costs roughly a third of > the stack, so a 16K stack on sparc64 provides far less effective > call depth than on other 64-bit architectures. > > Double THREAD_SIZE to 32K (four 8K pages). The PAGE_SHIFT > conditionals are dropped: sparc64 only supports 8K base pages, so > the other branches were dead code. Kernel stacks become order-2 > allocations; sparc64 has no VMAP_STACK, but stacks are allocated > once per thread and the trade against boot-time panics is a good > one. > > Link: https://lore.kernel.org/all/20260519075809.8993-1-unixpro1970@gmail.com/ > Signed-off-by: Tony Rodriguez <unixpro1970@gmail.com> > [stian: reduced the diff to the THREAD_* defines, measured stack > usage with CONFIG_STACK_TRACER and rewrote the changelog] > Signed-off-by: Stian Halseth <stian@itx.no> > --- > v2: > - drop the CONFIG_SPARC64 / PAGE_SHIFT conditional chain from v1; > thread_info_64.h is only built on sparc64 and only 8K pages are > supported, so define the three constants unconditionally > - replace the panic backtrace in the changelog with stack tracer > measurements answering David Laight's review comments: > https://lore.kernel.org/all/20260520144104.618c75ca@pumpkin/ > - retitled from "unify thread stack sizing and add explicit 32KB > stack"; the sizing logic for other configurations is unchanged > > Tested on an UltraSPARC T4-1, booted with the stack tracer armed > ("stacktrace") before and after this patch. The boot high-water mark > is 12616 bytes on both kernels - the worst path (hub_probe with a > printk and a timer interrupt on top) is deterministic - i.e. 77% of > the 16K stack before, 38% of the 32K stack after. DEBUG_STACK_USAGE > agrees: the peak boot-time task shows 9208 bytes left of 16K before > vs 25592 bytes left of 32K after (7176 bytes used in both). > > arch/sparc/include/asm/thread_info_64.h | 15 +++------------ > 1 file changed, 3 insertions(+), 12 deletions(-) > > diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h > --- a/arch/sparc/include/asm/thread_info_64.h > +++ b/arch/sparc/include/asm/thread_info_64.h > @@ -99,13 +99,8 @@ > #define FAULT_CODE_BLKCOMMIT 0x10 /* Use blk-commit ASI in copy_page */ > #define FAULT_CODE_BAD_RA 0x20 /* Bad RA for sun4v */ > > -#if PAGE_SHIFT == 13 > -#define THREAD_SIZE (2*PAGE_SIZE) > -#define THREAD_SHIFT (PAGE_SHIFT + 1) > -#else /* PAGE_SHIFT == 13 */ > -#define THREAD_SIZE PAGE_SIZE > -#define THREAD_SHIFT PAGE_SHIFT > -#endif /* PAGE_SHIFT == 13 */ > +#define THREAD_SIZE (4 * PAGE_SIZE) > +#define THREAD_SHIFT (PAGE_SHIFT + 2) > > /* > * macros/functions for gaining access to the thread information structure > @@ -128,11 +123,7 @@ > #endif > > /* thread information allocation */ > -#if PAGE_SHIFT == 13 > -#define THREAD_SIZE_ORDER 1 > -#else /* PAGE_SHIFT == 13 */ > -#define THREAD_SIZE_ORDER 0 > -#endif /* PAGE_SHIFT == 13 */ > +#define THREAD_SIZE_ORDER 2 > > #define __thread_flag_byte_ptr(ti) \ > ((unsigned char *)(&((ti)->flags))) > -- > 2.53.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] sparc64: increase kernel thread stack size to 32K 2026-08-31 18:25 ` Tony Rodriguez @ 2026-08-31 18:54 ` Stian Halseth 2026-08-31 20:18 ` Tony Rodriguez 0 siblings, 1 reply; 7+ messages in thread From: Stian Halseth @ 2026-08-31 18:54 UTC (permalink / raw) To: Tony Rodriguez, andreas, davem, sparclinux Cc: linux-kernel, david.laight.linux, glaubitz, thuth, regressions, nroach44 Hi Tony, You're welcome. I saw it was stuck, and wanted to push it along. Looks to me like a proper fix that should be included. PS: Don't want to take any credit, this is 100% your fix. If you rather want to handle it yourself, let me know :) -- Best regards Stian Halseth On Mon, 2026-08-31 at 11:25 -0700, Tony Rodriguez wrote: > > When I compile the kernel with -fstack-usage to generate .su files, > on > 7.1 kerner, the static analysis shows small stack frames for all USB > core functions. > For example: > > hub_event: 2457 bytes (static) > hub_activate: 1892 bytes (static) > usb_control_msg: 1248 bytes (static) > > However, my runtime stack tracing shows a dramatically different > picture: > > STACKTRACE: hub_event():entry: 31856 bytes used > STACKTRACE: hub_activate():entry: 31680 bytes used > STACKTRACE: usb_control_msg():entry: 30768 bytes used > I'm not quite sure what I'm looking at. Stack usage must _increase_ with call depth, but looks like it's decreasing? That shouldn't be possible, but maybe I'm misreading something? It kinda looks like you're showing sp - stack_base (space left). CONFIG_STACK_TRACER on the T4-1 measures 12.6K worst-case against 32K. Could you re-measure with stacktrace on the kernel command line? Happy to share the exact config/procedure. > > PS - I have not tested a 64K stack yet, only 32K, and this is a > heads-up > recommendation. > > > Tony > > On 8/31/26 10:29 AM, Stian Halseth wrote: > > From: Tony Rodriguez <unixpro1970@gmail.com> > > > > Kernel stacks on sparc64 are 16K and this is no longer enough: > > several machines (SPARC T5-2 among them) panic early in boot during > > USB hub enumeration with "corrupted stack end detected inside > > scheduler". sparc has not been converted to THREAD_INFO_IN_TASK, so > > thread_info sits at the bottom of the kernel stack and a marginal > > overflow corrupts it first; CONFIG_SCHED_STACK_END_CHECK then fires > > from __schedule long after the deep path has unwound, which is why > > the reported backtraces look shallow. > > > > Measurements with CONFIG_STACK_TRACER on an UltraSPARC T4-1 show > > the > > problem is frame count, not any single large frame. The high-water > > mark of an ordinary successful boot is 12616 of 16384 bytes (77%), > > reached in hub_probe() with a printk console flush and then a timer > > interrupt (which runs on the task stack, and whose scheduler tick > > performs load balancing and IPI delivery) stacked on top. Of the 66 > > frames in that path the largest is 408 bytes, and ~85% of them are > > 176-224 bytes - at or just above the SPARC V9 ABI minimum frame > > (128-byte register window save area plus 48-byte argument save > > area). An equivalent call chain on x86-64 costs roughly a third of > > the stack, so a 16K stack on sparc64 provides far less effective > > call depth than on other 64-bit architectures. > > > > Double THREAD_SIZE to 32K (four 8K pages). The PAGE_SHIFT > > conditionals are dropped: sparc64 only supports 8K base pages, so > > the other branches were dead code. Kernel stacks become order-2 > > allocations; sparc64 has no VMAP_STACK, but stacks are allocated > > once per thread and the trade against boot-time panics is a good > > one. > > > > Link: https://lore.kernel.org/all/20260519075809.8993-1- > > unixpro1970@gmail.com/ > > Signed-off-by: Tony Rodriguez <unixpro1970@gmail.com> > > [stian: reduced the diff to the THREAD_* defines, measured stack > > usage with CONFIG_STACK_TRACER and rewrote the changelog] > > Signed-off-by: Stian Halseth <stian@itx.no> > > --- > > v2: > > - drop the CONFIG_SPARC64 / PAGE_SHIFT conditional chain from v1; > > thread_info_64.h is only built on sparc64 and only 8K pages are > > supported, so define the three constants unconditionally > > - replace the panic backtrace in the changelog with stack tracer > > measurements answering David Laight's review comments: > > https://lore.kernel.org/all/20260520144104.618c75ca@pumpkin/ > > - retitled from "unify thread stack sizing and add explicit 32KB > > stack"; the sizing logic for other configurations is unchanged > > > > Tested on an UltraSPARC T4-1, booted with the stack tracer armed > > ("stacktrace") before and after this patch. The boot high-water > > mark > > is 12616 bytes on both kernels - the worst path (hub_probe with a > > printk and a timer interrupt on top) is deterministic - i.e. 77% of > > the 16K stack before, 38% of the 32K stack after. DEBUG_STACK_USAGE > > agrees: the peak boot-time task shows 9208 bytes left of 16K before > > vs 25592 bytes left of 32K after (7176 bytes used in both). > > > > arch/sparc/include/asm/thread_info_64.h | 15 +++------------ > > 1 file changed, 3 insertions(+), 12 deletions(-) > > > > diff --git a/arch/sparc/include/asm/thread_info_64.h > > b/arch/sparc/include/asm/thread_info_64.h > > --- a/arch/sparc/include/asm/thread_info_64.h > > +++ b/arch/sparc/include/asm/thread_info_64.h > > @@ -99,13 +99,8 @@ > > #define FAULT_CODE_BLKCOMMIT 0x10 /* Use blk-commit ASI in > > copy_page */ > > #define FAULT_CODE_BAD_RA 0x20 /* Bad RA for sun4v */ > > > > -#if PAGE_SHIFT == 13 > > -#define THREAD_SIZE (2*PAGE_SIZE) > > -#define THREAD_SHIFT (PAGE_SHIFT + 1) > > -#else /* PAGE_SHIFT == 13 */ > > -#define THREAD_SIZE PAGE_SIZE > > -#define THREAD_SHIFT PAGE_SHIFT > > -#endif /* PAGE_SHIFT == 13 */ > > +#define THREAD_SIZE (4 * PAGE_SIZE) > > +#define THREAD_SHIFT (PAGE_SHIFT + 2) > > > > /* > > * macros/functions for gaining access to the thread information > > structure > > @@ -128,11 +123,7 @@ > > #endif > > > > /* thread information allocation */ > > -#if PAGE_SHIFT == 13 > > -#define THREAD_SIZE_ORDER 1 > > -#else /* PAGE_SHIFT == 13 */ > > -#define THREAD_SIZE_ORDER 0 > > -#endif /* PAGE_SHIFT == 13 */ > > +#define THREAD_SIZE_ORDER 2 > > > > #define __thread_flag_byte_ptr(ti) \ > > ((unsigned char *)(&((ti)->flags))) > > -- > > 2.53.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] sparc64: increase kernel thread stack size to 32K 2026-08-31 18:54 ` Stian Halseth @ 2026-08-31 20:18 ` Tony Rodriguez 2026-08-31 21:05 ` Stian Halseth 0 siblings, 1 reply; 7+ messages in thread From: Tony Rodriguez @ 2026-08-31 20:18 UTC (permalink / raw) To: Stian Halseth, andreas, davem, sparclinux Cc: linux-kernel, david.laight.linux, glaubitz, thuth, regressions, nroach44 Hi Stian, No problem at all, and I appreciate your honesty and for reaching out. It’s best to get this addressed as soon as possible if you have the time to work on it—I’m currently swamped with other tasks. Overall, I don’t mind if you take over these patches, and truly appreciate your assistance to the sparc64 community. Just please continue to give me a mention in any patches related to this work, since I spent a considerable amount of time debugging, researching, and validating the fixes. When I last tested on 7.0 and 7.1, both of my patches worked: A) sparc64: increase kernel thread stack size to 32K B) sparc64: Fix comparator problem with timer interrupts I was able to debug and validate these issues on S7‑2 and T7‑1 hardware. I’m not sure if others have reported similar problems on T4 or T5 systems. Regarding: STACKTRACE: hub_event():entry: 31856 bytes used STACKTRACE: hub_activate():entry: 31680 bytes used STACKTRACE: usb_control_msg():entry: 30768 bytes used This was a set of debugging code inserted into function hot spots and scripts to measure stack usage at runtime. It helped me identify trouble spots and gave me a better idea of where stack consumption was highest. At the time, I wondered whether it might be possible to reduce the stack size of usbcore and the Nvidia mlx5 functions on sparc64, but that would be a significantly more time‑consuming task. I may have updated my stack monitoring script since then as well. It’s also been a few months, so I’d need to refresh my memory on the details. If you have a quicker or better methodology for reviewing stack usage—or any general suggestions—I’m definitely open to seeing them, along with your config and exact procedure. And if you need help validating against S7‑2 and T7‑1 hardware, I can try to allocate some time to assist. Best regards, Tony On 8/31/26 11:54 AM, Stian Halseth wrote: > Hi Tony, > > You're welcome. > > I saw it was stuck, and wanted to push it along. Looks to me like a > proper fix that should be included. > > PS: Don't want to take any credit, this is 100% your fix. If you rather > want to handle it yourself, let me know :) > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] sparc64: increase kernel thread stack size to 32K 2026-08-31 20:18 ` Tony Rodriguez @ 2026-08-31 21:05 ` Stian Halseth 2026-09-02 3:30 ` Tony Rodriguez 0 siblings, 1 reply; 7+ messages in thread From: Stian Halseth @ 2026-08-31 21:05 UTC (permalink / raw) To: Tony Rodriguez, andreas, davem, sparclinux Cc: linux-kernel, david.laight.linux, glaubitz, thuth, regressions, nroach44 Hi Tony, On Mon, 2026-08-31 at 13:18 -0700, Tony Rodriguez wrote: > Hi Stian, > > Just please continue to give me a > mention in any patches related to this work, since I spent a > considerable amount of time debugging, researching, and validating > the fixes. Sure. For now, no real changes have been made to your patches, so as far as I'm concerned, this is entirely your work. Will try help with the last mile, alongside some other patches I've submitted. And yes, the debugging, researching and validation is the hard part. Writing a fix is often _relatively_ easy, when you have all the facts. > > When I last tested on 7.0 and 7.1, both of my patches worked: > > A) sparc64: increase kernel thread stack size to 32K > > B) sparc64: Fix comparator problem with timer interrupts > > I was able to debug and validate these issues on S7‑2 and T7‑1 > hardware. Yes, and that's a very important data point. My analyzis is based on the change itself, _and_ your validation/testing. > I’m not sure if others have reported similar problems on T4 or T5 > systems. Not that I'm aware of, and I haven't seen it on my T4-1. > > If you have a quicker or better methodology for reviewing stack > usage—or > any general suggestions—I’m definitely open to seeing them, along > with > your config and exact procedure. And if you need help validating > against > S7‑2 and T7‑1 hardware, I can try to allocate some time to assist. I think that would be very helpful. Let's try to settle the 32K-vs-64K question with more data. The kernel has stack measurement built in. The in-kernel method: CONFIG_STACK_TRACER=y CONFIG_DEBUG_STACK_USAGE=y CONFIG_SCHED_STACK_END_CHECK=y Boot with "stacktrace" on the kernel command line (arms the tracer before built-in drivers probe). Then: cat /sys/kernel/tracing/stack_max_size # worst case seen, bytes cat /sys/kernel/tracing/stack_trace # that path, frame by frame Reset with "echo 0 > stack_max_size" before a workload to isolate it. For the 32K-vs-64K question, the most valuable data you could gather is a stack_trace snapshot on the S7-2/T7-1 under your real workload with mlx5 active, on a 32K kernel. On our T4-1 the worst case is 12616 bytes, but doesn't have mlx5. If your machines stay well under 32K, we have comfortable margin. But if something approaches the limit, the trace will name the exact frames, and we can judge whether the right answer is 64K or a targeted fix in that driver. > Thanks! -- Best regards Stian Halseth ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] sparc64: increase kernel thread stack size to 32K 2026-08-31 21:05 ` Stian Halseth @ 2026-09-02 3:30 ` Tony Rodriguez 0 siblings, 0 replies; 7+ messages in thread From: Tony Rodriguez @ 2026-09-02 3:30 UTC (permalink / raw) To: Stian Halseth, andreas, davem, sparclinux Cc: linux-kernel, david.laight.linux, glaubitz, thuth, regressions, nroach44 Thanks again for the details, but I already had those CONFIG and stacktrace options defined based on previous debugging sessions. 32K should be fine based on the output (see the link below), and I have not noticed any crashes with a 32K stack). These results are against kernel v7.1.0-rc3 using my original patches on the S7-2. https://github.com/unixpro1970/Sparc64-Kernel-Debugging-Dumps/blob/main/kernel-v7.1.0-rc3-depth-stack-trace-sparc64-s7-2.txt Should I try your revised 32k stack and timer patches on the S7-2 and T7-1? If so, which kernel version did you validate against 7.2 or 7.3? Regards, Tony On 8/31/26 2:05 PM, Stian Halseth wrote: > Hi Tony, > > On Mon, 2026-08-31 at 13:18 -0700, Tony Rodriguez wrote: >> Hi Stian, >> >> Just please continue to give me a >> mention in any patches related to this work, since I spent a >> considerable amount of time debugging, researching, and validating >> the fixes. > Sure. For now, no real changes have been made to your patches, so as > far as I'm concerned, this is entirely your work. > Will try help with the last mile, alongside some other patches I've > submitted. > And yes, the debugging, researching and validation is the hard part. > Writing a fix is often _relatively_ easy, when you have all the facts. >> When I last tested on 7.0 and 7.1, both of my patches worked: >> >> A) sparc64: increase kernel thread stack size to 32K >> >> B) sparc64: Fix comparator problem with timer interrupts >> >> I was able to debug and validate these issues on S7‑2 and T7‑1 >> hardware. > Yes, and that's a very important data point. My analyzis is based on > the change itself, _and_ your validation/testing. >> I’m not sure if others have reported similar problems on T4 or T5 >> systems. > Not that I'm aware of, and I haven't seen it on my T4-1. >> If you have a quicker or better methodology for reviewing stack >> usage—or >> any general suggestions—I’m definitely open to seeing them, along >> with >> your config and exact procedure. And if you need help validating >> against >> S7‑2 and T7‑1 hardware, I can try to allocate some time to assist. > I think that would be very helpful. Let's try to settle the 32K-vs-64K > question with more data. > > The kernel has stack measurement built in. > > The in-kernel method: > CONFIG_STACK_TRACER=y > CONFIG_DEBUG_STACK_USAGE=y > CONFIG_SCHED_STACK_END_CHECK=y > > Boot with "stacktrace" on the kernel command line (arms the tracer > before built-in drivers probe). Then: > > cat /sys/kernel/tracing/stack_max_size # worst case seen, bytes > cat /sys/kernel/tracing/stack_trace # that path, frame by frame > > Reset with "echo 0 > stack_max_size" before a workload to isolate it. > > For the 32K-vs-64K question, the most valuable data you could gather > is a stack_trace snapshot on the S7-2/T7-1 under your real workload > with mlx5 active, on a 32K kernel. > > On our T4-1 the worst case is 12616 bytes, but doesn't have mlx5. If > your machines stay well under 32K, we have comfortable margin. But if > something approaches the limit, the trace will name the exact frames, > and we can judge whether the right answer is 64K or a targeted fix in > that driver. > Thanks! > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-09-02 3:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <f3719bb0-e892-49cc-af82-79e2569a8a90@gmail.com>
2026-08-31 19:04 ` [PATCH v2] sparc64: increase kernel thread stack size to 32K Tony Rodriguez
2026-05-19 7:57 [PATCH 0/1] sparc64: unify thread stack sizing and add explicit 32KB stack Tony Rodriguez
2026-08-31 17:29 ` [PATCH v2] sparc64: increase kernel thread stack size to 32K Stian Halseth
2026-08-31 18:25 ` Tony Rodriguez
2026-08-31 18:54 ` Stian Halseth
2026-08-31 20:18 ` Tony Rodriguez
2026-08-31 21:05 ` Stian Halseth
2026-09-02 3:30 ` Tony Rodriguez
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox