mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: David Carlier <devnexen@gmail.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/rt: Use atomic_try_cmpxchg_acquire() in rto_start_trylock()
Date: Wed, 15 Apr 2026 20:14:04 +0200	[thread overview]
Message-ID: <27651a34-6b25-430f-8cb4-39d44b2d4c90@gmail.com> (raw)
In-Reply-To: <20260415124045.372307-1-devnexen@gmail.com>



On 4/15/26 14:40, David Carlier wrote:
> Replace this pattern in rto_start_trylock():
> 
>      !atomic_cmpxchg_acquire(*ptr, 0, new)
> 
> ... with the simpler and faster:
> 
>      atomic_try_cmpxchg_acquire(*ptr, &zero, new)
> 
> The x86 CMPXCHG instruction returns success in the ZF flag, so
> atomic_try_cmpxchg_acquire() saves a compare after the CMPXCHG.
> 
> No functional change intended.
> 
> Signed-off-by: David Carlier <devnexen@gmail.com>

Reviewed-by: Uros Bizjak <ubizjak@gmail.com>

> ---
>   kernel/sched/rt.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 4ee8faf01441..13ac94899c18 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2172,7 +2172,8 @@ static int rto_next_cpu(struct root_domain *rd)
>   
>   static inline bool rto_start_trylock(atomic_t *v)
>   {
> -	return !atomic_cmpxchg_acquire(v, 0, 1);
> +	int zero = 0;
> +	return atomic_try_cmpxchg_acquire(v, &zero, 1);
>   }
>   
>   static inline void rto_start_unlock(atomic_t *v)


      reply	other threads:[~2026-04-15 18:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-15 12:40 David Carlier
2026-04-15 18:14 ` Uros Bizjak [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=27651a34-6b25-430f-8cb4-39d44b2d4c90@gmail.com \
    --to=ubizjak@gmail.com \
    --cc=bsegall@google.com \
    --cc=devnexen@gmail.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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

Powered by JetHome