Linux Trace Kernel
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Avi Weiss <thnkslprpt@gmail.com>
Cc: mhiramat@kernel.org, peterz@infradead.org, andrii@kernel.org,
	mingo@redhat.com, acme@kernel.org, namhyung@kernel.org,
	linux-trace-kernel@vger.kernel.org,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] uprobes: avoid postponing return-probe SRCU lease expiration
Date: Mon, 16 Nov 2026 15:48:31 +0100	[thread overview]
Message-ID: <avsXv0CMBoilsB_1@redhat.com> (raw)
In-Reply-To: <20261115155921.260878-1-thnkslprpt@gmail.com>

On 11/15, Avi Weiss wrote:
>
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -2052,6 +2052,9 @@ static void ri_timer(struct timer_list *timer)
>  	 */
>  	raw_write_seqcount_begin(&utask->ri_seqcount);
>
> +	/* Pair with prepare_uretprobe() to avoid a missed rearm. */
> +	smp_mb();
> +
>  	for_each_ret_instance_rcu(ri, utask->return_instances)
>  		hprobe_expire(&ri->hprobe, false);
>
> @@ -2304,7 +2307,9 @@ static void prepare_uretprobe(struct uprobe *uprobe, struct pt_regs *regs,
>  	ri->next = utask->return_instances;
>  	rcu_assign_pointer(utask->return_instances, ri);
>
> -	mod_timer(&utask->ri_timer, jiffies + RI_TIMER_PERIOD);
> +	/* Pair with ri_timer() after publishing the instance. */
> +	smp_mb();
> +	timer_reduce(&utask->ri_timer, jiffies + RI_TIMER_PERIOD);

Hmm... timer_reduce() looks a bit confusing to me, perhaps

	if (!timer_pending(...))
		add_timer(...);

make more sense?

Either way, I am not sure I fully understand the memory barriers... Looks
correct, but IMO the "Pair with ..." comments do not really help.

IIUC, prepare_uretprobe() needs mb() between STORE in rcu_assign_pointer()
and LOAD in timer_pending(); while ri_timer() needs mb() between STORE in
expire_timers()->detach_timer() and LOAD in for_each_ret_instance_rcu().

Right?

Oleg.


      reply	other threads:[~2026-11-16 14:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 15:59 [PATCH] uprobes: avoid postponing return-probe SRCU lease expiration Avi Weiss
2026-11-16 14:48 ` Oleg Nesterov [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=avsXv0CMBoilsB_1@redhat.com \
    --to=oleg@redhat.com \
    --cc=acme@kernel.org \
    --cc=andrii@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=thnkslprpt@gmail.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