Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp28213lfe; Fri, 15 Apr 2022 17:52:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2CbvzL3PmJg/GFUL0FOag19DHD6+2dvJsrMAou+guD1le5FPN6jb0HG+9uVA9QABC/kdA X-Received: by 2002:a17:90a:8417:b0:1c7:85c9:96b1 with SMTP id j23-20020a17090a841700b001c785c996b1mr1543235pjn.8.1650070377363; Fri, 15 Apr 2022 17:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650070377; cv=none; d=google.com; s=arc-20160816; b=VX609KrnzI5TLB4LdV2CIxotQ3qPqSFt4VipwKLcw/Sf/BC91MPY4I8kFGTq50SFDb 2SR+c+UY8VhdM5gm3D/j+YeVoinbHjhgbDbIGcvaVylsPv6pz95BPsEr5jQFVVeBLLbZ J9Jb7Nx+qVJUGWWmxMYBSqysL5nNQaFWIp+H6Dwa4tjrqPKma7c6yaOxObQ2AC31MVXb ZZKKgPuKQlAucdAhgUiyOfrSjZJwPwX5PYwjIugLjTsGhjIDGuyzvGgGxjjn86ODfoS4 G5cu+PWZFIL5sl1bULZ2MtSRw5Y5AxjlV5bY9W5B8a3r3ILBNdsS6xAVRstxyqJzDh5/ gqDw== 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=z18FUB9s7KBEskqVTf7aP0q/WSmapl+AGV7tm/Rzx+w=; b=O177GBxnnX32NynNNWItzyji3jVC9showdiK3SXAQLOTHx8RlnHS+kUjtfVAX+qdlG xUliYP4Gy2J4IBKHvoGwX3jrOQ6dtk7yuCnWh5DSKaSmuI0XVGjF/eU0WWOn/c4l08xu nhLTry4rBSMsXyM9oSQuGjYvImDSIY7rROcAt8y/6hLyuBlKVCySMGBuc4z4P9FFSHb3 29ZWF3gbzMQOPJJ0citXN6Ylf69onyEerkUsYgqZD/guQ7wDyFfOvSXZnCiTFdh3FR+U CZ7M67pWfujNgQ+Cr1asgrMgh+eNhmodzBiwIjetrBn0d3DmM9Uk+DqJmX0d4M6tDekb J5lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=4yj8GNYw; 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 h32-20020a631220000000b00399563035e3si2455392pgl.809.2022.04.15.17.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:52:57 -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=4yj8GNYw; 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 8F867644D0; Fri, 15 Apr 2022 17:39:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343941AbiDNWH4 (ORCPT + 99 others); Thu, 14 Apr 2022 18:07:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244210AbiDNWHp (ORCPT ); Thu, 14 Apr 2022 18:07:45 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 893E1AD13B for ; Thu, 14 Apr 2022 15:05:17 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id t13so5926818pgn.8 for ; Thu, 14 Apr 2022 15:05:17 -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=z18FUB9s7KBEskqVTf7aP0q/WSmapl+AGV7tm/Rzx+w=; b=4yj8GNYwMFBt5S0TCYDexDsiDgZ+CphToZcr69BGb+YO1dX8XzN0DW+MGc/xCJDeXb Hcz0uIdoJnuNbkWJiV2+Fo3CA8vLW0C1IgS1CVVzH9aUg5j68NMCEbjwNgdXnkv7fEqz F6CZHlw5j34X9Ls84Zrx86UjvsRc7ZpFw0TYHUhHn1yyKX3+gl4msFSRvBIaTAhSTZdL 2YApeozR+Yfgpu19kZ4rinoHRC5MkmRhG0bqlbbT5bTMnVca/5C3iwU5CORogN7li9gJ eSftO1vHZa891P1ksAqxpAa0QJfvz+pd7dN+ERBzaFvvo1jYWPruym4OXs80BdrcFNBg 2lPw== 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=z18FUB9s7KBEskqVTf7aP0q/WSmapl+AGV7tm/Rzx+w=; b=LvNfCYN1qJJavqtCGYfawlDrApdnC8ZQQdtI5do4MDqVPBGMILwt2gaaYIrKOO7JUs LGk2aSgBJieKzVn5RDPBy4PSvZjXIDjx0EkZ5LcnhLM2jvx6ENzk8KuO9+5w95+tjDi4 AI1Myyj0As3rV8tC7IznmrFNp5Fj2JMBF9g49JVEkjFo4k31aREhx/EJ5J1lpJ18f8Hn GZ7z2n494odGSyz2EDb83QG77IGYeI4iy8aIygaQ1f04bqY5ZSeYiKiE1wqRF3TqduLX sspjfjSnAlrKea51D29Y85ThaR0+xQuv+MMgDJHrOsfaOs/ydHH+3rrUusXOWF1f4vNA 5O1A== X-Gm-Message-State: AOAM531Or9f2OjQ9T+1nY+FFtzDPOLCZo1vBy2SFouzvOvJZxcmr/eiS diQVqCee7T3YpwFgFidsfXf0Cg== X-Received: by 2002:a05:6a00:1a06:b0:4fc:d6c5:f3d7 with SMTP id g6-20020a056a001a0600b004fcd6c5f3d7mr5841959pfv.53.1649973916890; Thu, 14 Apr 2022 15:05:16 -0700 (PDT) Received: from localhost ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id n19-20020a635c53000000b0039dc2ea9876sm2697213pgm.49.2022.04.14.15.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 15:05:16 -0700 (PDT) Subject: [PATCH v3 2/7] asm-generic: qspinlock: Indicate the use of mixed-size atomics Date: Thu, 14 Apr 2022 15:02:09 -0700 Message-Id: <20220414220214.24556-3-palmer@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220414220214.24556-1-palmer@rivosinc.com> References: <20220414220214.24556-1-palmer@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: peterz@infradead.org, mingo@redhat.com, Will Deacon , longman@redhat.com, boqun.feng@gmail.com, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, Paul Walmsley , Palmer Dabbelt , aou@eecs.berkeley.edu, Arnd Bergmann , macro@orcam.me.uk, Greg KH , sudipm.mukherjee@gmail.com, wangkefeng.wang@huawei.com, jszhang@kernel.org, linux-csky@vger.kernel.org, linux-kernel@vger.kernel.org, openrisc@lists.librecores.org, linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, Palmer Dabbelt From: Palmer Dabbelt To: Arnd Bergmann , heiko@sntech.de, guoren@kernel.org, shorne@gmail.com 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: Peter Zijlstra (Intel) Acked-by: Waiman Long Signed-off-by: Palmer Dabbelt --- include/asm-generic/qspinlock.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/asm-generic/qspinlock.h b/include/asm-generic/qspinlock.h index d74b13825501..95be3f3c28b5 100644 --- a/include/asm-generic/qspinlock.h +++ b/include/asm-generic/qspinlock.h @@ -2,6 +2,37 @@ /* * 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 asm-generic/spinlock.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