[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZqubRQ3TRsZbV9fo@krava>
Date: Thu, 1 Aug 2024 16:27:17 +0200
From: Jiri Olsa <olsajiri@...il.com>
To: Andrii Nakryiko <andrii@...nel.org>
Cc: linux-trace-kernel@...r.kernel.org, peterz@...radead.org,
oleg@...hat.com, rostedt@...dmis.org, mhiramat@...nel.org,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org,
paulmck@...nel.org
Subject: Re: [PATCH 5/8] uprobes: travers uprobe's consumer list locklessly
under SRCU protection
On Wed, Jul 31, 2024 at 02:42:53PM -0700, Andrii Nakryiko wrote:
SNIP
> static int __copy_insn(struct address_space *mapping, struct file *filp,
> void *insn, int nbytes, loff_t offset)
> {
> @@ -924,7 +901,8 @@ static bool filter_chain(struct uprobe *uprobe, struct mm_struct *mm)
> bool ret = false;
>
> down_read(&uprobe->consumer_rwsem);
> - for (uc = uprobe->consumers; uc; uc = uc->next) {
> + list_for_each_entry_srcu(uc, &uprobe->consumers, cons_node,
> + srcu_read_lock_held(&uprobes_srcu)) {
> ret = consumer_filter(uc, mm);
> if (ret)
> break;
> @@ -1120,17 +1098,19 @@ void uprobe_unregister(struct uprobe *uprobe, struct uprobe_consumer *uc)
> int err;
>
> down_write(&uprobe->register_rwsem);
> - if (WARN_ON(!consumer_del(uprobe, uc))) {
> - err = -ENOENT;
> - } else {
> - err = register_for_each_vma(uprobe, NULL);
> - /* TODO : cant unregister? schedule a worker thread */
> - WARN(err, "leaking uprobe due to failed unregistration");
> - }
> +
> + list_del_rcu(&uc->cons_node);
hum, so previous code had a check to verify that consumer is actually
registered in the uprobe, so it'd survive wrong argument while the new
code could likely do things?
> + err = register_for_each_vma(uprobe, NULL);
> +
> up_write(&uprobe->register_rwsem);
>
> - if (!err)
> - put_uprobe(uprobe);
> + /* TODO : cant unregister? schedule a worker thread */
> + if (WARN(err, "leaking uprobe due to failed unregistration"))
> + return;
> +
> + put_uprobe(uprobe);
> +
> + synchronize_srcu(&uprobes_srcu);
could you comment on why it's needed in here? there's already potential
call_srcu(&uprobes_srcu, ... ) call in put_uprobe above
thanks,
jirka
Powered by blists - more mailing lists