From: Oleg Nesterov <oleg@redhat.com>
To: Andrii Nakryiko <andrii@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org, peterz@infradead.org,
rostedt@goodmis.org, mhiramat@kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, jolsa@kernel.org,
paulmck@kernel.org
Subject: Re: [PATCH v2 4/6] uprobes: travers uprobe's consumer list locklessly under SRCU protection
Date: Thu, 8 Aug 2024 16:40:14 +0200 [thread overview]
Message-ID: <20240808144013.GG8020@redhat.com> (raw)
In-Reply-To: <20240808002118.918105-5-andrii@kernel.org>
On 08/07, Andrii Nakryiko wrote:
>
> @@ -1127,18 +1105,30 @@ 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 */
> - if (unlikely(err))
> - uprobe_warn(current, "unregister, leaking uprobe");
> - }
> +
> + list_del_rcu(&uc->cons_node);
> + 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 (unlikely(err)) {
> + uprobe_warn(current, "unregister, leaking uprobe");
> + return;
Looks wrong... We can (should) skip put_uprobe(), but we can't avoid
synchronize_srcu().
The caller can free the consumer right after return. You even added
a fat comment below.
Yes, the problem will go away after you split it into nosync/sync, but
still.
Oleg.
next prev parent reply other threads:[~2024-08-08 14:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-08 0:21 [PATCH v2 0/6] uprobes: RCU-protected hot path optimizations Andrii Nakryiko
2024-08-08 0:21 ` [PATCH v2 1/6] uprobes: revamp uprobe refcounting and lifetime management Andrii Nakryiko
2024-08-08 0:21 ` [PATCH v2 2/6] uprobes: protected uprobe lifetime with SRCU Andrii Nakryiko
2024-08-08 10:20 ` Oleg Nesterov
2024-08-08 16:58 ` Andrii Nakryiko
2024-08-08 17:51 ` Andrii Nakryiko
2024-08-08 0:21 ` [PATCH v2 3/6] uprobes: get rid of enum uprobe_filter_ctx in uprobe filter callbacks Andrii Nakryiko
2024-08-08 0:21 ` [PATCH v2 4/6] uprobes: travers uprobe's consumer list locklessly under SRCU protection Andrii Nakryiko
2024-08-08 14:40 ` Oleg Nesterov [this message]
2024-08-08 17:50 ` Andrii Nakryiko
2024-08-08 0:21 ` [PATCH v2 5/6] perf/uprobe: split uprobe_unregister() Andrii Nakryiko
2024-08-08 0:21 ` [PATCH v2 6/6] uprobes: switch to RCU Tasks Trace flavor for better performance Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240808144013.GG8020@redhat.com \
--to=oleg@redhat.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).