From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id EB4203959C91 for ; Wed, 16 Nov 2022 11:46:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EB4203959C91 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1668599192; bh=CBMCJ/q5oVRJzW+Nn33DtzC9r8CecMjHh8hmb+b+Gg0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=lu8oxQ/coApYEVZCgftCBntOw790UPVL3/NwFP+XTQxg5L+ukoie4MSMYLowIBrPm xX+sIr5WZR5Bwzm1Xi6vaI/KMZiHMme85YbycQQ0DbuHxSAPINxSjwigWtNmxgdiab PPfyTWCR4CQsX4NxClavirK5pfAkIntSu3iA3kaY= Received: from [IPv6:240e:358:116a:f400:dc73:854d:832e:2] (unknown [IPv6:240e:358:116a:f400:dc73:854d:832e:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 360FC65CD9; Wed, 16 Nov 2022 06:46:21 -0500 (EST) Message-ID: <0390618e9d9e74eb2ea22ae8a934cbc37cd483a7.camel@xry111.site> Subject: Re: [PATCH] LoongArch: Fix atomic_exchange make comparison and may jump out From: Xi Ruoyao To: Jinyang He , Chenghua Xu , Lulu Cheng Cc: Weining Lu , Xing Li , yala , Peng Fan , gcc-patches@gcc.gnu.org Date: Wed, 16 Nov 2022 19:46:11 +0800 In-Reply-To: <1dd9ace0-a83f-c530-2d65-5f762e0cc81e@loongson.cn> References: <20221115130328.15413-1-hejinyang@loongson.cn> <8039c23568889fe85afbe6940ed625448cf6cd56.camel@xry111.site> <1dd9ace0-a83f-c530-2d65-5f762e0cc81e@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.0 MIME-Version: 1.0 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD,LIKELY_SPAM_FROM,PDS_OTHER_BAD_TLD,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 2022-11-16 at 10:11 +0800, Jinyang He wrote: > > > +=C2=A0 return "%G6\\n\\t" > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "1:\\n\\t" > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "ll.\\t%0,%1\\n\\t" > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "and\\t%7,%0,%z3\\n\\t" > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "or%i5\\t%7,%7,%5\\n\\t" > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "sc.\\t%7,%1\\n\\t" > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "beqz\\t%7,1b\\n\\t"; > > Do we need a "dbar 0x700" after beqz? > >=20 > > /* snip */ >=20 > That's worth discussing. Actually I don't see any dbar hint definition > like 0x700 in the manual right now. > Besides, I think what should be provided here is a relaxed version. And > whether the barrier exsit or not is depend on the specific memory_order. It's not related to memory order, but for a hardware issue workaround.=20 Jiaxun told me (via LKML): I had checked with Loongson guys and they confirmed that the workaround still needs to be applied to latest 3A4000 processors, including 3A4000 for MIPS and 3A5000 for LoongArch. =20 Though, the reason behind the workaround varies with the evaluation of their uArch, for GS464V based core, barrier is required as the uArch design allows regular load to be reordered after an atomic linked load, and that would break assumption of compiler atomic constraints. Without these dbar instructions I'd got random test failures in GCC libgomp test suite. We use a non-zero hint here because it is treated exactly same as zero in 3A5000, and the future LoongArch processors can fix the issue and ignore the dbar 0x700 instruction. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University