* [PATCH 0/1] sparc64: unify thread stack sizing and add explicit 32KB stack
@ 2026-05-19 7:57 Tony Rodriguez
2026-05-19 7:57 ` [PATCH 1/1] " Tony Rodriguez
2026-05-19 10:02 ` [PATCH 0/1] " David Laight
0 siblings, 2 replies; 8+ 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] 8+ messages in thread
* [PATCH 1/1] sparc64: unify thread stack sizing and add explicit 32KB stack
2026-05-19 7:57 [PATCH 0/1] sparc64: unify thread stack sizing and add explicit 32KB stack Tony Rodriguez
@ 2026-05-19 7:57 ` Tony Rodriguez
2026-05-19 8:56 ` Nathaniel Roach
2026-06-16 14:18 ` Andreas Larsson
2026-05-19 10:02 ` [PATCH 0/1] " David Laight
1 sibling, 2 replies; 8+ 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 restructures the thread‑stack sizing logic into a single
if / elif / else chain and introduces an explicit 32KB kernel stack
for SPARC64. The previous implementation relied on nested conditionals
and PAGE_SHIFT‑dependent behavior, which produced 8KB or 16KB stacks
depending on configuration. SPARC64 requires a larger,
architecture‑specific stack due to its trapframe size, register‑window
behavior, and deeper call paths.
A reproducible failure case occurs when usbcore is enabled: USB hub
enumeration (usb_new_device(), hub_port_connect(), PM/QoS helpers)
allocates large on‑stack structures and recurses through several
layers of device‑model code. Combined with SPARC64’s trapframe and
register‑window overhead, this reliably exhausts a 16KB stack and
results in early‑boot panics. A 32KB stack eliminates these failures.
The new logic is:
SPARC64:
THREAD_SIZE = 4 * PAGE_SIZE (32KB)
THREAD_SHIFT = PAGE_SHIFT + 2 (log₂(32KB))
THREAD_SIZE_ORDER = 2 (4 contiguous pages)
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>
---
arch/sparc/include/asm/thread_info_64.h | 28 ++++++++++++-------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
index c8a73dff27f8..6b12a2b66385 100644
--- a/arch/sparc/include/asm/thread_info_64.h
+++ b/arch/sparc/include/asm/thread_info_64.h
@@ -99,13 +99,20 @@ struct thread_info {
#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 */
+/* thread information allocation */
+#ifdef CONFIG_SPARC64
+ #define THREAD_SIZE (4 * PAGE_SIZE)
+ #define THREAD_SHIFT (PAGE_SHIFT + 2)
+ #define THREAD_SIZE_ORDER 2
+#elif PAGE_SHIFT == 13
+ #define THREAD_SIZE (2 * PAGE_SIZE)
+ #define THREAD_SHIFT (PAGE_SHIFT + 1)
+ #define THREAD_SIZE_ORDER 1
+#else
+ #define THREAD_SIZE PAGE_SIZE
+ #define THREAD_SHIFT PAGE_SHIFT
+ #define THREAD_SIZE_ORDER 0
+#endif
/*
* macros/functions for gaining access to the thread information structure
@@ -127,13 +134,6 @@ register struct thread_info *current_thread_info_reg asm("g6");
extern struct thread_info *current_thread_info(void);
#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_flag_byte_ptr(ti) \
((unsigned char *)(&((ti)->flags)))
#define __cur_thread_flag_byte_ptr __thread_flag_byte_ptr(current_thread_info())
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] sparc64: unify thread stack sizing and add explicit 32KB stack
2026-05-19 7:57 ` [PATCH 1/1] " Tony Rodriguez
@ 2026-05-19 8:56 ` Nathaniel Roach
2026-06-16 14:18 ` Andreas Larsson
1 sibling, 0 replies; 8+ messages in thread
From: Nathaniel Roach @ 2026-05-19 8:56 UTC (permalink / raw)
To: Tony Rodriguez, davem, sparclinux
Cc: linux-kernel, andreas, thuth, regressions, glaubitz
On 19/5/26 15:57, Tony Rodriguez wrote:
> This patch restructures the thread‑stack sizing logic into a single
> if / elif / else chain and introduces an explicit 32KB kernel stack
> for SPARC64. The previous implementation relied on nested conditionals
> and PAGE_SHIFT‑dependent behavior, which produced 8KB or 16KB stacks
> depending on configuration. SPARC64 requires a larger,
> architecture‑specific stack due to its trapframe size, register‑window
> behavior, and deeper call paths.
>
> A reproducible failure case occurs when usbcore is enabled: USB hub
> enumeration (usb_new_device(), hub_port_connect(), PM/QoS helpers)
> allocates large on‑stack structures and recurses through several
> layers of device‑model code. Combined with SPARC64’s trapframe and
> register‑window overhead, this reliably exhausts a 16KB stack and
> results in early‑boot panics. A 32KB stack eliminates these failures.
>
> The new logic is:
> SPARC64:
> THREAD_SIZE = 4 * PAGE_SIZE (32KB)
> THREAD_SHIFT = PAGE_SHIFT + 2 (log₂(32KB))
> THREAD_SIZE_ORDER = 2 (4 contiguous pages)
> 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>
Tested-by: Nathaniel Roach <nroach44@nroach44.id.au> # SPARC T5-2
> ---
> arch/sparc/include/asm/thread_info_64.h | 28 ++++++++++++-------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
> index c8a73dff27f8..6b12a2b66385 100644
> --- a/arch/sparc/include/asm/thread_info_64.h
> +++ b/arch/sparc/include/asm/thread_info_64.h
> @@ -99,13 +99,20 @@ struct thread_info {
> #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 */
> +/* thread information allocation */
> +#ifdef CONFIG_SPARC64
> + #define THREAD_SIZE (4 * PAGE_SIZE)
> + #define THREAD_SHIFT (PAGE_SHIFT + 2)
> + #define THREAD_SIZE_ORDER 2
> +#elif PAGE_SHIFT == 13
> + #define THREAD_SIZE (2 * PAGE_SIZE)
> + #define THREAD_SHIFT (PAGE_SHIFT + 1)
> + #define THREAD_SIZE_ORDER 1
> +#else
> + #define THREAD_SIZE PAGE_SIZE
> + #define THREAD_SHIFT PAGE_SHIFT
> + #define THREAD_SIZE_ORDER 0
> +#endif
>
> /*
> * macros/functions for gaining access to the thread information structure
> @@ -127,13 +134,6 @@ register struct thread_info *current_thread_info_reg asm("g6");
> extern struct thread_info *current_thread_info(void);
> #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_flag_byte_ptr(ti) \
> ((unsigned char *)(&((ti)->flags)))
> #define __cur_thread_flag_byte_ptr __thread_flag_byte_ptr(current_thread_info())
> --
> 2.53.0
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/1] sparc64: unify thread stack sizing and add explicit 32KB stack
2026-05-19 7:57 [PATCH 0/1] sparc64: unify thread stack sizing and add explicit 32KB stack Tony Rodriguez
2026-05-19 7:57 ` [PATCH 1/1] " Tony Rodriguez
@ 2026-05-19 10:02 ` David Laight
2026-05-19 23:57 ` Tony Rodriguez
1 sibling, 1 reply; 8+ messages in thread
From: David Laight @ 2026-05-19 10:02 UTC (permalink / raw)
To: Tony Rodriguez
Cc: davem, sparclinux, linux-kernel, andreas, thuth, regressions,
glaubitz
On Tue, 19 May 2026 00:57:54 -0700
Tony Rodriguez <unixpro1970@gmail.com> wrote:
> 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.
Increasing the stack size for all threads seems overkill.
That stack doesn't even look deep.
I suspect there are large on-stack buffers in there.
Unfortunately the traceback doesn't print the stack pointers making
debugging hard.
-- David
>
> 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] 8+ messages in thread
* Re: [PATCH 0/1] sparc64: unify thread stack sizing and add explicit 32KB stack
2026-05-19 10:02 ` [PATCH 0/1] " David Laight
@ 2026-05-19 23:57 ` Tony Rodriguez
2026-05-20 13:41 ` David Laight
0 siblings, 1 reply; 8+ messages in thread
From: Tony Rodriguez @ 2026-05-19 23:57 UTC (permalink / raw)
To: David Laight
Cc: davem, sparclinux, linux-kernel, andreas, thuth, regressions,
glaubitz
On 5/19/26 3:02 AM, David Laight wrote:
> On Tue, 19 May 2026 00:57:54 -0700
> Tony Rodriguez <unixpro1970@gmail.com> wrote:
>
>> 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.
> Increasing the stack size for all threads seems overkill.
> That stack doesn't even look deep.
> I suspect there are large on-stack buffers in there.
>
> Unfortunately the traceback doesn't print the stack pointers making
> debugging hard.
>
> -- David
Hi David. Any specific grub command line keywords and values, and
functions you recommend for debugging this? I would be happy to share
Trace Calls, etc. so it is easier to reconfirm and zero in on the issue.
-- Tony
>> 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] 8+ messages in thread
* Re: [PATCH 0/1] sparc64: unify thread stack sizing and add explicit 32KB stack
2026-05-19 23:57 ` Tony Rodriguez
@ 2026-05-20 13:41 ` David Laight
0 siblings, 0 replies; 8+ messages in thread
From: David Laight @ 2026-05-20 13:41 UTC (permalink / raw)
To: Tony Rodriguez
Cc: davem, sparclinux, linux-kernel, andreas, thuth, regressions,
glaubitz
On Tue, 19 May 2026 16:57:04 -0700
Tony Rodriguez <unixpro1970@gmail.com> wrote:
> On 5/19/26 3:02 AM, David Laight wrote:
> > On Tue, 19 May 2026 00:57:54 -0700
> > Tony Rodriguez <unixpro1970@gmail.com> wrote:
> >
> >> 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.
> > Increasing the stack size for all threads seems overkill.
> > That stack doesn't even look deep.
> > I suspect there are large on-stack buffers in there.
> >
> > Unfortunately the traceback doesn't print the stack pointers making
> > debugging hard.
> >
> > -- David
>
> Hi David. Any specific grub command line keywords and values, and
> functions you recommend for debugging this? I would be happy to share
> Trace Calls, etc. so it is easier to reconfirm and zero in on the issue.
Without the stack offsets from the dump, look at the stack frame sizes
for the functions in that traceback.
I suspect there are too many that get near the compile-time threshold.
-- David
> -- Tony
>
> >> 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] 8+ messages in thread
* Re: [PATCH 1/1] sparc64: unify thread stack sizing and add explicit 32KB stack
2026-05-19 7:57 ` [PATCH 1/1] " Tony Rodriguez
2026-05-19 8:56 ` Nathaniel Roach
@ 2026-06-16 14:18 ` Andreas Larsson
2026-06-16 19:58 ` David Laight
1 sibling, 1 reply; 8+ messages in thread
From: Andreas Larsson @ 2026-06-16 14:18 UTC (permalink / raw)
To: Tony Rodriguez, davem, sparclinux
Cc: linux-kernel, andreas, thuth, regressions, glaubitz, David Laight
On 2026-05-19 09:57, Tony Rodriguez wrote:
> This patch restructures the thread‑stack sizing logic into a single
> if / elif / else chain and introduces an explicit 32KB kernel stack
> for SPARC64. The previous implementation relied on nested conditionals
> and PAGE_SHIFT‑dependent behavior, which produced 8KB or 16KB stacks
> depending on configuration. SPARC64 requires a larger,
> architecture‑specific stack due to its trapframe size, register‑window
> behavior, and deeper call paths.
>
> A reproducible failure case occurs when usbcore is enabled: USB hub
> enumeration (usb_new_device(), hub_port_connect(), PM/QoS helpers)
> allocates large on‑stack structures and recurses through several
> layers of device‑model code. Combined with SPARC64’s trapframe and
> register‑window overhead, this reliably exhausts a 16KB stack and
> results in early‑boot panics. A 32KB stack eliminates these failures.
>
> The new logic is:
> SPARC64:
> THREAD_SIZE = 4 * PAGE_SIZE (32KB)
> THREAD_SHIFT = PAGE_SHIFT + 2 (log₂(32KB))
> THREAD_SIZE_ORDER = 2 (4 contiguous pages)
Yes
> Non‑SPARC64 with PAGE_SHIFT == 13:
> Retains the existing 16KB stack behavior
> Fallback:
> Retains the existing 8KB stack behavior
No, not to my understanding, see comments below.
>
> Signed-off-by: Tony Rodriguez <unixpro1970@gmail.com>
> ---
> arch/sparc/include/asm/thread_info_64.h | 28 ++++++++++++-------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
> index c8a73dff27f8..6b12a2b66385 100644
> --- a/arch/sparc/include/asm/thread_info_64.h
> +++ b/arch/sparc/include/asm/thread_info_64.h
> @@ -99,13 +99,20 @@ struct thread_info {
> #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 */
> +/* thread information allocation */
> +#ifdef CONFIG_SPARC64
> + #define THREAD_SIZE (4 * PAGE_SIZE)
> + #define THREAD_SHIFT (PAGE_SHIFT + 2)
> + #define THREAD_SIZE_ORDER 2
As far as I can see, given that this header is included by
#if defined(__sparc__) && defined(__arch64__)
#include <asm/thread_info_64.h>
#else
#include <asm/thread_info_32.h>
#endif
the code above is the only code that will ever be compiled, while leaving...
> +#elif PAGE_SHIFT == 13
> + #define THREAD_SIZE (2 * PAGE_SIZE)
> + #define THREAD_SHIFT (PAGE_SHIFT + 1)
> + #define THREAD_SIZE_ORDER 1
> +#else
> + #define THREAD_SIZE PAGE_SIZE
> + #define THREAD_SHIFT PAGE_SHIFT
> + #define THREAD_SIZE_ORDER 0
> +#endif
...this code dead, where the else branch code already was dead (but then
in two separate else braches).
I'd rather see the else branch here and the else branch below cleaned up
by a separate patch with a fixup tag for commit 15b9350a177b ("sparc64:
Only support 4MB huge pages and 8KB base pages.") that as far as I can
see should have removed the else branch. The else branches was to use
only one page when the page size was _larger_ than 8 KiB when that was
an option.
>
> /*
> * macros/functions for gaining access to the thread information structure
> @@ -127,13 +134,6 @@ register struct thread_info *current_thread_info_reg asm("g6");
> extern struct thread_info *current_thread_info(void);
> #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_flag_byte_ptr(ti) \
> ((unsigned char *)(&((ti)->flags)))
> #define __cur_thread_flag_byte_ptr __thread_flag_byte_ptr(current_thread_info())
> --
> 2.53.0
>
Apart from the above I agree with David Laight that more investigation
of the situation that leads to this problem would be good. Granted,
sparc and sparc64 in particular is a bit special with its stack frames,
but among other arches it seems to be uncommon with 32 KiB of thread
stack unless KASAN is enabled.
Cheers,
Andreas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] sparc64: unify thread stack sizing and add explicit 32KB stack
2026-06-16 14:18 ` Andreas Larsson
@ 2026-06-16 19:58 ` David Laight
0 siblings, 0 replies; 8+ messages in thread
From: David Laight @ 2026-06-16 19:58 UTC (permalink / raw)
To: Andreas Larsson
Cc: Tony Rodriguez, davem, sparclinux, linux-kernel, andreas, thuth,
regressions, glaubitz
On Tue, 16 Jun 2026 16:18:33 +0200
Andreas Larsson <andreas.larsson@gaisler.com> wrote:
> On 2026-05-19 09:57, Tony Rodriguez wrote:
> > This patch restructures the thread‑stack sizing logic into a single
> > if / elif / else chain and introduces an explicit 32KB kernel stack
> > for SPARC64. The previous implementation relied on nested conditionals
> > and PAGE_SHIFT‑dependent behavior, which produced 8KB or 16KB stacks
> > depending on configuration. SPARC64 requires a larger,
> > architecture‑specific stack due to its trapframe size, register‑window
> > behavior, and deeper call paths.
> >
> > A reproducible failure case occurs when usbcore is enabled: USB hub
> > enumeration (usb_new_device(), hub_port_connect(), PM/QoS helpers)
> > allocates large on‑stack structures and recurses through several
> > layers of device‑model code. Combined with SPARC64’s trapframe and
> > register‑window overhead, this reliably exhausts a 16KB stack and
> > results in early‑boot panics. A 32KB stack eliminates these failures.
> >
> > The new logic is:
> > SPARC64:
> > THREAD_SIZE = 4 * PAGE_SIZE (32KB)
> > THREAD_SHIFT = PAGE_SHIFT + 2 (log₂(32KB))
> > THREAD_SIZE_ORDER = 2 (4 contiguous pages)
>
> Yes
>
> > Non‑SPARC64 with PAGE_SHIFT == 13:
> > Retains the existing 16KB stack behavior
> > Fallback:
> > Retains the existing 8KB stack behavior
>
> No, not to my understanding, see comments below.
>
> >
> > Signed-off-by: Tony Rodriguez <unixpro1970@gmail.com>
> > ---
> > arch/sparc/include/asm/thread_info_64.h | 28 ++++++++++++-------------
> > 1 file changed, 14 insertions(+), 14 deletions(-)
> >
> > diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
> > index c8a73dff27f8..6b12a2b66385 100644
> > --- a/arch/sparc/include/asm/thread_info_64.h
> > +++ b/arch/sparc/include/asm/thread_info_64.h
> > @@ -99,13 +99,20 @@ struct thread_info {
> > #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 */
> > +/* thread information allocation */
> > +#ifdef CONFIG_SPARC64
> > + #define THREAD_SIZE (4 * PAGE_SIZE)
> > + #define THREAD_SHIFT (PAGE_SHIFT + 2)
> > + #define THREAD_SIZE_ORDER 2
>
> As far as I can see, given that this header is included by
>
> #if defined(__sparc__) && defined(__arch64__)
> #include <asm/thread_info_64.h>
> #else
> #include <asm/thread_info_32.h>
> #endif
>
> the code above is the only code that will ever be compiled, while leaving...
>
> > +#elif PAGE_SHIFT == 13
> > + #define THREAD_SIZE (2 * PAGE_SIZE)
> > + #define THREAD_SHIFT (PAGE_SHIFT + 1)
> > + #define THREAD_SIZE_ORDER 1
> > +#else
> > + #define THREAD_SIZE PAGE_SIZE
> > + #define THREAD_SHIFT PAGE_SHIFT
> > + #define THREAD_SIZE_ORDER 0
> > +#endif
>
> ...this code dead, where the else branch code already was dead (but then
> in two separate else braches).
>
> I'd rather see the else branch here and the else branch below cleaned up
> by a separate patch with a fixup tag for commit 15b9350a177b ("sparc64:
> Only support 4MB huge pages and 8KB base pages.") that as far as I can
> see should have removed the else branch. The else branches was to use
> only one page when the page size was _larger_ than 8 KiB when that was
> an option.
That whole logic is impenetrable.
Why not set the 'desired thread size' in kB, then work out how many
pages that ends up being based on the page size, and finally get the actual
stack size.
I'm not sure, but with vmalloc()ed stacks and 8k pages can't you have 24kB?
David
>
> >
> > /*
> > * macros/functions for gaining access to the thread information structure
> > @@ -127,13 +134,6 @@ register struct thread_info *current_thread_info_reg asm("g6");
> > extern struct thread_info *current_thread_info(void);
> > #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_flag_byte_ptr(ti) \
> > ((unsigned char *)(&((ti)->flags)))
> > #define __cur_thread_flag_byte_ptr __thread_flag_byte_ptr(current_thread_info())
> > --
> > 2.53.0
> >
>
> Apart from the above I agree with David Laight that more investigation
> of the situation that leads to this problem would be good. Granted,
> sparc and sparc64 in particular is a bit special with its stack frames,
> but among other arches it seems to be uncommon with 32 KiB of thread
> stack unless KASAN is enabled.
>
> Cheers,
> Andreas
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-06-16 19:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-19 7:57 [PATCH 0/1] sparc64: unify thread stack sizing and add explicit 32KB stack Tony Rodriguez
2026-05-19 7:57 ` [PATCH 1/1] " Tony Rodriguez
2026-05-19 8:56 ` Nathaniel Roach
2026-06-16 14:18 ` Andreas Larsson
2026-06-16 19:58 ` David Laight
2026-05-19 10:02 ` [PATCH 0/1] " David Laight
2026-05-19 23:57 ` Tony Rodriguez
2026-05-20 13:41 ` David Laight
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.