Re: [PATCH v3 11/19] unwind: Add deferred user space unwinding API

From: Peter Zijlstra
Date: Tue Oct 29 2024 - 14:12:01 EST


On Tue, Oct 29, 2024 at 10:05:26AM -0700, Josh Poimboeuf wrote:
> On Tue, Oct 29, 2024 at 02:49:18PM +0100, Peter Zijlstra wrote:
> > On Mon, Oct 28, 2024 at 02:47:38PM -0700, Josh Poimboeuf wrote:
> >
> > > +static void unwind_user_task_work(struct callback_head *head)
> > > +{
> > ...
> > > + guard(rwsem_read)(&callbacks_rwsem);
> > > +
> > > + for_each_set_bit(i, &pending, UNWIND_MAX_CALLBACKS) {
> > > + if (callbacks[i])
> > > + callbacks[i]->func(&trace, cookie, privs[i]);
> > > + }
> >
> > I'm fairly sure people will come with pitchforks for that read-lock
> > there. They scale like shit on big systems. Please use SRCU or somesuch.
>
> I'd expect that unwind_user_{register,unregister}() would only be called
> once per tracing component during boot so there wouldn't be any
> contention.

The read-lock does an atomic op on the lock word, try and do that with
200+ CPUs and things get really sad.

> But I think I can make SRCU work here.

Thanks!