From: Xi Ruoyao <xry111@xry111.site>
To: George Guo <dongtai.guo@linux.dev>, hev <r@hev.cc>
Cc: Huacai Chen <chenhuacai@kernel.org>,
WANG Xuerui <kernel@xen0n.name>,
loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
George Guo <guodongtai@kylinos.cn>
Subject: Re: [PATCH v2 1/2] LoongArch: Add 128-bit atomic cmpxchg support
Date: Tue, 25 Nov 2025 11:04:03 +0800 [thread overview]
Message-ID: <d35ea927d520569ac8b7482f5fedbe916005ff83.camel@xry111.site> (raw)
In-Reply-To: <20251125104316.00001294@linux.dev>
On Tue, 2025-11-25 at 10:43 +0800, George Guo wrote:
> > > + "=ZB" (__ptr[0])
> > > \
> >
> > "ZB" isn't a legal constraint for the address operand in sc.q. When
> > assembled, it turns into something like sc.q $r,$r,$r,0, which clearly
> > doesn't match the instruction format, yet gas happily accepts it wheil
> > clang rightfully rejects it. Classic GNU-as leniency biting again. :)
I clearly remember when Jiajie submitted the sc.q support to GAS
Qinggang was really insistent on supporting the additional ",0" here.
But I don't really understand why we must support it...
>
> Thanks for your advice, I tried sc.q with r or ZC. the result as
> below: (with gcc 14.2.1 in fedora-42)
> - sc.q with "r" caused system hang
It won't work because it'll pass the value (not address) of __ptr[0].
> - sc.q with "ZC" caused compiler error:
> {standard input}: Assembler messages:
> {standard input}:10037: Fatal error: Immediate overflow.
It won't work because the only accepted immediate of sc.q is 0, but ZC
would allow any factor of 4 in [-32768, 32768). I.e. ZC is for
{ldptr,stptr,ll,sc}.{w,d}.
As ZB is only used for sc.q (yet) in GCC backend maybe we can change ZB
to print simply $rX instead of $rX,0 and make LLVM do the same. Would
someone submit a GCC patch for that? Or is there already such a
constraint but I don't know?
BTW for the barrier between ll.d and ld.d, "dbar 0x700" is enough to
order two loads on the same address, and a Loongson hardware engineer
just confirmed me privately that "same address" can be read as "in the
same cacheline" here. Thus it's enough in our case and it has a lower
overhead than "dbar 0".
--
Xi Ruoyao <xry111@xry111.site>
next prev parent reply other threads:[~2025-11-25 3:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-24 9:26 [PATCH v2 0/2] LoongArch: Add 128-bit atomic cmpxchg support (v2) George Guo
2025-11-24 9:26 ` [PATCH v2 1/2] LoongArch: Add 128-bit atomic cmpxchg support George Guo
2025-11-24 11:37 ` hev
2025-11-25 2:43 ` George Guo
2025-11-25 3:04 ` Xi Ruoyao [this message]
[not found] ` <b5de6a2e-a700-4687-b483-2d60e309de25@loongson.cn>
2025-11-25 8:01 ` Xi Ruoyao
2025-11-25 3:32 ` hev
2025-11-24 9:26 ` [PATCH v2 2/2] LoongArch: Enable 128-bit atomics " George Guo
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=d35ea927d520569ac8b7482f5fedbe916005ff83.camel@xry111.site \
--to=xry111@xry111.site \
--cc=chenhuacai@kernel.org \
--cc=dongtai.guo@linux.dev \
--cc=guodongtai@kylinos.cn \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=r@hev.cc \
/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
all inboxes | Powered by JetHome®