From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Josef Bacik <josef@toxicpanda.com>
Cc: "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>,
Masami Hiramatsu <mhiramat@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 v5 03/13] kprobes: Expose the optprobe jump window to Tasks RCU
Date: Wed, 23 Sep 2026 16:45:10 +0900 [thread overview]
Message-ID: <20260923164510.f3bbddefea4423f8f1bfecb8@kernel.org> (raw)
In-Reply-To: <20260922-b4-rcu-tasks-preempt-qs-v5-3-410f57770bad@toxicpanda.com>
On Tue, 22 Sep 2026 02:23:22 +0000
Josef Bacik <josef@toxicpanda.com> wrote:
> kprobe_optimizer() is the one synchronize_rcu_tasks() user that is not
> about trampoline text: it waits for tasks that were interrupted on an
> instruction boundary inside the bytes it is about to overwrite with the
> optimized jump, so that none of them resumes into the middle of the new
> instruction. Those bytes are ordinary kernel or module text with no
> Tasks Trace reader around them, so on CONFIG_TASKS_RCU_TRAMPOLINE_READERS
> kernels the irq-exit quiescent-state check has to be told about them.
>
> Add kprobe_in_optimized_region(), a lockless and conservative form of
> get_optimized_kprobe() that reports whether any registered kprobe lies
> within MAX_OPTIMIZED_LENGTH before the given address regardless of its
> optimization state, and have rcu_tasks_trampoline_text() consult it for
> core and module text so that a task interrupted there becomes a holdout
> rather than a quiescent event. The hash walk only runs while
> kprobe_optimizer() is actually inside its synchronize_rcu_tasks(),
> tracked by a flag it sets around the call; otherwise the check is a
> single load. That check cannot see a task that was already preempted in
> the region before the flag went up (possibly before the kprobe even
> existed), and the new grace period does not otherwise wait for a
> preempted task to run again, so before synchronize_rcu_tasks() the
> optimizer calls rcu_tasks_wait_irq_preempted() to wait until no parked
> task's recorded irq-exit preemption IP is inside such a region; its
> leading synchronize_rcu() also publishes the flag to every (interrupts-
> disabled) check in flight. The kprobe hash is RCU-protected and every
> free path waits for a grace period after unhashing, so the lockless walk
> from the irq-exit path is safe.
>
> On other configurations the flag is set and cleared but nothing reads
> it and rcu_tasks_wait_irq_preempted() is a stub; the classic
> implementation already waits for such tasks.
Hmm, this seems a bit awkward. To solve this problem with tasks RCU is
not a straight solution. I rather like to suggest fixing kprobe_optimizer.
Since the root cause of the mutex related hang_task stall is the
kprobe_optimizer() waits RCU under locking mutexes -- text_mutex,
cpu_read_lock, and kprobe_mutex. When I introduced this, waiting
RCU grace period did not take so long time. But now it can take
longer, so it is a good chance to fix it completely.
Since the RCU is a kind of the generation control of internal state,
we can introduce multi-generation optimizing/freeing list and
RCU tasks callback for that.
Let me try to make another series to fix optprobe side.
Thank you,
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2026-09-23 7:45 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 [this message]
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
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=20260923164510.f3bbddefea4423f8f1bfecb8@kernel.org \
--to=mhiramat@kernel.org \
--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=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.