Re: [PATCH] io_uring: Use atomic_long_try_cmpxchg in __io_account_mem

From: Jens Axboe
Date: Thu Jul 14 2022 - 12:47:09 EST


On 7/14/22 10:33 AM, Uros Bizjak wrote:
> Use atomic_long_try_cmpxchg instead of
> atomic_long_cmpxchg (*ptr, old, new) == old in __io_account_mem.
> x86 CMPXCHG instruction returns success in ZF flag, so this
> change saves a compare after cmpxchg (and related move
> instruction in front of cmpxchg).
>
> Also, atomic_long_try_cmpxchg implicitly assigns old *ptr value
> to "old" when cmpxchg fails, enabling further code simplifications.
>
> No functional change intended.

This will be io_uring/rsrc.c for the for-next branches, but it'll apply
directly as that with a slight offset:

checking file io_uring/rsrc.c
Hunk #1 succeeded at 56 (offset -10448 lines).

I'll do that, thanks.

--
Jens Axboe