Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp894430pxp; Wed, 16 Mar 2022 20:27:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTh3iE73WF9Xw0XIGVdQ/RnnXUgOA2huRUQ2sXTdUjNIMDrkxOv5wVsZISPMxsU11hXmEM X-Received: by 2002:a17:90b:4c87:b0:1bf:7ff7:4f39 with SMTP id my7-20020a17090b4c8700b001bf7ff74f39mr13598708pjb.163.1647487669223; Wed, 16 Mar 2022 20:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647487669; cv=none; d=google.com; s=arc-20160816; b=hxrF7YZt83pBolBXP3bZzX9HP0F4ScTtO8KszVm9r064FtsuMgEKpXvZfuyyXt3p8E Bits5oerNI+rGV0loqB0ZTUwcXnDYn/wFW3MBIaDexVKJQt7Colx4zd1daUpq/9Ab3ho krMayg7ix0ZwwnFHtOzUtYrbrNvz4q2wp5iTnItR86APWWKmXv7leVW6PsojPoiVlkum Wsg1VVK5ER6bPlF9Q19i0ql2VRE2F71GWxE/7x12fy++5fdIIzWZtAdSgFgPowukiktX DajcohxFTCSlLzis2D5ISX/JoP0LcPbhkMM2gr4jrott5NJQ9gm6h63afHYvP1PApO4n HX+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:cc:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject :dkim-signature; bh=ofUFlPn1fFr6Pz05IWJLvQM8LyheEnwZgHIcbcC4aPw=; b=hSKl/d7piqCNtAf0VtMkTiXy3EYaIxETgxXkhCFTMO2QIxwcJn9nlEOZm1/9/HPKkO W6DsW+X/Ru4lW2RMTr4NR9zd1T84wBhRwTcaxkFeFQoMn5UVhsj/+srt3BxzuZrYuP1p Jt/7DvZ4piqRleHqXoq+CR77xP/IlGX1IRarWhRBZDwh1AaLvy2vccXFTICDxeIZU3mL wIl5fgRMdBEIUp5DzKQFc95nRC+eieSaSKAEANHU3pKpbHUoPU8YCkYKLe9n/tzH+QAJ jknHEf57HFMq3rO1tXpaxzUE2Rsgz1TWDPQ+EXCOKUaWyIfjH/kLkzR+YIls93qedhBJ qaGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=S5EoqvKo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bb2-20020a17090b008200b001c6519543a4si1138867pjb.48.2022.03.16.20.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 20:27:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=S5EoqvKo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DDC1836B53; Wed, 16 Mar 2022 20:26:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346799AbiCPX3u (ORCPT + 99 others); Wed, 16 Mar 2022 19:29:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346164AbiCPX3m (ORCPT ); Wed, 16 Mar 2022 19:29:42 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20640167CA for ; Wed, 16 Mar 2022 16:28:26 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id z16so5409261pfh.3 for ; Wed, 16 Mar 2022 16:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding:cc:from:to; bh=ofUFlPn1fFr6Pz05IWJLvQM8LyheEnwZgHIcbcC4aPw=; b=S5EoqvKolpNViVFVC6Nzsj4aBgAWTlxXUWEEMY7p3wEb0057ehZpzaUnP8f4GDTFJs zse0vx0vaol845GXW+EPh58H5hafan3CLwS2NebIMBjef8U0HNWEx3yRz3jPiV3uJlEC YXWJrMiwVe+oiaYZPhnxkOPG0gNmZ72sB2JgKC7u3KkkHP6Mrza8LqpBn+wgIhU0+wXO eiGMxzeY0dkF1fMYunyzzQlM6whMlxgT8yXppR7Shy3VF4INxmMTGDdTecXUZiBbWpJi KxadBRMOObu8VavJ+IpQtZPAu2dQ5o1nwyDfes8oJeqdvEAFgSJuP+TqCD4jDajWtIKl w7BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:cc:from:to; bh=ofUFlPn1fFr6Pz05IWJLvQM8LyheEnwZgHIcbcC4aPw=; b=BL22UWWYq/R1FVs33xjBhAAQnjSTPTpeQdrWG5KZmMXmZYZD/IIV3h2OesYq5Bu84c L8aLDtKxMTctvwXH7OkiJyK5ehrsngCPHlqStn8w6k5f4quxcGsmdYXvVAYKMsHLAHp7 ajBvJ8pUrPlgqIRpZoMScMmu5tOdzDR1IM5DJLuNzI10EB3efrQp+M0hpwyqgBPe1W4p Oo07hpu8WEZREk8GhjR1le/whZneu9vHfo011RfMJS2RlT/+n0xoY5dtUDSvyiLqn+VL FHR+bY/YkkR6LyGRhmO6LBY74Ift/tTzdkiy8bSFS2ch42Uj/UbsKjfkF/KejnzxyHrg VdLA== X-Gm-Message-State: AOAM531UEYfomkb3TMjnc0ZjVOBpW6YTHbQfSudxGRSNUCWR1YvLv6Og fq7FYR1OANm9T1avUABo9eKjtA== X-Received: by 2002:a63:5855:0:b0:380:a9f7:e373 with SMTP id i21-20020a635855000000b00380a9f7e373mr1418979pgm.557.1647473305604; Wed, 16 Mar 2022 16:28:25 -0700 (PDT) Received: from localhost ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id l186-20020a633ec3000000b003820485172asm145763pga.65.2022.03.16.16.28.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 16:28:25 -0700 (PDT) Subject: [PATCH 1/5] asm-generic: qspinlock: Indicate the use of mixed-size atomics Date: Wed, 16 Mar 2022 16:25:56 -0700 Message-Id: <20220316232600.20419-2-palmer@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220316232600.20419-1-palmer@rivosinc.com> References: <20220316232600.20419-1-palmer@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, mingo@redhat.com, Will Deacon , longman@redhat.com, boqun.feng@gmail.com, Paul Walmsley , Palmer Dabbelt , aou@eecs.berkeley.edu, Arnd Bergmann , jszhang@kernel.org, wangkefeng.wang@huawei.com, openrisc@lists.librecores.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, Palmer Dabbelt From: Palmer Dabbelt To: linux-riscv@lists.infradead.org, peterz@infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Peter Zijlstra The qspinlock implementation depends on having well behaved mixed-size atomics. This is true on the more widely-used platforms, but these requirements are somewhat subtle and may not be satisfied by all the platforms that qspinlock is used on. Document these requirements, so ports that use qspinlock can more easily determine if they meet these requirements. Signed-off-by: Palmer Dabbelt --- I have specifically not included Peter's SOB on this, as he sent his original patch without one. --- include/asm-generic/qspinlock.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/asm-generic/qspinlock.h b/include/asm-generic/qspinlock.h index d74b13825501..a7a1296b0b4d 100644 --- a/include/asm-generic/qspinlock.h +++ b/include/asm-generic/qspinlock.h @@ -2,6 +2,36 @@ /* * Queued spinlock * + * A 'generic' spinlock implementation that is based on MCS locks. An + * architecture that's looking for a 'generic' spinlock, please first consider + * ticket-lock.h and only come looking here when you've considered all the + * constraints below and can show your hardware does actually perform better + * with qspinlock. + * + * + * It relies on atomic_*_release()/atomic_*_acquire() to be RCsc (or no weaker + * than RCtso if you're power), where regular code only expects atomic_t to be + * RCpc. + * + * It relies on a far greater (compared to ticket-lock.h) set of atomic + * operations to behave well together, please audit them carefully to ensure + * they all have forward progress. Many atomic operations may default to + * cmpxchg() loops which will not have good forward progress properties on + * LL/SC architectures. + * + * One notable example is atomic_fetch_or_acquire(), which x86 cannot (cheaply) + * do. Carefully read the patches that introduced queued_fetch_set_pending_acquire(). + * + * It also heavily relies on mixed size atomic operations, in specific it + * requires architectures to have xchg16; something which many LL/SC + * architectures need to implement as a 32bit and+or in order to satisfy the + * forward progress guarantees mentioned above. + * + * Further reading on mixed size atomics that might be relevant: + * + * http://www.cl.cam.ac.uk/~pes20/popl17/mixed-size.pdf + * + * * (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P. * (C) Copyright 2015 Hewlett-Packard Enterprise Development LP * -- 2.34.1