Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp80834yba; Mon, 1 Apr 2019 02:08:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRJMvRuUlwCrVq4cfvdyAVyIoq8aIPVhjvL1Nf5mfz5cYZHW6JS8T7Abrpr2P684LBRGhH X-Received: by 2002:a63:cf0f:: with SMTP id j15mr60024746pgg.329.1554109693509; Mon, 01 Apr 2019 02:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554109693; cv=none; d=google.com; s=arc-20160816; b=awdtyOd5bDrIx/mhnWUEQ7BrC/TWz59+ynbTB2w+HJRiMGsUJqhi6J9p5VVRU0rYod vNKAi2dk2JciAhcDdk932/DQllJOBynrnilDqms/2tP3OiBGB6/A/3EgYuJKA86ThUxJ dCn9kF1lqi4DRUmU3aJUC/dxhIJ3S9kP9nQhL+Zp0fIYrwtrK+X/m5aiYhvXiKUicYNB e88ECEvu6444WCD1nucgGwuvr05uXGMWsmKcxvULDiah2oRjLCzNCrwbFhMsrMA/c2/5 sN77fCOES1bRhjzpY/3HfAOiYaQbpCL84v5GqYqQMMrPfpv21l6u2TFOyrW3XkB5ohBZ Lj1Q== 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; bh=Tr5iG0RatrjjKf2qKctaugtMj1dq+AB/Tt9yx6X0tTQ=; b=fVdw/+cCyzhw2CyXrjyw8NjpdoXwMnpoKY9StXD5yLf5Ok1qADVlcnYWttLOAi03Z+ F6VSROfiPmv481EHKrqHEWxc8L/bs8OJly76GnLpMew5Y6Oo1+GF0CJO/LZVqhwD1QJO 1Yhem23utCDu8oWxLqsOjLS6fRyC6o6ddXmJLZwbaiyhlLJSVo80DDstyUhu8/QJCczP sAH17TxBWr7rbOIzoW56kAm1Co9H/MjCRL+W8sRgn/tedNYbvUJWOmStErmZm1kxYNEU cNFJMXNfPpsUBD6IstL6xwMX1HzYsJqiE+hvrHnr3N4yQEHYN+ZYmTQivSnbFMXH3A8L +E8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=dn0nkNUx; 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 o90si8413815pfi.161.2019.04.01.02.07.58; Mon, 01 Apr 2019 02:08:13 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=dn0nkNUx; 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 S1726608AbfDAJHV (ORCPT + 99 others); Mon, 1 Apr 2019 05:07:21 -0400 Received: from merlin.infradead.org ([205.233.59.134]:36616 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbfDAJHU (ORCPT ); Mon, 1 Apr 2019 05:07:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Tr5iG0RatrjjKf2qKctaugtMj1dq+AB/Tt9yx6X0tTQ=; b=dn0nkNUxPzscydUMEDgkUuJmM G3yTjs9PPkAfE2Z1N086P7bUmc9Ag9xdwU3GcKB/M+aOz62jreKNWcIEqVvQB6v7NDW4gcgVGrGeP q5p3P4VPnw/oVjOhqsiY6WPFkchqNu1hai4Qk6RkvTgDw/uwXUPgJ0p7LsrTUOn3VKkR1Rg4JDpZk iW+fNMoF2JZ1zeS3dN+VBhQcmMK9dhQExQWT7odhU5p+2n/lMUBHypcV8rthCh3sKDAfpxVW3AN9Q 1G0kub/xg68ZNyRqu26LVEzCcl8xx+Vup5Ki+0zz/hFVM6v6zYOd54o307eDM5oAJIaSsLZ3JNnNy K52I5NZQw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hAsu6-0007nt-Ma; Mon, 01 Apr 2019 09:06:54 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2A2492026BE95; Mon, 1 Apr 2019 11:06:53 +0200 (CEST) Date: Mon, 1 Apr 2019 11:06:53 +0200 From: Peter Zijlstra To: Alex Kogan Cc: linux@armlinux.org.uk, mingo@redhat.com, will.deacon@arm.com, arnd@arndb.de, longman@redhat.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, bp@alien8.de, hpa@zytor.com, x86@kernel.org, steven.sistare@oracle.com, daniel.m.jordan@oracle.com, dave.dice@oracle.com, rahul.x.yadav@oracle.com Subject: Re: [PATCH v2 3/5] locking/qspinlock: Introduce CNA into the slow path of qspinlock Message-ID: <20190401090653.GF11158@hirez.programming.kicks-ass.net> References: <20190329152006.110370-1-alex.kogan@oracle.com> <20190329152006.110370-4-alex.kogan@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190329152006.110370-4-alex.kogan@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 29, 2019 at 11:20:04AM -0400, Alex Kogan wrote: > diff --git a/kernel/locking/mcs_spinlock.h b/kernel/locking/mcs_spinlock.h > index bc6d3244e1af..71ee4b64c5d4 100644 > --- a/kernel/locking/mcs_spinlock.h > +++ b/kernel/locking/mcs_spinlock.h > @@ -17,8 +17,18 @@ > > struct mcs_spinlock { > struct mcs_spinlock *next; > +#ifndef CONFIG_NUMA_AWARE_SPINLOCKS > int locked; /* 1 if lock acquired */ > int count; /* nesting count, see qspinlock.c */ > +#else /* CONFIG_NUMA_AWARE_SPINLOCKS */ > + uintptr_t locked; /* 1 if lock acquired, 0 if not, other values */ > + /* represent a pointer to the secondary queue head */ > + u32 node_and_count; /* node id on which this thread is running */ > + /* with two lower bits reserved for nesting */ > + /* count, see qspinlock.c */ > + u32 encoded_tail; /* encoding of this node as the main queue tail */ > + struct mcs_spinlock *tail; /* points to the secondary queue tail */ > +#endif /* CONFIG_NUMA_AWARE_SPINLOCKS */ > }; Please, have another look at the paravirt code, in particular at struct pv_node and its usage. This is horrible. > #ifndef arch_mcs_spin_lock_contended > diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c > index 074f65b9bedc..7cc923a59716 100644 > --- a/kernel/locking/qspinlock.c > +++ b/kernel/locking/qspinlock.c > @@ -527,6 +544,12 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) > next = READ_ONCE(node->next); > if (next) > prefetchw(next); > + } else { > + /* In CNA, we must pass a non-zero value to successor when > + * we unlock. This store should be harmless performance-wise, > + * as we just initialized @node. > + */ Buggered comment style, also, it confuses the heck out of me. What does it want to say? Also, why isn't it hidden in your pv_wait_head_or_lock() implementation? > + node->locked = 1; > } >