Received: by 10.223.176.5 with SMTP id f5csp1446566wra; Wed, 31 Jan 2018 06:37:43 -0800 (PST) X-Google-Smtp-Source: AH8x226YXG68WTNNCwzyCMIBuIwPDUcJMbVMfQlVJZ9HyCjvgHaLwOo68rzkgOaIs4hD09kQmWa9 X-Received: by 10.101.73.203 with SMTP id t11mr27213033pgs.48.1517409462938; Wed, 31 Jan 2018 06:37:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517409462; cv=none; d=google.com; s=arc-20160816; b=i/DjYfPBpeDI8M9yBG01U8m2AyBWivdaevevcd7mLAZi/7nIUaelP8IrTuk4d50b++ c7JYqEl76k76PIqypWEaztotUEuvjHqZTtVawiDCZT+oyRAa5jyG+3c5wYJSvkXb6dSl lpqB1Dm+Cxd5yGPylIX9uWAOYqTZECcgI5uge6kSGwUNZARArKQ/KzwyFLySP0sO4TA8 wwvgjK1SK3icUFJXLMhlleuYwtRQpxmCztvXE3TzE5LRKRprHxFTwbpzj1ay4iP1NmCT pDrBSbeUDzZHHLRlOHsWDuu3WcsJMDR7vbpeLX0XvldlwtRxUoKeodfeslTSa1DQIREH LW0w== 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=EyaA1hKYxzOcJuYITikdUj0WD3PirAgkceefxqt4aAg=; b=WSsUz/7hPTA6uQ6UfJFrWw75NbkmVFulJ0ErBTO48kbcHYI8L0F0OpD/0A6Drb/Jjx AXUGg1A3mi4LO46qiMF4PwnntuRPrwAHQr4LXvE3ovfBXpWqSQxhIzciPK85jorDAz1s 5cqyjiHfq/36DjtFu24XdFhKLNqaLFu25d5rSGV1yLBNpC1vDRHdQM06J+t5L8hFKZrt 0zl4cM9SvKYV3NjD0gsxgziW8uXNleKh9zLkhtwdPz/bPYaEJRat7DPltBjRFuYpNG6D PQXKeWMiSCWaL6yRGgGIpI8Ec9o5GOuCZo+lPWCigJpO/aZzTJclFvQf+5VkXBOdOZp4 /7EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eW2pYaTJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4si11217636pgb.334.2018.01.31.06.37.00; Wed, 31 Jan 2018 06:37:42 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=eW2pYaTJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753012AbeAaOLu (ORCPT + 99 others); Wed, 31 Jan 2018 09:11:50 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:40087 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752296AbeAaOLt (ORCPT ); Wed, 31 Jan 2018 09:11:49 -0500 Received: by mail-wr0-f193.google.com with SMTP id i56so15122077wra.7 for ; Wed, 31 Jan 2018 06:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=EyaA1hKYxzOcJuYITikdUj0WD3PirAgkceefxqt4aAg=; b=eW2pYaTJQA9ZPLlveVirDjSOmDxPz2fB1dNXN0msAt+L2alKB7Xy3i7H5wQs67rl/X nX9fXUjyw5DILOzlzE4W7Ze37vorfJObGNSYIAAEH84QnXJxdigb0ZvcYHDZhr2Zdznw YF+hgf7OnxOXWADHEQVj71SOEtYApF3XexNNUo0CKl/cQyuDDX4pHYj/xlcTqqWeLlI4 nv29CKIhyQ/GlUCrbfAUaJ3qakE46H4EyIRBjEJ48tOCIJDjd/fX6U/7SXoBf19cDIvp fEx7u6JkMvq5uLKFxxUCElSO41jQUa8GJlazGWdfizyoottOQqpXdpQteR8juxxdWL2e bB/g== 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=EyaA1hKYxzOcJuYITikdUj0WD3PirAgkceefxqt4aAg=; b=PNx9ZPtoeb/gzW4jQ8a0jyPj9WbWJvZs5IxcAMukyEAgphriGzgKucl/uDpvbDcirz AEZNQIW71d1+2QmaMIeLnZSRGTTRj71IN7tO7QkRz8KWpCq87h3OKQFojIZ/in33kGha RJcTt+QH3b1RAbctJOTVPblQHvOag3sEA8LKUYq6XnQOPox4v2B4ozcPr/C2LqMGVKjq F/8f1QmWZgE4DK40zwPPIc4nUyp8VC0k07grVo6x9xXzpNQiOVbQJw8cADtKIJFKIJ09 GkPZDdaM0kLJNu2BEnSAdex4cikLUla99EeaSfaw8zJKDt7WCmWpZC7O5VgslhICEUE2 V1lw== X-Gm-Message-State: AKwxyteOjMGyHBO8kiZXONUU36nuIb6Oi9dXXl6WAlmGHoEflhciT4f7 CoP352IQUY+Xym5MOXszgzw= X-Received: by 10.223.176.211 with SMTP id j19mr17961152wra.60.1517407907906; Wed, 31 Jan 2018 06:11:47 -0800 (PST) Received: from andrea (86.100.broadband17.iol.cz. [109.80.100.86]) by smtp.gmail.com with ESMTPSA id 204sm18109116wmx.0.2018.01.31.06.11.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jan 2018 06:11:47 -0800 (PST) Date: Wed, 31 Jan 2018 15:11:40 +0100 From: Andrea Parri To: Peter Zijlstra Cc: Will Deacon , linux-kernel@vger.kernel.org, Ingo Molnar Subject: Re: [PATCH] locking/qspinlock: Ensure node is initialised before updating prev->next Message-ID: <20180131141140.GA9450@andrea> References: <1517401246-2750-1-git-send-email-will.deacon@arm.com> <20180131123859.GQ2269@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180131123859.GQ2269@hirez.programming.kicks-ass.net> 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 On Wed, Jan 31, 2018 at 01:38:59PM +0100, Peter Zijlstra wrote: > On Wed, Jan 31, 2018 at 12:20:46PM +0000, Will Deacon wrote: > > diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c > > index 294294c71ba4..1ebbc366a31d 100644 > > --- a/kernel/locking/qspinlock.c > > +++ b/kernel/locking/qspinlock.c > > @@ -408,16 +408,15 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) > > */ > > if (old & _Q_TAIL_MASK) { > > prev = decode_tail(old); > > + > > /* > > - * The above xchg_tail() is also a load of @lock which generates, > > - * through decode_tail(), a pointer. > > - * > > - * The address dependency matches the RELEASE of xchg_tail() > > - * such that the access to @prev must happen after. > > + * We must ensure that the stores to @node are observed before > > + * the write to prev->next. The address dependency on 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_read_barrier_depends(); > > Right, except you're patching old code here, please try again on a tree > that includes commit: > > 548095dea63f ("locking: Remove smp_read_barrier_depends() from queued_spin_lock_slowpath()") BTW, which loads was/is the smp_read_barrier_depends() supposed to order? ;) I was somehow guessing that this barrier was/is there to "order" the load from xchg_tail() with the address-dependent loads from pv_wait_node(); is this true? (Does Will's patch really remove the reliance on the barrier?) Andrea > > > - > > - WRITE_ONCE(prev->next, node); > > + smp_store_release(prev->next, node); > > > > pv_wait_node(node, prev); > > arch_mcs_spin_lock_contended(&node->locked); > > -- > > 2.1.4 > >