Re: [RFC 11/14] x86: add support for Dynamic Kernel Stacks

From: Thomas Gleixner
Date: Mon Mar 11 2024 - 19:34:11 EST


On Mon, Mar 11 2024 at 19:10, Pasha Tatashin wrote:
> On Mon, Mar 11, 2024 at 6:17 PM Andy Lutomirski <luto@xxxxxxxxxx> wrote:
>> Also, I think the whole memory allocation concept in this whole
>> series is a bit odd. Fundamentally, we *can't* block on these stack
>> faults -- we may be in a context where blocking will deadlock. We
>> may be in the page allocator. Panicing due to kernel stack
>> allocation would be very unpleasant.
>
> We never block during handling stack faults. There's a per-CPU page
> pool, guaranteeing availability for the faulting thread. The thread
> simply takes pages from this per-CPU data structure and refills the
> pool when leaving the CPU. The faulting routine is efficient,
> requiring a fixed number of loads without any locks, stalling, or even
> cmpxchg operations.

Is this true for any context including nested exceptions and #NMI?

Thanks,

tglx