Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp416979rwo; Tue, 1 Aug 2023 20:21:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlFLIjMapCADwYQyYZr0PScj0szrS5aGz4HhmcZCLagqgV+6MMOZKC+q2gvWLGH8KfLSWg19 X-Received: by 2002:a37:de09:0:b0:75b:23a1:362e with SMTP id h9-20020a37de09000000b0075b23a1362emr11620343qkj.63.1690946484853; Tue, 01 Aug 2023 20:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690946484; cv=none; d=google.com; s=arc-20160816; b=dFxKeExl4X7CZ3QFIajyO7g5sv3G5QjAAJShHpjZ5JQ0EQnN+S7Skm57mLIXB7hzXx BaTJPE7ECLwacT9W/EUGq3k5j8KqQrFbnoUJhHjhRLA4Y8/itD4rHrIMuIWyjFlN/8rv 4DZVIsNq4Yx5bo4FvUZiZZTwrKL0JZnUG78IF1k7ZbQVrNWwc1SC/qB6Lf1sG4tOKljd hHw7USqDd6px7A4nngqGH5e9Edt5+YnJVGJpYAyYgmWTzxsPvDYJ9f5E3c+7JEW1lQKG e6qtxgXqgMqyvDeE74FDGfzy4+5JJB+D2htba+3b4EhIIUJT98AU7MKWQfe9oLAVPOCv pmPw== 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; bh=MVAI6LOae+uGY9Z2aYi8cQf4C3oFrOZnnF2OHz8V5mo=; fh=PxxAVadtOQjMRcRmDo2Jb4n9TPl92Nihns72TrQ/54E=; b=FI0ZR7pfBYMXOYn3fq/4HlWPwSfaRixbC27PLS2L9RIUJ0/DwBxgNu2Ayahi1LR7C4 +7l5s6DGQzWzJGrbq1qBIT+rogKSpAlsj+iHfoR8JkuOpPi9YwVSkDLw+dk+aMMvE4BB GewKVqEIanPVuTf/c5jRsmDKTJFlu1D6GaDL8mPaZU/0jaegk/W7AXlqSBkznk9Woo+c N8BpmpFLpXZ1HhnAW+M1itop6yuSgefG3j3ZBRClir0w9V0QNmP2fs9J809Xg4X1JJDj r4nkowi6hUzU1hzhwNJyYU5AgUJ1US+vDKr3mZGAK9GKF+s6bmGpOeYeikwp1EBZjmkH nL7A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d2-20020a633602000000b0053ff537164fsi1146262pga.783.2023.08.01.20.21.13; Tue, 01 Aug 2023 20:21:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230317AbjHBCXi convert rfc822-to-8bit (ORCPT + 99 others); Tue, 1 Aug 2023 22:23:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230180AbjHBCXg (ORCPT ); Tue, 1 Aug 2023 22:23:36 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B1B6E213E for ; Tue, 1 Aug 2023 19:23:34 -0700 (PDT) Received: from loongson.cn (unknown [209.85.221.50]) by gateway (Coremail) with SMTP id _____8AxEvAlvslk5osOAA--.33118S3; Wed, 02 Aug 2023 10:23:33 +0800 (CST) Received: from mail-wr1-f50.google.com (unknown [209.85.221.50]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxDc8ivslkYNdEAA--.47852S3; Wed, 02 Aug 2023 10:23:32 +0800 (CST) Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-31792ac0fefso3300303f8f.2 for ; Tue, 01 Aug 2023 19:23:32 -0700 (PDT) X-Gm-Message-State: ABy/qLbR4I2Y9xu14JEkQvrrT7w0v2+IhRfEVpSbx9Ze2iXQC7+fRqK5 yCRzVGucmGjF4/bAgqBQVnVKOhiNsbZqzHTYRgxVug== X-Received: by 2002:a05:6000:11c5:b0:317:594a:dbde with SMTP id i5-20020a05600011c500b00317594adbdemr3350887wrx.20.1690943009317; Tue, 01 Aug 2023 19:23:29 -0700 (PDT) MIME-Version: 1.0 References: <20230801011554.3950435-1-guoren@kernel.org> In-Reply-To: From: WANG Rui Date: Wed, 2 Aug 2023 10:23:18 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] LoongArch: Fixup cmpxchg sematic for memory barrier To: Guo Ren 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: 8BIT X-CM-TRANSID: AQAAf8DxDc8ivslkYNdEAA--.47852S3 X-CM-SenderInfo: pzdqw2txl6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoWrtw4xtrW3tr1UKFWrKFyDArc_yoW8JrWDpr WIyFs0gFZ7Xw40ywsakw48ZFyrtwnaqF17X3sa9rZFyFyav343trW7Gry3XrsxZr93Gw1Y v3yq934FvFyDZFgCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUyEb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAF wI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxAIw28IcxkI7VAKI4 8JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xv wVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjx v20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20E Y4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267 AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8czVUUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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 Wed, Aug 2, 2023 at 7:17 AM Guo Ren wrote: > > On Tue, Aug 1, 2023 at 12:37 PM WANG Rui wrote: > > > > On Tue, Aug 1, 2023 at 6:50 PM Guo Ren wrote: > > > > > > On Tue, Aug 1, 2023 at 5:32 PM WANG Rui wrote: > > > > No. LL and LL won't reorder because LL implies a memory barrier(though > > > > not acquire semantics). > > > That means we could remove __WEAK_LLSC_MB totally, right? > > > > More precisely, __WEAK_LLSC_MB is intended to prevent reordering > > between LL and normal LD used to fetch the expected value for cmpxchg. > Oh, that's unnecessary when cmpxchg fails. > > Maybe you treat cmpxchg as a CoRR antidote in coincidence. Please > solve the CoRR problem by READ_ONCE. > > See alpha architecture. Unfortunately, the LL instruction has no acquire semantics. Even if our kernel team improves READ_ONCE, it cannot prevent reordering between LL and READ_ONCE after cmpxchg fails. LL ( + ); WEAK_LLSC_MB; READ_ONCE (); ... vs LL ( + ); READ_ONCE ( + ); ... Improving READ_ONCE is really important. Regards, -- WANG Rui