fork: Only cache the VMAP stack in finish_task_switch()
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Thu, 17 Feb 2022 10:24:05 +0000 (11:24 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 22 Feb 2022 21:25:02 +0000 (22:25 +0100)
commite540bf3162e822d7a1f07e69e3bb1b4f925ca368
treeb4063b98ade2647194d15f92eea7dc3afc8ee55f
parent1a03d3f13ffe5dd24142d6db629e72c11b704d99
fork: Only cache the VMAP stack in finish_task_switch()

The task stack could be deallocated later, but for fork()/exec() kind of
workloads (say a shell script executing several commands) it is important
that the stack is released in finish_task_switch() so that in VMAP_STACK
case it can be cached and reused in the new task.

For PREEMPT_RT it would be good if the wake-up in vfree_atomic() could
be avoided in the scheduling path. Far worse are the other
free_thread_stack() implementations which invoke __free_pages()/
kmem_cache_free() with disabled preemption.

Cache the stack in free_thread_stack() in the VMAP_STACK case and
RCU-delay the free path otherwise. Free the stack in the RCU callback.
In the VMAP_STACK case this is another opportunity to fill the cache.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Andy Lutomirski <luto@kernel.org>
Link: https://lore.kernel.org/r/20220217102406.3697941-8-bigeasy@linutronix.de
kernel/fork.c