Linux Trace Kernel
 help / color / mirror / Atom feed
From: Andrea Parri <parri.andrea@gmail.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	bpf@vger.kernel.org
Subject: Re: [PATCH 0/2] tracepoint: Fix stale probe data in system call tracepoints
Date: Fri,  4 Dec 2026 16:51:29 +0100	[thread overview]
Message-ID: <20261204155131.24670-1-parri.andrea@gmail.com> (raw)
In-Reply-To: <e9de6675-b1b6-438d-81ca-d4310380f80a@efficios.com>

On Fri, Dec 04, 2026 at 10:41:13AM -0500, Mathieu Desnoyers wrote:
> Why not just fix tp_rcu_cond_sync() to handle the rcu tasks trace
> sychronization which seems to be missing ?

That was my first version: tp_rcu_get_state() also took a polled
snapshot of rcu_tasks_trace_srcu_struct for faultable tracepoints, and
tp_rcu_cond_sync() waited for it if it had not elapsed yet.  It closes
the race, but the wait runs under tracepoints_mutex, and the read-side
sections of the system call tracepoints are not bounded: their probes
can fault in user memory, and sleepable BPF programs can attach there
too.  How long a fault takes is up to whoever backs the memory, a
userfaultfd handler for example.

With a sys_enter_write probe parked in a userfaultfd fault, I disabled
that event and then attached a BPF raw tracepoint to sched_switch.  The
attach blocked until the fault was resolved (it was still blocked after
3 s, on v7.4-rc4):

  __synchronize_srcu+0x92/0xd0
  tracepoint_add_func+0x2b5/0x480
  tracepoint_probe_register_prio_may_exist+0x6d/0xa0
  bpf_raw_tp_link_attach+0x1c2/0x2a0

The snapshots are shared by all tracepoints, so the wait also hits
registrations on unrelated tracepoints such as sched_switch.  Keeping
the Tasks Trace snapshot per tracepoint would avoid that, but a
sys_enter or sys_exit registration could still sleep on the fault with
tracepoints_mutex held, and every other probe registration and
unregistration would queue behind it.

Keeping the iterator for faultable tracepoints removes the need for
that wait, at the cost of an indirect call while the tracepoint has a
single probe.

Thanks,
Andrea

      reply	other threads:[~2026-12-04 15:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 15:34 [PATCH 0/2] tracepoint: Fix stale probe data in system call tracepoints Andrea Parri
2026-12-04 15:34 ` [PATCH 1/2] tracepoint: Always use the iterator for faultable tracepoints Andrea Parri
2026-12-04 15:34 ` [PATCH 2/2] tracepoint: Drop static call switching " Andrea Parri
2026-12-04 15:41 ` [PATCH 0/2] tracepoint: Fix stale probe data in system call tracepoints Mathieu Desnoyers
2026-12-04 15:51   ` Andrea Parri [this message]

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=20261204155131.24670-1-parri.andrea@gmail.com \
    --to=parri.andrea@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@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