Re: [PATCH 05/10] perf/uprobe: SRCU-ify uprobe->consumer list
From: Peter Zijlstra
Date: Tue Jul 09 2024 - 08:06:13 EST
On Mon, Jul 08, 2024 at 11:12:46AM +0200, Peter Zijlstra wrote:
> @@ -2087,14 +2092,19 @@ static struct uprobe *find_active_uprobe
> return uprobe;
> }
>
> +#define for_each_consumer_rcu(pos, head) \
> + for (pos = rcu_dereference_raw(head); pos; \
> + pos = rcu_dereference_raw(pos->next))
> +
> static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)
> {
> struct uprobe_consumer *uc;
> int remove = UPROBE_HANDLER_REMOVE;
> bool need_prep = false; /* prepare return uprobe, when needed */
>
> - down_read(&uprobe->register_rwsem);
> - for (uc = uprobe->consumers; uc; uc = uc->next) {
> + 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.
> }
> - up_read(&uprobe->register_rwsem);
> }