From: Andrea Parri <parri.andrea@gmail.com>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Josef Bacik <josef@toxicpanda.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Boqun Feng <boqun@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Puranjay Mohan <puranjay@kernel.org>,
rcu@vger.kernel.org, bpf@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kprobes: Make optprobe optimizer multi-generational and asynchronous
Date: Thu, 24 Sep 2026 11:31:50 +0200 [thread overview]
Message-ID: <arTuBodyGqQ0mErI@andreayoga.localdomain> (raw)
In-Reply-To: <179017148080.466588.9116221556625712980.stgit@devnote2>
Hi Masami,
> - /* Step 5: Kick optimizer again if needed. But if there is a flush requested, */
> - if (completion_done(&optimizer_completion))
> - complete(&optimizer_completion);
> + /* Step 2: Dispatch waiting room generation if allowed */
> + optprobe_dispatch_generation();
>
> - if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list))
> - kick_kprobe_optimizer(); /*normal kick*/
> + /* Step 3: Check completion if flush was requested */
> + if (!optprobe_optimizer_busy()) {
> + if (optprobe_flush_requested) {
> + optprobe_flush_requested = false;
> + complete_all(&optimizer_completion);
> + }
Removing the completion_done() check also fixes a hang in the current
code: completion_done() is only true once the completion has been
completed, so complete() is never called while a flusher waits. For
example, "echo 0 > /proc/sys/debug/kprobes-optimization" with an
optimized kprobe never returns. I posted a fix for that separately [1].
[...]
> - while (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list)) {
> + while (optprobe_optimizer_busy()) {
> init_completion(&optimizer_completion);
This part is still racy, though. The flusher drops kprobe_mutex while
it sleeps, and the sysctl handler and the debugfs "enabled" file do not
otherwise serialize against each other. A second flusher can then run
init_completion() on the wait queue the first one is sleeping on: the
first waiter is dropped from the queue, and complete_all() wakes only
the second one.
With this patch the window is wider, since kprobe_mutex is released
while the Tasks RCU grace period runs and optprobe_optimizer_busy()
stays true until the generation is finalized.
The fix in [1] replaces the completion with a counter of optimizer
passes, bumped at the end of each pass and signalled with
wake_up_var_locked(), both under kprobe_mutex; the flusher samples the
count and waits with wait_var_event_mutex() until it changes.
Something similar should fit here, with the counter bumped at the end
of each kprobe_optimizer() call and the flusher re-checking
optprobe_optimizer_busy() under kprobe_mutex as it does now.
[1] https://lore.kernel.org/all/20260924092142.199198-1-parri.andrea@gmail.com/
Thanks,
Andrea
next prev parent reply other threads:[~2026-09-24 9:32 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 2:23 [PATCH v5 00/13] rcu-tasks: build Tasks RCU on Tasks Trace readers in trampolines Josef Bacik
2026-09-22 2:23 ` [PATCH v5 01/13] entry: Pass pt_regs to irqentry_exit_cond_resched() Josef Bacik
2026-09-22 2:23 ` [PATCH v5 02/13] rcu-tasks: Add a Tasks RCU implementation for reader-marked trampolines Josef Bacik
2026-09-22 9:26 ` Frederic Weisbecker
2026-09-22 2:23 ` [PATCH v5 03/13] kprobes: Expose the optprobe jump window to Tasks RCU Josef Bacik
2026-09-22 3:22 ` bot+bpf-ci
2026-09-23 7:45 ` Masami Hiramatsu
2026-09-23 13:51 ` [PATCH] kprobes: Make optprobe optimizer multi-generational and asynchronous Masami Hiramatsu (Google)
2026-09-23 15:12 ` Masami Hiramatsu
2026-09-23 16:58 ` Paul E. McKenney
2026-09-24 0:35 ` Masami Hiramatsu
2026-09-24 9:31 ` Andrea Parri [this message]
2026-09-24 16:17 ` bot+bpf-ci
2026-09-26 2:17 ` Masami Hiramatsu
2026-09-22 2:23 ` [PATCH v5 04/13] ftrace: Mark modules hosting direct-call trampolines for Tasks RCU Josef Bacik
2026-09-22 2:23 ` [PATCH v5 05/13] x86/ftrace: Take a Tasks Trace reader around ftrace_caller's call-out Josef Bacik
2026-09-22 2:23 ` [PATCH v5 06/13] x86/kprobes: Take a Tasks Trace reader in the optprobe template Josef Bacik
2026-09-22 3:22 ` bot+bpf-ci
2026-09-22 2:23 ` [PATCH v5 07/13] bpf, x86: Take a Tasks Trace reader in the trampoline around its call-outs Josef Bacik
2026-09-22 3:22 ` bot+bpf-ci
2026-09-23 2:16 ` Alexei Starovoitov
2026-09-22 2:23 ` [PATCH v5 08/13] arm64: ftrace: Take a Tasks Trace reader around ftrace_caller's call-out Josef Bacik
2026-09-22 2:23 ` [PATCH v5 09/13] bpf, arm64: Take a Tasks Trace reader in the trampoline around its call-outs Josef Bacik
2026-09-22 2:23 ` [PATCH v5 10/13] samples: ftrace: Make the direct-call trampolines Tasks Trace readers Josef Bacik
2026-09-22 3:35 ` bot+bpf-ci
2026-09-22 2:23 ` [PATCH v5 11/13] rcutorture: Make Tasks RCU readers Tasks Trace readers where required Josef Bacik
2026-09-22 2:23 ` [PATCH v5 12/13] rcu-tasks-trace: Assert no reader is held on return to userspace Josef Bacik
2026-09-22 3:11 ` bot+bpf-ci
2026-09-22 2:23 ` [PATCH v5 13/13] x86, arm64: Build Tasks RCU on Tasks Trace readers in trampolines Josef Bacik
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=arTuBodyGqQ0mErI@andreayoga.localdomain \
--to=parri.andrea@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=boqun@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=frederic@kernel.org \
--cc=josef@toxicpanda.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=puranjay@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.