Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3566425pxf; Mon, 29 Mar 2021 05:56:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzvzSgCF6VeXryiIVNZpH2uZAuNztGmfrSttTbzLawNA97eADWyW0BFq4pvTVqzvdATK1V X-Received: by 2002:a50:fc94:: with SMTP id f20mr28530108edq.370.1617022613658; Mon, 29 Mar 2021 05:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617022613; cv=none; d=google.com; s=arc-20160816; b=TAxIXK2QQVbpPj/MBuhiCP9P+tMVA/SRY7V2G4PK9C+vI57TcoGKzQnLwM7DT/uZZp YIniBrx8t0ioaB0MDtxrpSvpRy+UBmQiSgWvKF6MvWuEPVmkqRmAauJU3R77aDN93ss0 wjJ5AQi7wA6kcmAVavYfV0WcCPwIxg0umy2zehXeenb00578XnGEcUaS+BlABENnXbvR soxAlzpEZ073ketz7na3hkqsQufVvDfRJGoF8DkphIStUJCriG6JRW6UGcR2X2lOdMg+ vMmZL7eAA4TLDzNG8JOZxxImf5VGbS+YihtBQRKm+EyOnzy/pIPjONh36QALG7KRdswS hhGw== 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=Y7bmPcMokoE/Ule7+N/yqUD5mZjrl1rPWjVXmw4Ch6U=; b=IcyXGr5ofq8+ik/nh1xJrhxu7dlArRPwFqghoq4/PAwlGY3HGAVKzw0jD2RX99BE85 WfaJZjdckktuUD6ZO6FZv0Sse38D+LsZUqW5CQ3TtRClgFzRcnE9LGyeGl5OyY/Bh/gq 4KoCul/Qgt9KSebMfPbcPxUh8roQCYSfQC24/FidVAw4YwEX7VMuKHy8YN7fKIte1NfJ DCaPLsncSasl0WoHAH1oa3M3KKLLLNWxVrm7v6oLhfuqQF5/nF/b4N6rwKmhZYvWY6FW veY2ifYdozPvfdQr9kjP/FSClGuxQ6dQE34z1eQ00BZKk1PYR5N5qjwAmOhyay2OhleF RZ7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="iy/yWInW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si13177194ejo.374.2021.03.29.05.56.31; Mon, 29 Mar 2021 05:56:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="iy/yWInW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231322AbhC2Mxm (ORCPT + 99 others); Mon, 29 Mar 2021 08:53:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:46676 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231270AbhC2MxK (ORCPT ); Mon, 29 Mar 2021 08:53:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2665A61934; Mon, 29 Mar 2021 12:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617022390; bh=ZtH+hMquy7Na1NKF/yxIB+LhxXUi37ByQKiTFk9d38U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=iy/yWInWB8DBRPxhLE7cb8nnL6SjCZMkWAdqdfKqXrpShBLHbTyVWa0wYkSN/tX5v Iu2rpPH80kkfOhq/UaN9/SA2YdB+x9RzSUizC5xp3FbagOGD5b8lWF+eiPxaQmBmsG 8mQrC67o6eRGU77PTSiyD5FqmWZB/XMtgSQ5Lr9cr8/1EInyzd3Enz3sAFQtKWMDis x3GYxZ0FAXmMllpi+MTFzy++LKlizjyA1MYaBsoE2fzmId5Zv5Q27wwu0mWOSFEudJ MXKxlcT5oSR+vVk0rlL8s5NVNMSWLEZchX3yY/jaxKeq8CZH6LQBvCanFjA1q171Om P1oxZoWMTKRBQ== Received: by mail-lf1-f41.google.com with SMTP id o10so18223327lfb.9; Mon, 29 Mar 2021 05:53:10 -0700 (PDT) X-Gm-Message-State: AOAM533cSk97HasmT8nByVThJULtDdqVPyK13bf2i1w0RLRFzSF8Li8M CVz+iN9B15UZU561UOhAEZN+6nbU59L6+hzz1NM= X-Received: by 2002:a19:f501:: with SMTP id j1mr17188294lfb.231.1617022388450; Mon, 29 Mar 2021 05:53:08 -0700 (PDT) MIME-Version: 1.0 References: <1616868399-82848-1-git-send-email-guoren@kernel.org> <1616868399-82848-4-git-send-email-guoren@kernel.org> In-Reply-To: From: Guo Ren Date: Mon, 29 Mar 2021 20:52:57 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 3/4] locking/qspinlock: Add ARCH_USE_QUEUED_SPINLOCKS_XCHG32 To: Peter Zijlstra Cc: Arnd Bergmann , linux-riscv , Linux Kernel Mailing List , linux-csky@vger.kernel.org, linux-arch , Guo Ren , Will Deacon , Ingo Molnar , Waiman Long , Anup Patel , Sebastian Andrzej Siewior Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 29, 2021 at 7:31 PM Peter Zijlstra wrote= : > > On Mon, Mar 29, 2021 at 01:16:53PM +0200, Peter Zijlstra wrote: > > Anyway, an additional 'funny' is that I suspect you cannot prove fwd > > progress of the entire primitive with any of this on. But who cares > > about details anyway.. :/ > > What's the architectural guarantee on LL/SC progress for RISC-V ? funct5 | aq | rl | rs2 | rs1 | funct3 | rd | opcode 5 1 1 5 5 3 5 7 LR.W/D ordering 0 addr width dest AMO SC.W/D ordering src addr width dest AMO LR.W loads a word from the address in rs1, places the sign-extended value in rd, and registers a reservation set=E2=80=94a set of bytes that subsumes the bytes in the addressed word. SC.W conditionally writes a word in rs2 to the address in rs1: the SC.W succeeds only if the reservation is still valid and the reservation set contains the bytes being written. If the SC.W succeeds, the instruction writes the word in rs2 to memory, and it writes zero to rd. If the SC.W fails, the instruction does not write to memory, and it writes a nonzero value to rd. Regardless of success or failure, executing an SC.W instruction *invalidates any reservation held by this hart*. More details, ref: https://github.com/riscv/riscv-isa-manual > And what if you double loop it like cmpxchg() ? Can you give a code snippet? -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/