[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFULd4Y8vhcTWG-eNMSLEJHR_1=LuQzKj7q4JX8Kv7auJKAYDQ@mail.gmail.com>
Date: Mon, 22 Jul 2024 10:53:45 +0200
From: Uros Bizjak <ubizjak@...il.com>
To: Baoquan He <bhe@...hat.com>
Cc: akpm@...ux-foundation.org, kexec@...ts.infradead.org,
linux-kernel@...r.kernel.org, Eric Biederman <ebiederm@...ssion.com>
Subject: Re: [PATCH] kexec: Use atomic_try_cmpxchg_acquire() in kexec_trylock()
On Mon, Jul 22, 2024 at 5:09 AM Baoquan He <bhe@...hat.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/
>
> For this one,
>
> Acked-by: Baoquan He <bhe@...hat.com>
Thanks,
Uros.
Powered by blists - more mailing lists