Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5427816rwb; Tue, 1 Aug 2023 02:18:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlHjiEZwZFeZ+4MUSzgsm5H6rfDF9EIxm38cJOitRX6WMpmh/NAnjUQDgTu1Fe73F5UMNoF+ X-Received: by 2002:a17:90a:940d:b0:263:5376:b952 with SMTP id r13-20020a17090a940d00b002635376b952mr15531993pjo.9.1690881531091; Tue, 01 Aug 2023 02:18:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690881531; cv=none; d=google.com; s=arc-20160816; b=TZHheF6i7NSnNDCJJ0xz94w7YciQWhO2XSHWlP8tAGf4mwVu14VN414X6WsZpUIhkT Q01qh2N2RaEnut/v5QH88f3ZOlztl643OhRO5pn4OgpECFc7lii1hI/lDhO3JIMPqs/E jHXjnmdS4L90eZM9GVAJr9t3UPopsJMmrU3v29d0CgV0EEBS0Tvao0r5Z127UMI7mRkM DSFCtDwgEXOBy1dUSKP6/JIkmnijdJKfC9kxvmfKQkBtt4bEvKlg9qou8Z8RzJbIp4uX eBVPk8oKU3diPLl/Cg5/SEEfAz+KYcYUJ322vB++yd9IGDTHvVNWqOP38E4YcKbNPp7w tiWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/UOUp5hRuQwIYDnY0fe6fmEjx/owq/0i7iA6ehBs1+I=; fh=vAoEAjNZCjfQkEcdTrv/sg+0BydeFefaCjHXBJUqZyg=; b=IZdW0Jz5hw9KZa4Yg9hWP77+U63v0geCW2iXRYJiXkR3ggPxxO5ddYZC2L5LCYjeP6 K9wSVFpSq5cAXE4WDWjjgmrV0RFN9cP/ZwKnUYT0+7iX814NoPpSncOd8GlJXtuAcvGv ILFJyzMUMWigEKayd8ZX3UwAZ/uvLgVqNPpBuOUmUeNhpPaHRAtUMHGKtaATvD0zzauF 7Hbt5UY68miJRlKb8JNN3DVnsbJBrQa0cLTAw5BngurPMziukZ0ANaAKuNq6D+PN8jwp yFtgQVZsu5+xtc2WUs4Z7ixuaNxRzOYmhST9IGEqCTLsfZRR/ElSbbG+Q8eVW2qnqSiN 9OqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A0GTM2AE; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a63574b000000b005501b28fc02si8797887pgm.50.2023.08.01.02.18.39; Tue, 01 Aug 2023 02:18:51 -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=@kernel.org header.s=k20201202 header.b=A0GTM2AE; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbjHAJFG (ORCPT + 99 others); Tue, 1 Aug 2023 05:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232020AbjHAJEh (ORCPT ); Tue, 1 Aug 2023 05:04:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45837211B for ; Tue, 1 Aug 2023 02:03:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 30FC7614CC for ; Tue, 1 Aug 2023 09:02:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9156CC433D9 for ; Tue, 1 Aug 2023 09:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690880564; bh=yysbtRG74SbIc4kvWFf/yt8D0zmK33jlQSMHNhB2wik=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=A0GTM2AE72dpcUqSmcfOwmGqe8VJbA+nJCh8Adx7EpCoKBq5AetFc/Y2oOegRt7FQ byGONZNnIeHQ06SZWqYVbslVRMZkBnu1S3RfOl3IOvTQqyz0hS4sorNQb9jmEgUwFv ysQ4uJg6kSV0mI8JbdNKcczUURS/8Gzlx8RBPwAGbquAGl8pW2LpLMSDxZPHlTO/gX 2DfmVQDF7v+QHy1L2O4cz2nhYQHDLjxoQN2ytinUmIgp2z8aAmf9SPyKeN/sAS0m/D pYSlS0rDRzMuPZ3YLpZ5FjOMLGLXdyTWyXHJkjARFwP3MlHkVNSbTQUABOTs/JQfpc 68W8gJv/t9pDw== Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5221c6a2d3dso7777296a12.3 for ; Tue, 01 Aug 2023 02:02:44 -0700 (PDT) X-Gm-Message-State: ABy/qLa5yCaH5azr3TYneM0H8N7hNvEcLo+SXVNyrDxPKWSB+8k9RzWD +7jxd4t2bG8lE4x8Hrtq1uTOp2S3dn2GCWIc9Ec= X-Received: by 2002:a17:907:2718:b0:99b:415f:2e4f with SMTP id w24-20020a170907271800b0099b415f2e4fmr1895566ejk.57.1690880562621; Tue, 01 Aug 2023 02:02:42 -0700 (PDT) MIME-Version: 1.0 References: <20230801011554.3950435-1-guoren@kernel.org> In-Reply-To: From: Guo Ren Date: Tue, 1 Aug 2023 17:02:31 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] LoongArch: Fixup cmpxchg sematic for memory barrier To: WANG Rui Cc: chenhuacai@kernel.or, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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, Aug 1, 2023 at 10:29=E2=80=AFAM WANG Rui wrot= e: > > Hello, > > On Tue, Aug 1, 2023 at 9:16=E2=80=AFAM wrote: > > diff --git a/arch/loongarch/include/asm/cmpxchg.h b/arch/loongarch/incl= ude/asm/cmpxchg.h > > index 979fde61bba8..6a05b92814b6 100644 > > --- a/arch/loongarch/include/asm/cmpxchg.h > > +++ b/arch/loongarch/include/asm/cmpxchg.h > > @@ -102,8 +102,8 @@ __arch_xchg(volatile void *ptr, unsigned long x, in= t size) > > " move $t0, %z4 \n" = \ > > " " st " $t0, %1 \n" = \ > > " beqz $t0, 1b \n" = \ > > - "2: \n" = \ > > __WEAK_LLSC_MB = \ > > + "2: \n" = \ > > Thanks for the patch. > > This would look pretty good if it weren't for the special memory > barrier semantics of the LoongArch's LL and SC instructions. > > The LL/SC memory barrier behavior of LoongArch: > > * LL: + > * SC: + > > and the LoongArch's weak memory model allows load/load reorder for the > same address. The CoRR problem would cause wider problems than this.For this case, do you mean your LL -> LL would be reordered? CPU 0 CPU1 LL(2) (set ex-monitor) store (break the ex-monitor) LL(1) (reordered instruction set ex-monitor SC(3) (successed ?) > > So, the __WEAK_LLSC_MB[1] is used to prevent load/load reorder and no > explicit barrier instruction is required after SC. > > [1] https://lore.kernel.org/loongarch/20230516124536.535343-1-chenhuacai@= loongson.cn/ > > Regards, > -- > WANG Rui > --=20 Best Regards Guo Ren