Re: [PATCH] powerpc/Kconfig: Force THREAD_SHIFT to at least 14 with KASAN

Christoph Hellwig
2022-05-31T07:41:30Z

On Tue, May 31, 2022 at 04:16:19PM +1000, Michael Ellerman wrote:
> I was thinking of doing it in C, similar to the way arm64 handles it.
>
> Something like below. It means we always double the stack size when
> KASAN is enabled. I think it's preferable, as it will always work
> regardless of whether the user has an old .config (or is bisectting)?

Is there any reason to even offer the Kconfig? It is super cryptic and
just picking the right value directly in the header would seem much
more sensible:

#if defined(CONFIG_PPC_256K_PAGES)
#define MIN_THREAD_SHIFT 15
#elif defined(CONFIG_PPC64)
#define MIN_THREAD_SHIFT 14
#else
#define MIN_THREAD_SHIFT 13
#endif

#ifdef CONFIG_KASAN
#define THREAD_SHIFT (MIN_THREAD_SHIFT + 1)
#else
#define THREAD_SHIFT MIN_THREAD_SHIFT
#endif

#if defined(CONFIG_VMAP_STACK) && THREAD_SHIFT < PAGE_SHIFT
#undef THREAD_SHIFT
#define THREAD_SHIFT PAGE_SHIFT
#endif