Received: by 10.213.65.68 with SMTP id h4csp2449586imn; Mon, 9 Apr 2018 03:50:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx49RM7Gg8bUvwDxQcw/xbcmTq0uRuKKEA75kk5JVBYxHYOwvIICTFmrmYZ2zuBGWWkpbsI7a X-Received: by 2002:a17:902:6b07:: with SMTP id o7-v6mr38298676plk.136.1523271025453; Mon, 09 Apr 2018 03:50:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523271025; cv=none; d=google.com; s=arc-20160816; b=h8mlI0uWQsTDkSFNIvNNCv7A2o4R6fSSEo487h0ypFFaV+KkrmzJblO46X9RYm3r9L se2KQwMr6Qu4Sa38i6iM2owlykzkteq4sa9uwxTmRNvKNpicMwo4GnAPRxyOANPPd6Iy D0eeijOLE891H4NtYVAogn1iq/Q0TJsJfm8sbGEHD9VkqTV6T3LIlTLHb3b4kIVZXLOE xeAi9hi2cE66Lm7u3WbItdnmIrVJa0BdZvPYqmiXiye1Y2U4ZdwaF0vyWIwv18TwHP/l dLx3TiB+0Xr7jn0+5kD7ovSciSnmLmxTxPItY5mHHO6nCyAapvdA2ozwMWYXzsNAZ/aM jmlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=jUH71cFip1J1YO/qsatO3MSYCY6DB9FeY94Lah1iSTI=; b=Bs0IROuZoHPQu2o3fjkWiYgLlJ0Qy8GFoFNnnGl4kF4zuZUrQ/qWT9Oq0s1dFjL/Km iIWzORIN9zOj7nkp7l/OP6hik4lJob5hlMnDGi4m/wto6wO3eCI0i41IIQ8b6sikPAnK DHpaDJx6MqZ5+lS3SdYKKv6ibzwxtxSwPas+uJQzo1C2KO1RWEQN/RYOdmgk7DzJXX/B m8Zk22O/KnE05xLxq1e5s4aIj+iWR38XTqkJOivjxF0CsgyEiwaZ7hbTFptX3UXCWBz/ /iuCdTChF83tK4FzN5JGvRqzsLljWLxObdcvvvFQJTB5sQkpz/LRfp4dRjxNJ1SAWBmD q9xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x14-v6si4351pln.728.2018.04.09.03.49.49; Mon, 09 Apr 2018 03:50:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751918AbeDIKq6 (ORCPT + 99 others); Mon, 9 Apr 2018 06:46:58 -0400 Received: from foss.arm.com ([217.140.101.70]:54342 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751744AbeDIKqx (ORCPT ); Mon, 9 Apr 2018 06:46:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5C7F7F; Mon, 9 Apr 2018 03:46:53 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2CD7B3F487; Mon, 9 Apr 2018 03:46:53 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 01EB91AE5501; Mon, 9 Apr 2018 11:47:07 +0100 (BST) Date: Mon, 9 Apr 2018 11:47:07 +0100 From: Will Deacon To: Boqun Feng Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, peterz@infradead.org, mingo@kernel.org, paulmck@linux.vnet.ibm.com, catalin.marinas@arm.com Subject: Re: [PATCH 10/10] locking/qspinlock: Elide back-to-back RELEASE operations with smp_wmb() Message-ID: <20180409104707.GB23134@arm.com> References: <1522947547-24081-1-git-send-email-will.deacon@arm.com> <1522947547-24081-11-git-send-email-will.deacon@arm.com> <20180407054711.rldyfcmni2wtblyu@tardis> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180407054711.rldyfcmni2wtblyu@tardis> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Boqun, On Sat, Apr 07, 2018 at 01:47:11PM +0800, Boqun Feng wrote: > On Thu, Apr 05, 2018 at 05:59:07PM +0100, Will Deacon wrote: > > @@ -340,12 +341,17 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) > > goto release; > > > > /* > > + * Ensure that the initialisation of @node is complete before we > > + * publish the updated tail and potentially link @node into the > > I think it might be better if we mention exactly where we "publish the > updated tail" and "link @node", how about: > > * publish the update tail via xchg_tail() and potentially link > * @node into the waitqueue via WRITE_ONCE(->next,..) below. > > and also add comments below like: > > > + * waitqueue. > > + */ > > + smp_wmb(); > > + > > + /* > > * We have already touched the queueing cacheline; don't bother with > > * pending stuff. > > * > > * p,*,* -> n,*,* > > - * > > - * RELEASE, such that the stores to @node must be complete. > > * publish the updated tail > > > */ > > old = xchg_tail(lock, tail); > > next = NULL; > > @@ -356,15 +362,7 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) > > */ > > if (old & _Q_TAIL_MASK) { > > prev = decode_tail(old); > > - > > - /* > > - * We must ensure that the stores to @node are observed before > > - * the write to prev->next. The address dependency from > > - * xchg_tail is not sufficient to ensure this because the read > > - * component of xchg_tail is unordered with respect to the > > - * initialisation of @node. > > - */ > > - smp_store_release(&prev->next, node); > > /* Eventually link @node to the wait queue */ > > Thoughts? I'll make some changes along these lines for v2. Thanks! Will