Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5611986rwb; Tue, 1 Aug 2023 05:35:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlF9v6OfMWPWNOtsP68K0atGw9zHQrjmO9VvbOo2VTXxnsceuOnjARBk6bZv/UJI7mdcflKs X-Received: by 2002:a17:907:760d:b0:99b:cdfd:fb44 with SMTP id jx13-20020a170907760d00b0099bcdfdfb44mr3217887ejc.9.1690893358524; Tue, 01 Aug 2023 05:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690893358; cv=none; d=google.com; s=arc-20160816; b=yxKSHv1RcVQYtxPHoisegQk+lJ+8eA7G62tHozQ9LfkRZth7w8PC62afvjNZVsuHyX jsdxy3GhnWfjm6mQXSbds1g3xXInnG49MyE5BgR/3/ohwdk9W06maf4Zl8URUTWp0Stj Dm2idiMj97qolGNwjKy1uDquKHr9oPPNUdmULc5zI8EiNkC8Mbc9WIb1tmR94lFDJEbT yoMn1MrUVugs58kA3Z219lXb3Gib/bPjQ5Yh15rn6R2+b6q3aOkN3kd2bhDMxRxunA7d 6X87zvDNV2/F62Awn2o14mVJ2UoQ2k+tdcIZjQazPS2ub2bagqRX/+i9E+gbv6uF1hqO KViw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=/bCn1qMcszzgb1bqqaxxSpsu5naJTKIbI0/nMPz6zJY=; fh=ywRe+jCQTLvcOrlkmjc/9McfCEfuoVoSXF4rcFIGGUg=; b=afDlZXW2/CeovjCRZdJFcYK8w8ZAkSHjDD+iZUdGZ6+uVA+U3YnqvsOD6fcpwUKm4H 15Ib6RxIAG5+KVipGDwfx1UD0nHE0pHJXAenJIWkeHC1gVeEPFykQ6ZRoUUIGmAbSYYp qzI5mkNsNRWXBDmKfztMgKKajIZYWmNu1ktjlzlwPSdP6hEkFlm1vkDJyi3qw3PJ+3mW u4GuK6FfzdSLj5rpjBFwVx1MhYerlKWITPIxkwK7vlkOWtfEpN9Lc9l4B6uON8rJ3AkO leUlK+vWlebuKXewZP7g7pEh/lzkSoZSgG/v63kaOu3Bz+T9CJtb176T9b/8ULPEHQj+ P/GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=kaeCaWOW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qu12-20020a170907110c00b00991f1e4b041si7782248ejb.737.2023.08.01.05.35.32; Tue, 01 Aug 2023 05:35:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=kaeCaWOW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231354AbjHAL2l (ORCPT + 99 others); Tue, 1 Aug 2023 07:28:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230333AbjHAL2k (ORCPT ); Tue, 1 Aug 2023 07:28:40 -0400 Received: from xry111.site (xry111.site [89.208.246.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CDC7D3 for ; Tue, 1 Aug 2023 04:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1690889319; bh=oB+m1whzA5Poc7p8CzrPGLnshdyNojzHyilFcZEUHHA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=kaeCaWOW1jSaF5FyZvKSo7L7oHxh3CidQ1yPcD2cp301VRvsumWj5bHChuN17ZOI1 KHjq/cxdK5sk116T9akLgxaun9J4wizA8uludAvNNAmy3bEC19RDuW7kwYz+BO9AC4 lVC3NEso/6lDSXfV2p3ohVYCJqt9s4pGa+5T4ong= Received: from localhost.localdomain (xry111.site [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384)) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id B09986599C; Tue, 1 Aug 2023 07:28:36 -0400 (EDT) Message-ID: <06f228ac4afce0126337ad4a8b0ade1f12c98d40.camel@xry111.site> Subject: Re: [PATCH] LoongArch: Fixup cmpxchg sematic for memory barrier From: Xi Ruoyao To: Guo Ren , WANG Rui Cc: chenhuacai@kernel.org, kernel@xen0n.name, arnd@arndb.de, andi.shyti@linux.intel.com, andrzej.hajda@intel.com, peterz@infradead.org, will@kernel.org, boqun.feng@gmail.com, mark.rutland@arm.com, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, Guo Ren Date: Tue, 01 Aug 2023 19:28:35 +0800 In-Reply-To: <44a99b78933afeb1b33d8c51487fe0673281af9b.camel@xry111.site> References: <20230801011554.3950435-1-guoren@kernel.org> <44a99b78933afeb1b33d8c51487fe0673281af9b.camel@xry111.site> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2023-08-01 at 19:23 +0800, Xi Ruoyao wrote: > On Tue, 2023-08-01 at 18:49 +0800, Guo Ren wrote: > > > On Tue, Aug 1, 2023 at 5:05=E2=80=AFPM Guo Ren wr= ote: > > > >=20 > > > > > The CoRR problem would cause wider problems than this.For this ca= se, > > > > > do you mean your LL -> LL would be reordered? > > > > >=20 > > > > > CPU 0 > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CPU1 > > > > > LL(2) (set ex-monitor) > > > > >=20 > > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 store (break the ex-monitor) > > > > > LL(1) (reordered instruction set ex-monitor > > > > > SC(3) (successes ?) > > > > Sorry for the mail client reformat, I mean: > > > >=20 > > > > CPU0=C2=A0 LL(2) (set ex-monitor) > > > > CPU1=C2=A0 STORE (break the ex-monitor) > > > > CPU0=C2=A0 LL(1) (reordered instruction set ex-monitor > > > > CPU0=C2=A0 SC(3) (success?) > > >=20 > > > No. LL and LL won't reorder because LL implies a memory barrier(thoug= h > > > not acquire semantics). > > That means we could remove __WEAK_LLSC_MB totally, right? >=20 > As I've said, to implement CAS on LA464 this barrier is *really* needed. > I initially didn't believe it then I spent one night (from 11 PM to 04 > AM) debugging GCC libgomp test failures. >=20 > On LA664 (3A6000) things may change though. And I consider this a hardware bug, so it's out of the general concept of general memory orders. We are basically just applying a workaround provided by uarch designers. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University