From: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
To: 70474@debbugs.gnu.org
Subject: bug#70474: [PATCH] Move the spin loop target to the LDAXR instruction.
Date: Mon, 22 Apr 2024 10:18:46 +0200 [thread overview]
Message-ID: <35ead1ce-582e-4378-b894-c9ca1deb8cc2@leastfixedpoint.com> (raw)
In-Reply-To: <825897f1-19fa-4f6a-b459-8db93791d1c3@leastfixedpoint.com>
Oh man. This little patch all by itself makes the problem behaviour go
away. No switching to SWPAL/CASAL, just tightening the spinloop. (And no
changes at all to the CAS code, so nothing to do with the fibers bug I
guess.)
With the patch, the spinloop goes LDAXR-STLXR-CBNZ (which is what GCC
does when SWPAL isn't there) instead of potentially MOV-LDAXR-STLXR-CBNZ
(which isn't).
Could the machine really be so sensitive to the target of the CBNZ?
---
libguile/lightening/lightening/aarch64-cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libguile/lightening/lightening/aarch64-cpu.c
b/libguile/lightening/lightening/aarch64-cpu.c
index 13aa351e9..4df712a0e 100644
--- a/libguile/lightening/lightening/aarch64-cpu.c
+++ b/libguile/lightening/lightening/aarch64-cpu.c
@@ -2532,10 +2532,10 @@ str_atomic(jit_state_t *_jit, int32_t loc,
int32_t val)
static void
swap_atomic(jit_state_t *_jit, int32_t dst, int32_t loc, int32_t val)
{
- void *retry = jit_address(_jit);
int32_t result = jit_gpr_regno(get_temp_gpr(_jit));
int32_t val_or_tmp = dst == val ? jit_gpr_regno(get_temp_gpr(_jit))
: val;
movr(_jit, val_or_tmp, val);
+ void *retry = jit_address(_jit);
LDAXR(_jit, dst, loc);
STLXR(_jit, val_or_tmp, loc, result);
jit_patch_there(_jit, bnei(_jit, result, 0), retry);
--
2.44.0
next prev parent reply other threads:[~2024-04-22 8:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-19 10:54 bug#70474: Possible bug with `atomic-box-swap!` on OSX/M3 (?!?!) Tony Garnock-Jones
2024-04-19 12:14 ` bug#70474: Also manifests on an M1 running 14.1.1 and with newer Guile versions Tony Garnock-Jones
2024-04-19 13:19 ` bug#70474: Possible bug with `atomic-box-swap!` on OSX/M3 (?!?!) Christopher Baines
2024-04-19 20:46 ` bug#70474: [PATCH 1/2] Including the cast makes Apple clang 15.0.0 happy; without it, clang is sad Tony Garnock-Jones
2024-04-19 20:48 ` bug#70474: [PATCH 2/2] Replace aarch64 CAS and atomic-swap generated JIT code with CASAL and SWPAL instructions Tony Garnock-Jones
2024-04-22 7:52 ` bug#70474: Just adding DMB doesn't help Tony Garnock-Jones
2024-04-22 8:18 ` Tony Garnock-Jones [this message]
2024-04-22 11:23 ` bug#70474: [PATCH] Move the spin loop target to the LDAXR instruction Tony Garnock-Jones
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=35ead1ce-582e-4378-b894-c9ca1deb8cc2@leastfixedpoint.com \
--to=tonyg@leastfixedpoint.com \
--cc=70474@debbugs.gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).