Received: by 10.213.65.68 with SMTP id h4csp607996imn; Fri, 6 Apr 2018 06:07:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/JAiOUsR4k1it5mMiNuI/KhATPFmARyMcW1P+ZdmaNxy+g+6SKlkp/rFU35z6aJSqyZjTN X-Received: by 2002:a17:902:8d97:: with SMTP id v23-v6mr26749234plo.285.1523020034904; Fri, 06 Apr 2018 06:07:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523020034; cv=none; d=google.com; s=arc-20160816; b=cyUt7FtY6YEikmGl8pShviWoKWICT7gZHXXjjF49Bp2Kpfo+TWmDtuJVwDMn8FbagR 7v8HD5QmU7/U5O3bkrDKf0e4pjk7M6RcxcGsAGh4+pho/E47WmC9Mkt6z5JdSbLOSDsy 1e7waSwRBmqmFiMOZYvIBY/ZEGxBliQ+tSP0R9KPTJrfhsDYGGYG8vjhkrjpKia+UUbS 41e75JgrYRhkJpD9hKRogBNGDmtLy540OMP3debxLzQTjitLxilM6s4rN+dDzKmxG0nz anqRPvLLrpSCCQSyk4ivc1YLVHdn3Fur3vvCTPMjlK88TCWzhzlbsOKFbkAB6cFAWrRh cXqA== 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:dkim-signature:arc-authentication-results; bh=DUY2dp0JeN332a3kHakSlTqCsBvaRoCy/5EhYtoAGaM=; b=cjN904CXt6IFl1Ep8VDR4/YdjA0Gb5vH+1LMCXGJQlMGWaZT4VyJpVxgszkDDkIyex rU4LWQLX2177OPqwbZkP2rJohNMHkLJ4w5MFAKZQyvnhTcVEQxzXtJHQGJ/IQOdjvq+l ZZhg2DsQZzUV+uhlQkq61IX0PD6SEfDhV63sYuAlV3kbmjWt0Ko+JPjfEhwIkfBIwSSa 03MZ8HBfKGhA66gzcz9G4pnkn1hMlQSGlthHlwG/ZMUZBRW5hpVOdYVQ+5FRiZrF31jq lthQlp34ReNJOFtGCDp+wpnuZG+IHo7uXhhX2UyJr2B3JfbGHakGOAiT3nzIHJdJFH+Q RJBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=L6vRM8Ie; 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 a6-v6si8416836pll.722.2018.04.06.06.07.01; Fri, 06 Apr 2018 06:07:14 -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; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=L6vRM8Ie; 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 S1753046AbeDFNFX (ORCPT + 99 others); Fri, 6 Apr 2018 09:05:23 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40684 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752999AbeDFNFV (ORCPT ); Fri, 6 Apr 2018 09:05:21 -0400 Received: by mail-wm0-f68.google.com with SMTP id x4so3226796wmh.5 for ; Fri, 06 Apr 2018 06:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=DUY2dp0JeN332a3kHakSlTqCsBvaRoCy/5EhYtoAGaM=; b=L6vRM8IeoHCaZN+lxzMIGb1vIi/SKgxZsbAYHcLVnNwpE1Ev+88XLVZXwoUxkopdFX QlSTUwQkBRMmVJao+hHKfZd9+79flXFPAWGVuB7paK3g19Goj77KKvhkzGcCIhbfZsWB 73wMPyS2retqHEbkQXv6LumRPedbWyXxpVknk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=DUY2dp0JeN332a3kHakSlTqCsBvaRoCy/5EhYtoAGaM=; b=A7Oy7ogy1S+dwUrChRy7HzC5Ni56sdDM2J397ZvHLEtHA8a6hH+FfKCNzsn8xMjmAX f9YDzuZCCiiElzzEZX+gOyskdaCpR53oJZDZC/s5GdVJipPUxIi2wPEhMDKeZekiOj8W WzeqE8aGj//HTrZBhU/fUjFyv/ytuP+a7mcOuGsJBT7mtXY+lv84bedZZ/fuGsF2QuO3 CCwtotQfS9RTOmObwP3P9i2YVXKQESrSUMd3/m09cMQ8gsYS4gqm+NOTEfLh/3kpB35G gF3EDDnnn+fZyWbjvznbzxVORJh7OcZUmtd6KeiS9CAnhCB25epYpb5YlbYT8Pwyf/qz 1e8g== X-Gm-Message-State: ALQs6tDlksCz2Kl2of9cBhvbKvGKIkVGCjW8x3XReGIKPQHk/7da+rA3 ltqk3yMLWQxz2b7MEG4N7JpjIQ== X-Received: by 10.28.173.77 with SMTP id w74mr11704224wme.60.1523019920088; Fri, 06 Apr 2018 06:05:20 -0700 (PDT) Received: from andrea ([213.209.242.222]) by smtp.gmail.com with ESMTPSA id y30sm9213943wrd.83.2018.04.06.06.05.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 06:05:19 -0700 (PDT) Date: Fri, 6 Apr 2018 15:05:12 +0200 From: Andrea Parri To: Will Deacon Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mingo@kernel.org, boqun.feng@gmail.com, paulmck@linux.vnet.ibm.com, catalin.marinas@arm.com, Waiman Long Subject: Re: [PATCH 10/10] locking/qspinlock: Elide back-to-back RELEASE operations with smp_wmb() Message-ID: <20180406130512.GA6631@andrea> References: <1522947547-24081-1-git-send-email-will.deacon@arm.com> <1522947547-24081-11-git-send-email-will.deacon@arm.com> <20180405172808.GG4082@hirez.programming.kicks-ass.net> <20180406113436.GC27619@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180406113436.GC27619@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Will, On Fri, Apr 06, 2018 at 12:34:36PM +0100, Will Deacon wrote: > On Thu, Apr 05, 2018 at 07:28:08PM +0200, Peter Zijlstra 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 > > > + * waitqueue. > > > + */ > > > + smp_wmb(); > > > > Maybe an explicit note to where the matching barrier lives.. > > Oh man, that's not a simple thing to write: there isn't a matching barrier! > > Instead, we rely on dependency ordering for two cases: > > * We access a node by decoding the tail we get back from the xchg > > - or - > > * We access a node by following our own ->next pointer > > I could say something like: > > "Pairs with dependency ordering from both xchg_tail and explicit > dereferences of node->next" > > but it's a bit cryptic :( Agreed. ;) It might be helpful to instead include a snippet to highlight the interested memory accesses/dependencies; IIUC, /* * Pairs with dependency ordering from both xchg_tail and explicit/? * dereferences of node->next: * * CPU0 * * /* get node0, encode node0 in tail */ * pv_init_node(node0); * ((struct pv_node *)node0)->cpu = smp_processor_id(); * ((struct pv_node *)node0)->state = vcpu_running; * smp_wmb(); * old = xchg_tail(lock, tail); * * CPU1: * * /* get node1, encode tail from node1 */ * old = xchg_tail(lock, tail); // = tail corresponding to node0 * // head an addr. dependency * /* decode old in prev */ * pv_wait_node(node1, prev); * READ ((struct pv_node *)prev)->cpu // addr. dependent read * READ ((struct pv_node *)prev)->state // addr. dependend read * * [More details for the case "following our own ->next pointer" you * mentioned dabove.] */ CPU1 would also have: WRITE_ONCE(prev->next, node1); // addr. dependent write but I'm not sure how this pairs: does this belong to the the second case above? can you elaborate on that? Andrea > > Will