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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

>  /* 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



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux