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]
Date: Mon, 15 Apr 2024 22:12:19 +0200
From: Borislav Petkov <bp@...en8.de>
To: Uros Bizjak <ubizjak@...il.com>
Cc: linux-kernel@...r.kernel.org, linux-tip-commits@...r.kernel.org,
	Ingo Molnar <mingo@...nel.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Waiman Long <longman@...hat.com>, x86@...nel.org
Subject: Re: [tip: locking/core] locking/atomic/x86: Introduce
 arch_try_cmpxchg64_local()

On Sun, Apr 14, 2024 at 08:46:39PM -0000, tip-bot2 for Uros Bizjak wrote:
> The following commit has been merged into the locking/core branch of tip:
> 
> Commit-ID:     d26e46f6bf329cfcc469878709baa41d3bfc7cc3
> Gitweb:        https://git.kernel.org/tip/d26e46f6bf329cfcc469878709baa41d3bfc7cc3
> Author:        Uros Bizjak <ubizjak@...il.com>
> AuthorDate:    Sun, 14 Apr 2024 18:12:43 +02:00
> Committer:     Ingo Molnar <mingo@...nel.org>
> CommitterDate: Sun, 14 Apr 2024 22:40:54 +02:00
> 
> locking/atomic/x86: Introduce arch_try_cmpxchg64_local()
> 
> Introduce arch_try_cmpxchg64_local() for 64-bit and 32-bit targets
> to improve code using cmpxchg64_local().  On 64-bit targets, the
> generated assembly improves from:
> 
>     3e28:	31 c0                	xor    %eax,%eax
>     3e2a:	4d 0f b1 7d 00       	cmpxchg %r15,0x0(%r13)
>     3e2f:	48 85 c0             	test   %rax,%rax
>     3e32:	0f 85 9f 00 00 00    	jne    3ed7 <...>
> 
> to:
> 
>     3e28:	31 c0                	xor    %eax,%eax
>     3e2a:	4d 0f b1 7d 00       	cmpxchg %r15,0x0(%r13)
>     3e2f:	0f 85 9f 00 00 00    	jne    3ed4 <...>
> 
> where a TEST instruction after CMPXCHG is saved.  The improvements
> for 32-bit targets are even more noticeable, because double-word
> compare after CMPXCHG8B gets eliminated.
> 
> Signed-off-by: Uros Bizjak <ubizjak@...il.com>
> Signed-off-by: Ingo Molnar <mingo@...nel.org>
> Cc: Linus Torvalds <torvalds@...ux-foundation.org>
> Cc: Waiman Long <longman@...hat.com>
> Link: https://lore.kernel.org/r/20240414161257.49145-1-ubizjak@gmail.com
> ---
>  arch/x86/include/asm/cmpxchg_32.h | 34 ++++++++++++++++++++++++++++++-
>  arch/x86/include/asm/cmpxchg_64.h |  6 +++++-
>  2 files changed, 40 insertions(+)

Ok, maybe I'm missing the point here or maybe the commit message doesn't
explain but how does this big diffstat justify one less insn?

And no, 32-bit doesn't matter.

This looks like too crazy micro-optimization to me to be worth the 40
insertions.

But I could be wrong and I'd gladly read explanations for why I am.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ