Re: [PATCH V4 8/8] riscv: Add config of thread stack size

From: Guo Ren
Date: Sat Sep 10 2022 - 19:36:05 EST


On Sun, Sep 11, 2022 at 12:07 AM Arnd Bergmann <arnd@xxxxxxxx> wrote:
>
> On Sat, Sep 10, 2022, at 2:52 PM, Guo Ren wrote:
> > On Thu, Sep 8, 2022 at 3:37 PM Arnd Bergmann <arnd@xxxxxxxx> wrote:
> >> On Thu, Sep 8, 2022, at 4:25 AM, guoren@xxxxxxxxxx wrote:
> >> > From: Guo Ren <guoren@xxxxxxxxxxxxxxxxx>
> >> - When VMAP_STACK is set, make it possible to select non-power-of-two
> >> stack sizes. Most importantly, 12KB should be a really interesting
> >> choice as 8KB is probably still not enough for many 64-bit workloads,
> >> but 16KB is often more than what you need. You probably don't
> >> want to allow 64BIT/8KB without VMAP_STACK anyway since that just
> >> makes it really hard to debug, so hiding the option when VMAP_STACK
> >> is disabled may also be a good idea.
> > I don't want this config to depend on VMAP_STACK. Some D1 chips would
> > run with an 8K stack size and !VMAP_STACK.
>
> That sounds like a really bad idea, why would you want to risk
> using such a small stack without CONFIG_VMAP_STACK?
>
> Are you worried about increased memory usage or something else?
The requirement is from [1], and I think disabling CONFIG_VMAP_STACK
would be the last step after serious testing.

[1] https://www.cnx-software.com/2021/10/25/allwinner-d1s-f133-risc-v-processor-64mb-ddr2/



>
> > /* thread information allocation */
> > -#ifdef CONFIG_64BIT
> > -#define THREAD_SIZE_ORDER (2 + KASAN_STACK_ORDER)
> > -#else
> > -#define THREAD_SIZE_ORDER (1 + KASAN_STACK_ORDER)
> > -#endif
> > +#define THREAD_SIZE_ORDER CONFIG_THREAD_SIZE_ORDER
> > #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
>
> This doesn't actually allow additional THREAD_SIZE values, as you
> still round up to the nearest power of two.
>
> I think all the non-arch code can deal with non-power-of-2
> sizes, so you'd just need
>
> #define THREAD_SIZE round_up(CONFIG_THREAD_SIZE, PAGE_SIZE)
>
> and fix up the risc-v specific code to do the right thing
> as well. I now see that THREAD_SIZE_ORDER is not actually
> used anywhere with CONFIG_VMAP_STACK, so I suppose that
> definition can be skipped, but you still need a THREAD_ALIGN
> definition that is a power of two and at least a page larger
> than THREAD_SIZE.
>
> Arnd



--
Best Regards
Guo Ren