Re: [PATCH v4 01/39] task_work: Fix TWA_NMI_CURRENT error handling

Steven Rostedt
2025-04-22T16:13:07Z

/me is resurrecting the sframe work

On Wed, 22 Jan 2025 13:28:21 +0100
Peter Zijlstra <peterz@infradead.org> wrote:

> > The error has to be checked before the write to task->task_works. Also
> > the try_cmpxchg() loop isn't needed in NMI context. The TWA_NMI_CURRENT
> > case really is special, keep things simple by keeping its code all
> > together in one place.
>
> NMIs can nest, consider #DB (which is NMI like) doing task_work_add()
> and getting interrupted with NMI doing the same.
>

I was looking at this patch and was thinking that the trycmpxchg() is still
for the race against other CPUs.

Another CPU can add a task_work for this task, right?

If so, then even though the NMI adding the task work can't be interrupted
(considering there's no #DB and such), it still can clobber an update done
for this tasks task_work from another CPU.

Is this patch still even needed?

-- Steve