Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp347235pxb; Wed, 14 Apr 2021 17:25:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+AKh8gMBvDBTeXbhVk3ofWyD5l3dQk3uDmEZsLQwZWkOBmBUQi+62knxNoN5o+AeYfWMY X-Received: by 2002:a05:6402:4415:: with SMTP id y21mr961158eda.70.1618446317806; Wed, 14 Apr 2021 17:25:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618446317; cv=none; d=google.com; s=arc-20160816; b=ZgO54hiG0KsMwnxyjsbpL13EhfqbZ/8960hGrhpsZXFP93+9MFftibKsAvFF6XXMTI Ako2q73n9hJnhFoEgpBB6yuQLD9YkvZY0CShB1Zy6c3EyMWsUiACBYEUhAnv58c578oE oJlezRJiPtDjgzl4Y/bAG+Y5JbePvcKsMBpikSlOmPwUxmDSVNhalYYOHHvli54JClv8 dQePiZSBxcaXfMtgz4kaQxuxAypBM/enSeQWXZ/qD+Tah7JUqkwpoasArWw0JEUjCSsA wv+dkhQg7TyELINw5cBgezhB09zjRgqILqjZ8aOqJ/J/FMZ03vQ4klxnPXM3zg79zd7U CMDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OxdMAk1LmEqVZwUMYasw5A7Q8hQ+IixVw/lGbUnnOh0=; b=grorX7daN88b+SbqosmMLZr54Ho79x/vYitMr9LaGqJQPXSoQGQtu6W14UeOZMd11q lZJ5jIexfrQ8EvERTmkOcrLXybGFiVpMWcayKVhkICLbrpnBKHd/nEi7njA4JLa2Bq0j T6KdlhsKhhjOOREG4797E1DbPG8SV/TUt64D63ULAMu6D+OGjdrt5qOTrqLMfUNIFTEc AxR1+o2Sxxvh2IkSczg6TZDPsRPzg38dgUvatMavJp2EeO7jBiPhyMW7zXYvjCXbUAdd FYLtfTPWtJe/wVwqBTy5yaCsoYSkFB/Cqz1xWpCbebjI1cCIrGkwYjz6Nmb/4pn3rDV3 E9pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=sbxUAR1O; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e18si959278edj.485.2021.04.14.17.24.55; Wed, 14 Apr 2021 17:25:17 -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=@infradead.org header.s=casper.20170209 header.b=sbxUAR1O; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233234AbhDNNKp (ORCPT + 99 others); Wed, 14 Apr 2021 09:10:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351149AbhDNNKM (ORCPT ); Wed, 14 Apr 2021 09:10:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A89E7C061574 for ; Wed, 14 Apr 2021 06:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=OxdMAk1LmEqVZwUMYasw5A7Q8hQ+IixVw/lGbUnnOh0=; b=sbxUAR1Ou6zsfaam6Yge0tIitq WUZqtRbnE6R5XHVcG880KxETwVIsTvEHS/9EJ4RuB8KgS2NCFb74vtv7LLFOX5muyUB7y0PBtjrD+ uOsGjA33PLJukmCX8phq1CKCbb6xtqwTQAjLuOJIZlBH/LkLwjz860+HGdcFTaSoZRVRipRLMM116 WEpGCEz2gJGFDrrWua9F8wO1Xi5LhjVHCNviO+o4caKjdagtlFlkTQeNwVUvoobcBmCdElN4XFNvI 71tRGEzgEL0eW4wwERVBXTFJ65qo7aNjPl0uCAx9OyoK/0Op3nxNbCgmfXo7oqleltXqtPfoIKlDO PKlyfuKA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lWfFy-0078jp-Vr; Wed, 14 Apr 2021 13:08:42 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8071B30015A; Wed, 14 Apr 2021 15:08:34 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4AAF02065A47D; Wed, 14 Apr 2021 15:08:34 +0200 (CEST) Date: Wed, 14 Apr 2021 15:08:34 +0200 From: Peter Zijlstra To: Guo Ren Cc: Christoph =?iso-8859-1?Q?M=FCllner?= , Palmer Dabbelt , Anup Patel , linux-riscv , Linux Kernel Mailing List , Guo Ren , Catalin Marinas , Will Deacon , Arnd Bergmann , Jonas Bonn , Stefan Kristiansson , Stafford Horne Subject: Re: [RFC][PATCH] locking: Generic ticket-lock Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 14, 2021 at 02:55:57PM +0200, Peter Zijlstra wrote: > On Wed, Apr 14, 2021 at 08:39:33PM +0800, Guo Ren wrote: > > > + * It further assumes atomic_*_release() + atomic_*_acquire() is RCpc and hence > > > + * uses atomic_fetch_add() which is SC to create an RCsc lock. > > This ^^^ then vvv > > > > +static __always_inline void ticket_lock(arch_spinlock_t *lock) > > > +{ > > > + u32 val = atomic_fetch_add(1<<16, lock); /* SC, gives us RCsc */ > > atomic_fetch_add_acquire ? > > Then we must rely on the arch to implement RCsc atomics. And I for one > can never tell wth Risc-V actually does. Anyway, if we can mandate that atomic acquire/release is RCsc, then yes we can do that but then we also need: #define smp_mb__after_spinlock() smp_mb__after_atomic() But currently atomic acquire/release is not RCsc (at the very least Power does RCtso -- and power gets to deal with any and all pain caused by that).