Re: [patch 4/5] sched: Delay task stack freeing on RT

From: Andy Lutomirski
Date: Fri Oct 01 2021 - 15:02:37 EST


On Fri, Oct 1, 2021 at 11:48 AM Andy Lutomirski <luto@xxxxxxxxxx> wrote:
>
> On Fri, Oct 1, 2021 at 10:24 AM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> >

> ISTM it would be conceptually for do_exit() to handle its own freeing
> in its own preemptible context. Obviously that can't really work,
> since we can't free a task_struct or a task stack while we're running
> on it. But I wonder if we could approximate it by putting this work
> in a workqueue so that it all runs in a normal schedulable context.
> To make the shell script case work nicely, we want to release the task
> stack before notifying anyone waiting for the dying task to exit, but
> maybe that's doable. It could involve some nasty exit_signal hackery,
> though.

I'm making this way more complicated than it needs to be. How about
we unaccount the task stack in do_exit and release it for real in
finish_task_switch()? Other than accounting, free_thread_stack
doesn't take any locks.

--Andy