public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: akpm@linux-foundation.org, kexec@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Eric Biederman <ebiederm@xmission.com>
Subject: Re: [PATCH] kexec: Use atomic_try_cmpxchg_acquire() in kexec_trylock()
Date: Mon, 22 Jul 2024 18:30:36 +0800	[thread overview]
Message-ID: <Zp40zOw+E1Na/Lly@MiWiFi-R3L-srv> (raw)
In-Reply-To: <CAFULd4Y8vhcTWG-eNMSLEJHR_1=LuQzKj7q4JX8Kv7auJKAYDQ@mail.gmail.com>

On 07/22/24 at 10:53am, Uros Bizjak wrote:
> On Mon, Jul 22, 2024 at 5:09 AM Baoquan He <bhe@redhat.com> wrote:
> >
> > On 07/19/24 at 12:38pm, Uros Bizjak wrote:
> > > Use atomic_try_cmpxchg_acquire(*ptr, &old, new) instead of
> > > atomic_cmpxchg_acquire(*ptr, old, new) == old in kexec_trylock().
> > > x86 CMPXCHG instruction returns success in ZF flag, so
> > > this change saves a compare after cmpxchg.
> >
> > Seems it can simplify code even though on non-x86 arch, should we
> > replace atomic_try_cmpxchg_acquire() with atomic_try_cmpxchg_acquire()
> > in all similar places?
> 
> Yes, the change is beneficial also for non-x86 architectures, please
> see analysis at thread [1]. I've been looking through the kernel
> sources for these places for quite some time, and I believe I have
> changed most of the places. The change is relatively straightforward,
> and immediately results in a better code.
> 
> [1] https://lore.kernel.org/lkml/871qwgmqws.fsf@mpe.ellerman.id.au/

Good to know, thanks for telling.


      reply	other threads:[~2024-07-22 10:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19 10:38 [PATCH] kexec: Use atomic_try_cmpxchg_acquire() in kexec_trylock() Uros Bizjak
2024-07-22  3:09 ` Baoquan He
2024-07-22  8:53   ` Uros Bizjak
2024-07-22 10:30     ` Baoquan He [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=Zp40zOw+E1Na/Lly@MiWiFi-R3L-srv \
    --to=bhe@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ubizjak@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