From: Uros Bizjak <ubizjak@gmail.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Uros Bizjak <ubizjak@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>, Will Deacon <will@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Boqun Feng <boqun.feng@gmail.com>,
Mark Rutland <mark.rutland@arm.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
Marco Elver <elver@google.com>
Subject: [PATCH v3 0/2] locking/atomic/x86: Introduce arch_try_cmpxchg64
Date: Sun, 15 May 2022 20:42:02 +0200 [thread overview]
Message-ID: <20220515184205.103089-1-ubizjak@gmail.com> (raw)
The followign patchset introduces generic support for try_cmpxchg64
and introduces arch_try_cmpxchg64 for 64-bit and 32-bit targets.
On 64-bit targets, the generated assembly improves from:
ab: 89 c8 mov %ecx,%eax
ad: 48 89 4c 24 60 mov %rcx,0x60(%rsp)
b2: 83 e0 fd and $0xfffffffd,%eax
b5: 89 54 24 64 mov %edx,0x64(%rsp)
b9: 88 44 24 60 mov %al,0x60(%rsp)
bd: 48 89 c8 mov %rcx,%rax
c0: c6 44 24 62 f2 movb $0xf2,0x62(%rsp)
c5: 48 8b 74 24 60 mov 0x60(%rsp),%rsi
ca: f0 49 0f b1 34 24 lock cmpxchg %rsi,(%r12)
d0: 48 39 c1 cmp %rax,%rcx
d3: 75 cf jne a4 <t+0xa4>
to:
b3: 89 c2 mov %eax,%edx
b5: 48 89 44 24 60 mov %rax,0x60(%rsp)
ba: 83 e2 fd and $0xfffffffd,%edx
bd: 89 4c 24 64 mov %ecx,0x64(%rsp)
c1: 88 54 24 60 mov %dl,0x60(%rsp)
c5: c6 44 24 62 f2 movb $0xf2,0x62(%rsp)
ca: 48 8b 54 24 60 mov 0x60(%rsp),%rdx
cf: f0 48 0f b1 13 lock cmpxchg %rdx,(%rbx)
d4: 75 d5 jne ab <t+0xab>
where a move and a compare after cmpxchg is saved. The improvements
for 32-bit targets are even more noticeable, because dual-word compare
after cmpxchg8b gets eliminated.
Changes since v2:
* Remove invalid and unnecessary cast from 32-bit arch_try_cmpxchg64.
Changes since v1:
* Implement full support for try_cmpxchg64{,_acquire,_release,_relaxed}
and their falbacks involving cmpxchg64.
* Split patch to generic and target-dependant part.
* Modernize __try_cmpxchg64 asm template with symbolic operand name.
* Use generic fallback when arch_try_cmpxchg64 is not defined.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Will Deacon <will@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Marco Elver <elver@google.com>
Uros Bizjak (2):
locking/atomic: Add generic try_cmpxchg64 support
locking/atomic/x86: Introduce arch_try_cmpxchg64
arch/x86/include/asm/cmpxchg_32.h | 21 ++++++
arch/x86/include/asm/cmpxchg_64.h | 6 ++
include/linux/atomic/atomic-arch-fallback.h | 72 ++++++++++++++++++++-
include/linux/atomic/atomic-instrumented.h | 40 +++++++++++-
scripts/atomic/gen-atomic-fallback.sh | 31 +++++----
scripts/atomic/gen-atomic-instrumented.sh | 2 +-
6 files changed, 156 insertions(+), 16 deletions(-)
--
2.35.1
next reply other threads:[~2022-05-15 18:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-15 18:42 Uros Bizjak [this message]
2022-05-15 18:42 ` [PATCH v3 1/2] locking/atomic: Add generic try_cmpxchg64 support Uros Bizjak
2022-05-17 22:21 ` [tip: locking/core] " tip-bot2 for Uros Bizjak
2022-05-15 18:42 ` [PATCH v3 2/2] locking/atomic/x86: Introduce arch_try_cmpxchg64 Uros Bizjak
2022-05-17 22:21 ` [tip: locking/core] " tip-bot2 for Uros Bizjak
2022-05-16 8:12 ` [PATCH v3 0/2] " Peter Zijlstra
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=20220515184205.103089-1-ubizjak@gmail.com \
--to=ubizjak@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=elver@google.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/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