From: Peter Zijlstra <peterz@infradead.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
linux-trace-kernel@vger.kernel.org, oleg@redhat.com,
rostedt@goodmis.org, mhiramat@kernel.org, mingo@kernel.org,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
jolsa@kernel.org, paulmck@kernel.org
Subject: Re: [PATCH v2 tip/perf/core 1/2] uprobes: allow put_uprobe() from non-sleepable softirq context
Date: Mon, 21 Oct 2024 12:31:51 +0200 [thread overview]
Message-ID: <20241021103151.GB6791@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAEf4Bzb3xjTH7Qh8c_j95jEr4fNxBgG11a0sCe4hoF9chwUtYg@mail.gmail.com>
On Fri, Oct 18, 2024 at 11:22:00AM -0700, Andrii Nakryiko wrote:
> On Fri, Oct 18, 2024 at 1:26 AM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Mon, Oct 07, 2024 at 05:25:55PM -0700, Andrii Nakryiko wrote:
> > > Currently put_uprobe() might trigger mutex_lock()/mutex_unlock(), which
> > > makes it unsuitable to be called from more restricted context like softirq.
> >
> > This is delayed_uprobe_lock, right?
>
> Not just delated_uprobe_lock, there is also uprobes_treelock (I forgot
> to update the commit message to mention that). Oleg had concerns (see
> [0]) with that being taken from the timer thread, so I just moved all
> of the locking into deferred work callback.
>
> [0] https://lore.kernel.org/linux-trace-kernel/20240915144910.GA27726@redhat.com/
Right, but at least that's not a sleeping lock. He's right about it
needing to become a softirq-safe lock though. And yeah, unfortunate
that.
> > So can't we do something like so instead?
>
> I'll need to look at this more thoroughly (and hopefully Oleg will get
> a chance as well), dropping lock from delayed_ref_ctr_inc() is a bit
> scary, but might be ok.
So I figured that update_ref_ctr() is already doing the
__update_ref_ctr() thing without holding the lock, so that lock really
is only there to manage the list.
And that list is super offensive... That really wants to be a per-mm
rb-tree or somesuch.
AFAICT the only reason it is a mutex, is because doing unbouded list
iteration under a spinlock is a really bad idea.
> But generally speaking, what's your concern with doing deferred work
> in put_uprobe()? It's not a hot path by any means, worst case we'll
> have maybe thousands of uprobes attached/detached.
Mostly I got offended by the level of crap in that code, and working
around crap instead of fixing crap just ain't right.
next prev parent reply other threads:[~2024-10-21 10:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 0:25 [PATCH v2 tip/perf/core 0/2] SRCU-protected uretprobes hot path Andrii Nakryiko
2024-10-08 0:25 ` [PATCH v2 tip/perf/core 1/2] uprobes: allow put_uprobe() from non-sleepable softirq context Andrii Nakryiko
2024-10-18 8:26 ` Peter Zijlstra
2024-10-18 18:22 ` Andrii Nakryiko
2024-10-21 10:31 ` Peter Zijlstra [this message]
2024-10-21 17:04 ` Andrii Nakryiko
2024-10-08 0:25 ` [PATCH v2 tip/perf/core 2/2] uprobes: SRCU-protect uretprobe lifetime (with timeout) Andrii Nakryiko
2024-10-18 10:16 ` Peter Zijlstra
2024-10-18 18:22 ` Andrii Nakryiko
2024-10-19 0:09 ` Paul E. McKenney
2024-10-21 10:48 ` Peter Zijlstra
2024-10-21 13:57 ` Paul E. McKenney
2024-10-21 16:53 ` 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=20241021103151.GB6791@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=andrii.nakryiko@gmail.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=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@kernel.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