Received: by 10.213.65.68 with SMTP id h4csp762402imn; Fri, 6 Apr 2018 08:28:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx49FdHWzSzvRfggmBh6i0+t6xsP8+kt2oCpWGKjaDjlnUWgqFH82tRR36w9n2AFQ+S5x4zuj X-Received: by 2002:a17:902:9a48:: with SMTP id x8-v6mr27509982plv.135.1523028529049; Fri, 06 Apr 2018 08:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523028529; cv=none; d=google.com; s=arc-20160816; b=jlc8rtXBDMsFhWQb0EWGD9dohSxGPfK8lpqg7dYGSS6CRVGHhqgOvAvxy+gWslRM7S xUpApkRNe3JuZECgtgBZXoado3iD8LcCvXSCO+lU4xXurbSbP/0dG8gLMDgN/YD8vXjC wherY1oBe7UdEENNqB11GIG2tL0F7HhB3HmF2AYtHElJYCf067DDgIdsoP8/4OS5Qbch MIobGTUai5yGRouU41rFfqFGy3zusptac6NIeKHYsBlY7xG+Ge6aFicZC21BgAKOCdWR qDcuB5BLughejhmaLnzBFdIABIWOGlfUQoyne9j71ibcGQI+bEbT+HFBYuynyt6hyINL jE9g== 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=8vV96+2Q0pLx1QeddUS9ailRGZJTSWZuSrKcmddnY9Y=; b=U/wELxEfi+SdhxDBjR44dftPQRUsn8gHAyjZczRpLnzwzs+k6dPaHXw9JMpwiCOcfa a0NX4rU8Oy7MlFHy7dbUeHz34WGOBgmqzXT6fs6jFGh941g5Vgfa6j4UKmb4sdPcMKPa wms7tw0/2MkbcVMkd+5uB5SJPQktzixAlc9rKfpSZvTF1Mc3CV3XYaRE8v0hezcgKR3l bwhDIzQhMiMdgv/6rztsiokSvF0rTI5gVC6j3oQlcGoKBc1I2ccQKzdweWEqN5L8Q0dj A4r5BR1GCQVpucYTgxgGaIwvhjTJt7ArXgmXsQESgGRAieCj4qL1XgsyrloGJJY8s8P0 fsmQ== 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 c184si8023997pfc.367.2018.04.06.08.28.34; Fri, 06 Apr 2018 08:28:48 -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 S1752892AbeDFP1d (ORCPT + 99 others); Fri, 6 Apr 2018 11:27:33 -0400 Received: from foss.arm.com ([217.140.101.70]:38848 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752278AbeDFP1b (ORCPT ); Fri, 6 Apr 2018 11:27:31 -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 50E4D1529; Fri, 6 Apr 2018 08:27:31 -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 22AD83F587; Fri, 6 Apr 2018 08:27:31 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 17EA31AE55CC; Fri, 6 Apr 2018 16:27:45 +0100 (BST) Date: Fri, 6 Apr 2018 16:27:45 +0100 From: Will Deacon To: Andrea Parri 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: <20180406152744.GE10528@arm.com> 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> <20180406130512.GA6631@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180406130512.GA6631@andrea> 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 Andrea, On Fri, Apr 06, 2018 at 03:05:12PM +0200, Andrea Parri wrote: > On Fri, Apr 06, 2018 at 12:34:36PM +0100, Will Deacon wrote: > > 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; I'd probably ignore the PV case here and just focus on the native init of count/locked/next. > * 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); Similarly here -- the dependency is through decode_tail. > * 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? This is dependent on the result of decode_tail, so it's still the first case. The second case is when we queued into an empty tail but somebody later queued behind us, so we don't find them until we're claiming the lock: if (!next) next = smp_cond_load_relaxed(&node->next, (VAL)); arch_mcs_spin_unlock_contended(&next->locked); here, this is all straightforward address dependencies rather than the arithmetic in decode_tail. Will