lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241025080200.GD14555@noisy.programming.kicks-ass.net>
Date: Fri, 25 Oct 2024 10:02:00 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Uros Bizjak <ubizjak@...il.com>
Cc: linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
	Will Deacon <will@...nel.org>, Waiman Long <longman@...hat.com>,
	Boqun Feng <boqun.feng@...il.com>
Subject: Re: [PATCH] locking/osq_lock: Use atomic_try_cmpxchg_release() in
 osq_unlock()

On Tue, Oct 01, 2024 at 01:45:57PM +0200, Uros Bizjak wrote:
> Replace this pattern in osq_unlock():
> 
>     atomic_cmpxchg(*ptr, old, new) == old
> 
> ... with the simpler and faster:
> 
>     atomic_try_cmpxchg(*ptr, &old, new)
> 
> The x86 CMPXCHG instruction returns success in the ZF flag,
> so this change saves a compare after the CMPXCHG.  The code
> in the fast path of osq_unlock() improves from:
> 
>  11b:	31 c9                	xor    %ecx,%ecx
>  11d:	8d 50 01             	lea    0x1(%rax),%edx
>  120:	89 d0                	mov    %edx,%eax
>  122:	f0 0f b1 0f          	lock cmpxchg %ecx,(%rdi)
>  126:	39 c2                	cmp    %eax,%edx
>  128:	75 05                	jne    12f <...>
> 
> to:
> 
>  12b:	31 d2                	xor    %edx,%edx
>  12d:	83 c0 01             	add    $0x1,%eax
>  130:	f0 0f b1 17          	lock cmpxchg %edx,(%rdi)
>  134:	75 05                	jne    13b <...>
> 
> Signed-off-by: Uros Bizjak <ubizjak@...il.com>

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ