Re: [PATCH v4 2/6] perf: Enqueue SIGTRAP always via task_work.

From: Oleg Nesterov
Date: Mon Dec 16 2024 - 14:20:26 EST


On 12/13, Frederic Weisbecker wrote:
>
> So which way do you prefer do solve the initial problem?

Ah. please do what you think/feel is right.

I can't suggest a better fix anyway.

> > > > do {
> > > > - next = work->next;
> > > > + next = READ_ONCE(work->next);
> > > > work->func(work);
> > > > work = next;
> > > > cond_resched();
> > > >
> > > > Perhaps it makes sense before the patch from Sebastian even if that patch
> > > > removes this do/while loop ?
> > >
> > > Hmm, can work->next be modified concurrently here?
> >
> > work->func(work) can, say, do kfree(work) or do another task_work_add(X,
> > work).
>
> Right but then isn't it serialized program order, from the compiler point of view?

Hmm, indeed, you are right. In this case the compiler can't assume it can
"defer" work->next. Thanks for correcting me!

Oleg.