Re: [PATCH 04/10] perf/uprobe: RCU-ify find_uprobe()

From: Oleg Nesterov
Date: Tue Jul 09 2024 - 11:25:34 EST


On 07/09, Peter Zijlstra wrote:

> On Tue, Jul 09, 2024 at 04:32:55PM +0200, Oleg Nesterov wrote:
>
> > Once guard(srcu)(&uprobes_srcu) in handle_swbp() drops the uprobes_srcu lock,
> > utask->active_uprobe can be freed.
>
> Yeah, I've fixed all those already. It's a bit of churn, adding
> inc_not_zero all over the place

I am wondering if we can move delayed_uprobe_remove() from put_uprobe()
to delete_uprobe()... probably not, I forgot everything.

But if we can, then we can probably do

put_uprobe(uprobe)
{
if (refcount_dec_and_test(&uprobe->ref))
kfree(uprobe);
}

uprobe_put_rcu(struct rcu_head *rcu)
{
uprobe = container_of(...);
put_uprobe(uprobe);
}

delete_uprobe(uprobe)
{
rb_erase(...);
delayed_uprobe_remove(...);
...

call_srcu(&uprobes_srcu, &uprobe->rcu, uprobe_put_rcu);
}

and avoid inc_not_zero.

Not sure, I am already exhausted ;)

Oleg.