Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5435126rwb; Tue, 1 Aug 2023 02:28:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlHUi+fXcdNKygqGaaecZYk5FIVFAtlxpMFs7e5rNkHzfmrASzzAieHgUgV7NmO1Azbhx158 X-Received: by 2002:a05:6402:883:b0:522:40dd:74f3 with SMTP id e3-20020a056402088300b0052240dd74f3mr1850454edy.39.1690882094228; Tue, 01 Aug 2023 02:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690882094; cv=none; d=google.com; s=arc-20160816; b=a+DnHuuESdYgd3BTYpi6T3t8UHMZPjwgxuyiWQDSjAQ4WwFyCC0djRyzJbODqDyKsN 4VnrzyCHxf1GOFlUaZZB9ITjTI+JTZ30PtnB5L0UOoKqWeETdAY58U4l9lf4t+xo/S54 R3vNLInlV6vqsz1xzyIZBmn9STJR6Mm30Dope9HtXgo72IoBp8ktRFsPpNe4Na4xeu5I qlURuXPJ8L92n+TXx30ITGIGTSkKvXAvmX6RbV1B0E3IQC7w7M9NDAZ4j691Dki8SPNa MWaGnuwVkovfK5lFdzZZ+3grncgKpAa8HCd9o5b2lb6xkStv2sPhassIs4YsiURbfzvP w9tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zoagUS3nEiE16vxzBK1vRglCfWXT16TuZFBjSpM/4j0=; fh=OOwsKa1ux60+RtWlDJsUvKE3bxOxmOg/AcGNI/+tNeg=; b=CNJ10MQIhgTn7srfns6WdELLZ6zyzcg8HyXY6BIT1oq8dU50N2jwdxp2b0M4Jye1FF tvrbO69mf7tatozQNsWiBo689ngYOHmc6CV1dNveb7ImiNeahxQwUdlistYVePiiql5H KLmwI7fY1ON/QhaisqmxxkoP1nDPMVFNvJ4meQUUk7ApMbAOxNdaBb21lYZ36IUAXX2A VK2rcDW8GJDKq7rFtyWxWYSzuy9MscH9bjxaZzqT+K1/mteAkJzRNpeulo72nJV2SmEo ej/4pjlA1U2CFfVq92zVbom9XKjCLxYV7ChwDqlestTpKQgY8OoSF01mfmywDfHC9TVS CPnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uzaEGkj4; 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 b9-20020aa7dc09000000b00522188efd8dsi4831657edu.605.2023.08.01.02.27.50; Tue, 01 Aug 2023 02:28:14 -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=uzaEGkj4; 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 S230273AbjHAIcT (ORCPT + 99 others); Tue, 1 Aug 2023 04:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbjHAIcP (ORCPT ); Tue, 1 Aug 2023 04:32:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 070811FD5 for ; Tue, 1 Aug 2023 01:32:09 -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 26F40614B0 for ; Tue, 1 Aug 2023 08:32:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15A4FC433C7; Tue, 1 Aug 2023 08:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690878728; bh=iZGZK3Q0OU2nHxrf6A9XxGLtvvmQD2q0xRwNAp6LqtM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uzaEGkj4vdv1kPHN4VKD33S2lWcjHg6YUUZQMWugr6l57bVhMPHPuQbgXoZZM2KRy bHJmvPMiOCCZhgzV7J/SkfXt2HaV3WRTFcFbLfxCFAYUuegGnnMSnyyFyrz5nsu9xA Wb8jYvdvfDiXMI95bmNi8fQZw2Ds2/zPBTXLSGU4todXYS6vvlalsT+2bJIoeM3uVw H6lAeVG4gWNrjAGqP57+zfrB3RQUs1diEErJMbgs53llmeXanEP2qOzLLXnKLVizt9 lR+8WTljUrnXre2fJ7M1xbitG9V632wx3lfOElPraWmqQwUTPqZRQSy+99VJ+qSkTy rQxBnDcAQKxfQ== Date: Tue, 1 Aug 2023 09:32:02 +0100 From: Will Deacon To: WANG Rui Cc: guoren@kernel.org, chenhuacai@kernel.or, kernel@xen0n.name, arnd@arndb.de, andi.shyti@linux.intel.com, andrzej.hajda@intel.com, peterz@infradead.org, boqun.feng@gmail.com, mark.rutland@arm.com, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, Guo Ren Subject: Re: [PATCH] LoongArch: Fixup cmpxchg sematic for memory barrier Message-ID: <20230801083201.GB26036@willie-the-truck> References: <20230801011554.3950435-1-guoren@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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 01, 2023 at 10:29:31AM +0800, WANG Rui wrote: > On Tue, Aug 1, 2023 at 9:16 AM wrote: > > diff --git a/arch/loongarch/include/asm/cmpxchg.h b/arch/loongarch/include/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, int 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. Hmm, somehow this one passed me by, but I think that puts you in the naughty corner with Itanium. It probably also means your READ_ONCE() is broken, unless the compiler emits barriers for volatile reads (like ia64)? Will