Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1612162pxp; Thu, 17 Mar 2022 12:42:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwXSd87qT+UyQ5H2ROBOOKYMWhRnQmy6OfzH9wc0b0IpPkR8u5X0hZKYKfSYHMoDYpMn0F X-Received: by 2002:a65:6657:0:b0:381:1b99:3f04 with SMTP id z23-20020a656657000000b003811b993f04mr4957560pgv.512.1647546127030; Thu, 17 Mar 2022 12:42:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647546127; cv=none; d=google.com; s=arc-20160816; b=BtKOU3/SbcdsYBKBj06C7ufRQ27vJJzIrpNVdlhJ6Mfx09ll+Xhi5ZcGpig15MvvXG 1M0R/Ow/KUoqKvK8pzdp585icjgzK/NI3UzT7Wu5DQ1oXEGTPYgOacnhJC7h+xhGdb1r I3vxzgzHbfcjvkA51D3L5CfYCAl1EgNHia7pKc/SGe3x4UQgW/ZRJqm8m/6qZTEobSLx VXbDnDkDZ/3GdnC/552nLNmM4ehPhhwRkvUoQTD9wSr1LcQ8qlQSf7u3wnSe+lzwsPlw oGqTpAnmc1b8V3J0OoERr1kCXp3A4FDbMZsWvXU4Qm9/4hJvCjfMlV799TTEYHFG3oZX snZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=llqjR9J1FmybTT0pHxsozwhPdyLYqoq+OgcFl5fMvI4=; b=V7XvbMfW6MR/wJ71R8UiHvu1A167QQ14o9iNO/DTqD74qOi5Y+ir0e4pQsiczlErPQ bxdkVmmBoA0D7uAY+w3L25FBoxavot9bKSWoSXwuEhECpUg8NGK+Al+uO6sQYhYN43DT cXzvMicH9Qj6BltWAk7Zb/YPluV1/GW6WKZWoaDpkbq89uBFYDrVI0dtPBHugYyWmDyj 54V8Jpus8Mfb+1Qr+caevRVJmvbpiE5Vb8I/FUMm2P8OO4xWs18VBX+Swpra+BhwAarH vbzzP4JiVqHqHV4N7LUYHcF+njP4tq/bX5r+eBx5zJITif6nPbyR2yjldCNrrWfryXfk kvbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X7v+a+3G; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y17-20020a17090322d100b0015409fa2de7si216564plg.525.2022.03.17.12.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 12:42:07 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X7v+a+3G; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A1985237FE2; Thu, 17 Mar 2022 12:42:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237056AbiCQRsV (ORCPT + 99 others); Thu, 17 Mar 2022 13:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237073AbiCQRsK (ORCPT ); Thu, 17 Mar 2022 13:48:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C086B1F6356 for ; Thu, 17 Mar 2022 10:46:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647539212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=llqjR9J1FmybTT0pHxsozwhPdyLYqoq+OgcFl5fMvI4=; b=X7v+a+3GIfbjGtyGOEoKEN6aLHlBimYXLjPd7cuVU7NrGNI5h6uit4z0oMlC767cpnW7OF uSiYek03N2suncz5ZFR6hcGeKix1l+VDmhZ5mb6rdC+/lHIfJFLY+c2K/mLqHDxS+Ey5uX j6IYyEOLeK5iKviPhbzgMzaVuTQ2ITc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-201-D_1JD0DkM1yNyRBj3b6jGg-1; Thu, 17 Mar 2022 13:46:49 -0400 X-MC-Unique: D_1JD0DkM1yNyRBj3b6jGg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A59218A6584; Thu, 17 Mar 2022 17:46:48 +0000 (UTC) Received: from [10.22.8.95] (unknown [10.22.8.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EC33401E87; Thu, 17 Mar 2022 17:46:47 +0000 (UTC) Message-ID: <67ba2190-dd72-4ad0-32c2-de43418b73a2@redhat.com> Date: Thu, 17 Mar 2022 13:46:46 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH 1/5] asm-generic: qspinlock: Indicate the use of mixed-size atomics Content-Language: en-US To: Palmer Dabbelt , linux-riscv@lists.infradead.org, peterz@infradead.org Cc: jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, mingo@redhat.com, Will Deacon , 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-arch@vger.kernel.org References: <20220316232600.20419-1-palmer@rivosinc.com> <20220316232600.20419-2-palmer@rivosinc.com> From: Waiman Long In-Reply-To: <20220316232600.20419-2-palmer@rivosinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 3/16/22 19:25, Palmer Dabbelt wrote: > 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 > * Acked-by: Waiman Long Note that it references ticket-lock.h. Perhaps we should reverse the order of patches 1 & 2. Cheers, Longman