Re: [PATCH 05/10] perf/uprobe: SRCU-ify uprobe->consumer list

From: Oleg Nesterov
Date: Tue Jul 09 2024 - 09:37:07 EST


On 07/09, Peter Zijlstra wrote:
>
> > + guard(srcu)(&uprobes_srcu);
> > +
> > + for_each_consumer_rcu(uc, uprobe->consumers) {
> > int rc = 0;
> >
> > if (uc->handler) {
> > @@ -2116,7 +2126,6 @@ static void handler_chain(struct uprobe
> > WARN_ON(!uprobe_is_active(uprobe));
> > unapply_uprobe(uprobe, current->mm);
>
> ^^^ this remove case needs more thought.

Yeah... that is why the current code doesn't use ->consumer_rwsem, iirc.

And consumer_add/del need some changes. Say, consumer_add() does

uc->next = uprobe->consumers;
uprobe->consumers = uc;

I guess it should do

WRITE_ONCE(uc->next, uprobe->consumers);
rcu_assign_pointer(uprobe->consumers, uc);

Oleg.