Linux Trace Kernel
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Josef Bacik <josef@toxicpanda.com>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
	Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
	Joel Fernandes <joelagnelf@nvidia.com>,
	Boqun Feng <boqun@kernel.org>, Thomas Gleixner <tglx@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>, Jiri Olsa <jolsa@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	x86@kernel.org, Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Puranjay Mohan <puranjay@kernel.org>,
	Xu Kuohai <xukuohai@huaweicloud.com>,
	Andy Lutomirski <luto@kernel.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Zqiang <qiang.zhang@linux.dev>, Juergen Gross <jgross@suse.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	linux-kernel@vger.kernel.org, rcu@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH RFC v3 03/13] rcu-tasks: Add a Tasks RCU implementation for reader-marked trampolines
Date: Thu, 17 Sep 2026 22:20:17 +0200	[thread overview]
Message-ID: <aqxLgT41UyA-bV5J@pavilion.home> (raw)
In-Reply-To: <20260915-b4-rcu-tasks-preempt-qs-v3-3-0ad30c4c5ee7@toxicpanda.com>

Le Tue, Sep 15, 2026 at 01:17:30PM +0000, Josef Bacik a écrit :
> +static void rcu_tasks_tramp_hold(struct task_struct *t)
> +{
> +	unsigned long flags;
> +
> +	if (t->rcu_tasks_holdout)
> +		return;
> +	raw_spin_lock_irqsave(&rcu_tasks_tramp_lock, flags);
> +	list_add_tail(&t->rcu_tasks_holdout_list, &rcu_tasks_tramp_holdouts);
> +	WRITE_ONCE(t->rcu_tasks_holdout, true);
> +	raw_spin_unlock_irqrestore(&rcu_tasks_tramp_lock, flags);
> +}
> +
> +static void rcu_tasks_tramp_release(struct task_struct *t)
> +{
> +	unsigned long flags;
> +
> +	if (likely(!t->rcu_tasks_holdout))
> +		return;
> +	raw_spin_lock_irqsave(&rcu_tasks_tramp_lock, flags);
> +	list_del_init(&t->rcu_tasks_holdout_list);
> +	WRITE_ONCE(t->rcu_tasks_holdout, false);
> +	raw_spin_unlock_irqrestore(&rcu_tasks_tramp_lock, flags);
> +}
> +
> +/**
> + * rcu_tasks_irq_resched_enter - Tasks RCU hook for the irq-exit reschedule check
> + * @ip: instruction pointer of the interrupted (task-level) context
> + *
> + * Called with interrupts disabled when an interrupt returning to kernel
> + * mode is about to preempt_schedule_irq(), the one context switch that can
> + * catch a task inside unmarked trampoline text.  Record where the task is
> + * parked for as long as it is (rcu_tasks_wait_irq_preempted() looks at
> + * that), and if it is inside such text make it a holdout before
> + * __schedule() reports the quiescent event; if it is not, this is as good
> + * as a voluntary switch for ending an earlier hold.
> + */
> +void rcu_tasks_irq_resched_enter(unsigned long ip)
> +{
> +	struct task_struct *t = current;
> +	struct rcu_tasks_percpu *rtpcp = this_cpu_ptr(rcu_tasks.rtpcpu);
> +
> +	lockdep_assert_irqs_disabled();
> +	WRITE_ONCE(t->rcu_tasks_irq_ip, ip);
> +	t->rcu_tasks_exit_cpu = smp_processor_id();
> +	raw_spin_lock_rcu_node(rtpcp);
> +	list_add(&t->rcu_tasks_exit_list, &rtpcp->rtp_exit_list);
> +	raw_spin_unlock_rcu_node(rtpcp);

I don't think we can do that. This is too much unconditional overhead
on the hot preemption path. rcu_tasks_trampoline_text() should be
a condition here.

And do we really need to maintain both lists? I understand that they
have different purposes.

->rcu_tasks_exit_list is to track preempted tasks on trampoline
->rcu_tasks_holdout_list is to track preempted tasks on trampoline until
                         they ever voluntary schedule()

Can the latter replace the former? I see it's used on kprobes and others
but I haven't checked the details yet.

Thanks.

-- 
Frederic Weisbecker
SUSE Labs

  parent reply	other threads:[~2026-09-17 20:20 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 13:17 [PATCH RFC v3 00/13] rcu-tasks: build Tasks RCU on Tasks Trace readers in trampolines Josef Bacik
2026-09-15 13:17 ` [PATCH RFC v3 01/13] entry: Pass pt_regs to irqentry_exit_cond_resched() Josef Bacik
2026-09-15 14:17   ` bot+bpf-ci
2026-09-15 13:17 ` [PATCH RFC v3 02/13] rcu-tasks-trace: Inline rcu_read_lock_trace() and annotate inside the reader Josef Bacik
2026-09-15 14:17   ` bot+bpf-ci
2026-09-15 13:17 ` [PATCH RFC v3 03/13] rcu-tasks: Add a Tasks RCU implementation for reader-marked trampolines Josef Bacik
2026-09-15 13:29   ` sashiko-bot
2026-09-15 16:02     ` Josef Bacik
2026-09-15 15:14   ` Frederic Weisbecker
2026-09-15 23:56     ` Paul E. McKenney
2026-09-16 12:40       ` Frederic Weisbecker
2026-09-16 14:26         ` Paul E. McKenney
2026-09-16 14:35           ` Frederic Weisbecker
2026-09-16 14:47             ` Frederic Weisbecker
2026-09-16 14:55               ` Paul E. McKenney
2026-09-16 15:23                 ` Frederic Weisbecker
2026-09-16 15:41                   ` Paul E. McKenney
2026-09-17 12:14                     ` Frederic Weisbecker
2026-09-17 15:40                       ` Paul E. McKenney
2026-09-17 16:35                         ` Josef Bacik
2026-09-17 16:55                           ` Paul E. McKenney
2026-09-17 18:45                         ` Frederic Weisbecker
2026-09-17 19:25                           ` Paul E. McKenney
2026-09-17 20:31                             ` Paul E. McKenney
2026-09-17 20:20   ` Frederic Weisbecker [this message]
2026-09-22 15:42     ` Josef Bacik
2026-09-15 13:17 ` [PATCH RFC v3 04/13] kprobes: Expose the optprobe jump window to Tasks RCU Josef Bacik
2026-09-15 13:17 ` [PATCH RFC v3 05/13] ftrace: Mark modules hosting direct-call trampolines for " Josef Bacik
2026-09-15 14:17   ` bot+bpf-ci
2026-09-15 16:03     ` Josef Bacik
2026-09-15 13:17 ` [PATCH RFC v3 06/13] bpf: Take a Tasks Trace reader in the trampoline glue Josef Bacik
2026-09-16  3:45   ` Alexei Starovoitov
2026-09-17  1:16     ` Josef Bacik
2026-09-17  2:24       ` Alexei Starovoitov
2026-09-15 13:17 ` [PATCH RFC v3 07/13] x86/ftrace: Take a Tasks Trace reader around ftrace_caller's call-out Josef Bacik
2026-09-15 13:17 ` [PATCH RFC v3 08/13] x86/kprobes: Take a Tasks Trace reader in the optprobe template Josef Bacik
2026-09-15 13:17 ` [PATCH RFC v3 09/13] arm64: ftrace: Take a Tasks Trace reader around ftrace_caller's call-out Josef Bacik
2026-09-15 13:17 ` [PATCH RFC v3 10/13] samples: ftrace: Make the direct-call trampolines Tasks Trace readers Josef Bacik
2026-09-15 13:17 ` [PATCH RFC v3 11/13] rcutorture: Make Tasks RCU readers Tasks Trace readers where required Josef Bacik
2026-09-15 13:17 ` [PATCH RFC v3 12/13] rcu-tasks-trace: Assert no reader is held on return to userspace Josef Bacik
2026-09-15 13:17 ` [PATCH RFC v3 13/13] x86, arm64: Build Tasks RCU on Tasks Trace readers in trampolines Josef Bacik
2026-09-15 14:17   ` bot+bpf-ci

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=aqxLgT41UyA-bV5J@pavilion.home \
    --to=frederic@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=boqun@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=daniel@iogearbox.net \
    --cc=ihor.solodrai@linux.dev \
    --cc=jgross@suse.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joelagnelf@nvidia.com \
    --cc=jolsa@kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mcgrof@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=neeraj.upadhyay@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=puranjay@kernel.org \
    --cc=qiang.zhang@linux.dev \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@kernel.org \
    --cc=urezki@gmail.com \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xukuohai@huaweicloud.com \
    /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