[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z78SPz7VaVZpDOYg@localhost.localdomain>
Date: Wed, 26 Feb 2025 14:08:15 +0100
From: Frederic Weisbecker <frederic@...nel.org>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
linux-kernel@...r.kernel.org, Eric Dumazet <edumazet@...gle.com>,
Peter Zijlstra <peterz@...radead.org>,
Waiman Long <longman@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH] task_work: Consume only item at a time while invoking
the callbacks.
Le Wed, Feb 26, 2025 at 01:50:48PM +0100, Oleg Nesterov a écrit :
> On 02/21, Sebastian Andrzej Siewior wrote:
> >
> > Yi and syzbot managed to hang the task within task_run().
> >
> > The problem is
> > task_work_run() -> __fput() -> perf_release() ->
> > perf_event_release_kernel() -> _free_event() ->
> > perf_pending_task_sync() -> task_work_cancel() failed ->
> > rcuwait_wait_event().
> >
> > Once task_work_run() is running, the list of callbacks removed from the
> > task_struct and from this point on task_work_cancel() can't remove any
> > pending and not yet started work items.
>
> But can this patch really solve the problem?
>
> Suppose we have two tasks, T1 and T2.
>
> T1 does fd = perf_event_open(pid => T2->pid);
> T2 does fd = perf_event_open(pid => T1->pid);
>
> Now, both T1 and T2 do close(fd), call task_work_run(), dequeue the
> ____fput work, and finally call __fput(). Now suppose that both perf
> events fire before T1/T2 call perf_event_release_kernel/_free_event.
>
> Now, T1 and T2 will hang forever in perf_pending_task_sync() waiting
> for each other. task_work_cancel(current) can't succeed with or without
> this patch.
>
> No?
Duh!
So indeed, the wait/wake based solution is too fragile. Are we back to the
old serialized workqueue days flavour of deadlocks with task work?
Anyway the perf_pending_task()'s put_event() based solution thing should fix
that scenario too.
Thanks.
Powered by blists - more mailing lists