On 2/20/20 2:17 PM, Peter Zijlstra wrote: > On Thu, Feb 20, 2020 at 01:31:48PM -0700, Jens Axboe wrote: >> This is similar to the task_works, and uses the same infrastructure, but >> the sched_work list is run when the task is being scheduled in or out. >> >> The intended use case here is for core code to be able to add work >> that should be automatically run by the task, without the task needing >> to do anything. This is done outside of the task, one example would be >> from waitqueue handlers, or anything else that is invoked out-of-band >> from the task itself. >> > > >> diff --git a/kernel/task_work.c b/kernel/task_work.c >> index 3445421266e7..ba62485d5b3d 100644 >> --- a/kernel/task_work.c >> +++ b/kernel/task_work.c >> @@ -3,7 +3,14 @@ >> #include <linux/task_work.h> >> #include <linux/tracehook.h> >> >> -static struct callback_head work_exited; /* all we need is ->next == NULL */ >> +static void task_exit_func(struct callback_head *head) >> +{ >> +} >> + >> +static struct callback_head work_exited = { >> + .next = NULL, >> + .func = task_exit_func, >> +}; > > Do we really need this? It seems to suggest we're trying to execute > work_exited, which would be an error. > > Doing so would be the result of calling sched_work_run() after > exit_task_work(). I suppose that's actually possible.. the problem is > that that would reset sched_work to NULL and re-allow queueing works, > which would then leak. > > I'll look at it in more detail tomorrow, I'm tired... Let me try and instrument it, I definitely hit it on task exit but might have been induced by some earlier bugs. -- Jens Axboe