Skip to content

Commit a7555f6

Browse files
guoren83palmer-dabbelt
authored andcommitted
riscv: stack: Add config of thread stack size
The commit 0cac21b ("riscv: use 16KB kernel stack on 64-bit") increases the thread size mandatory, but some scenarios, such as D1 with a small memory footprint, would suffer from that. After independent irq stack support, let's give users a choice to determine their custom stack size. Link: https://lore.kernel.org/linux-riscv/[email protected]/ Suggested-by: Arnd Bergmann <[email protected]> Tested-by: Jisheng Zhang <[email protected]> Signed-off-by: Guo Ren <[email protected]> Signed-off-by: Guo Ren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent dd69d07 commit a7555f6

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

arch/riscv/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,16 @@ config IRQ_STACKS
599599
Add independent irq & softirq stacks for percpu to prevent kernel stack
600600
overflows. We may save some memory footprint by disabling IRQ_STACKS.
601601

602+
config THREAD_SIZE_ORDER
603+
int "Kernel stack size (in power-of-two numbers of page size)" if VMAP_STACK && EXPERT
604+
range 0 4
605+
default 1 if 32BIT && !KASAN
606+
default 3 if 64BIT && KASAN
607+
default 2
608+
help
609+
Specify the Pages of thread stack size (from 4KB to 64KB), which also
610+
affects irq stack size, which is equal to thread stack size.
611+
602612
endmenu # "Platform type"
603613

604614
menu "Kernel features"

arch/riscv/include/asm/thread_info.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,8 @@
1111
#include <asm/page.h>
1212
#include <linux/const.h>
1313

14-
#ifdef CONFIG_KASAN
15-
#define KASAN_STACK_ORDER 1
16-
#else
17-
#define KASAN_STACK_ORDER 0
18-
#endif
19-
2014
/* thread information allocation */
21-
#ifdef CONFIG_64BIT
22-
#define THREAD_SIZE_ORDER (2 + KASAN_STACK_ORDER)
23-
#else
24-
#define THREAD_SIZE_ORDER (1 + KASAN_STACK_ORDER)
25-
#endif
15+
#define THREAD_SIZE_ORDER CONFIG_THREAD_SIZE_ORDER
2616
#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
2717

2818
/*

0 commit comments

Comments
 (0)