Re: [PATCH 7/8] kernel/fork: Only cache the VMAP stack in finish_task_switch().

From: Sebastian Andrzej Siewior
Date: Mon Feb 14 2022 - 12:48:17 EST


On 2022-02-14 17:54:48 [+0100], To Andy Lutomirski wrote:
> index fcf0c180617c2..defe31036930a 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -4895,8 +4895,11 @@ static struct rq *finish_task_switch(struct task_struct *prev)
> if (prev->sched_class->task_dead)
> prev->sched_class->task_dead(prev);
>
> - /* Task is done with its stack. */
> - put_task_stack(prev);
> + /*
> + * Task is done with its stack. Try to cache VMAP stack and
> + * delay free it otherwise.
> + */
> + put_task_stack_sched(prev);

Now that I write the commit message, there is probably nothing wrong
with unconditionally delaying it via RCU if caching failed. Then I don't
have to explain that there is one function is for the atomic context and
the other for non-atomic.

> put_task_struct_rcu_user(prev);
> }
> --
Sebastian