Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp296475yba; Wed, 3 Apr 2019 08:55:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBsaZgWGXMtR+c3z/apDT9TvKactWr9fWXvV3yi7thSDpN8BcQKNJYClVzhtqzdMqHagw0 X-Received: by 2002:a17:902:8ecc:: with SMTP id x12mr733191plo.0.1554306903574; Wed, 03 Apr 2019 08:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554306903; cv=none; d=google.com; s=arc-20160816; b=OfWQ6QE3UuQIYPw58mgl8VQYdwPsY6bz99m7cmPP/rsXPctFKJXYGFQ1SNd7JUmjJD Q1Vcj73jCcoIAygN6tqMwxKETx8d2Bn6aJ+6cKSNGVUKiigjUXrvjqhXk3gb7RCJWq2p riw2gubSb5pcaH9JZH9TI72x0dFRc5NEL+hRhn21lXyk96/xFnRH5qxI6bZTcQ6Jnc6A t3RMR4bN+rTIFGe+/CkhO0yzjZH16Md3UvXHQwM0LELJZI4ct+gtep6AWZDc8wxgMkgE pU1sKkhGNhLArRYHMM7q0AqEoYd/d0vdFcfuDru0TlqaeID0JFn0/5Ku7qbCF40nDJLE hzIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=qReBWK8TFnnRJ4GgchFv6RlNPNP9puAXnouaEBsFg1Q=; b=Uz6EVLJQ5qHV9l6dan9SYHi0jzsKDBOyEo3hGpykXVtpzSpm25wLRGal1y9nTBP6jZ AbRJ9AuYW6+U5OpMet+hCSk9vYHZ835onaGdsOr+cvso4CtjYVzBi9kFwbam6xfdqV50 Vaykl66ci1QBrXDhSiUk4fLiamYHBMM799MislJFwdYwFeH4+4pNcBSHnTliA46XN0JU yYsyE/rak2PjvCvSSMNcpgbrwPsKocqaflR0RQOk+oIAqAFFhPgQmnRvqQmQNWBN57wr E2B3a5eoQFDiHoFy2TKyXHTe/cfOHr8o/hjJwd1ZAfx7f6RvyyfU+j1HFI7zqDPfVvz9 H3mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Ohy1m45p; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t69si13821795pfa.7.2019.04.03.08.54.48; Wed, 03 Apr 2019 08:55:03 -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=@oracle.com header.s=corp-2018-07-02 header.b=Ohy1m45p; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726384AbfDCPyO (ORCPT + 99 others); Wed, 3 Apr 2019 11:54:14 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:38254 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726105AbfDCPyO (ORCPT ); Wed, 3 Apr 2019 11:54:14 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x33FmlQx086647; Wed, 3 Apr 2019 15:53:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=corp-2018-07-02; bh=qReBWK8TFnnRJ4GgchFv6RlNPNP9puAXnouaEBsFg1Q=; b=Ohy1m45pvk9TJdKhCLWgta9Nf0uVuyy9XMgjoQXvQjQ2jL2F/A8ohKSeOmaPqQPVKDa0 3cKD/ZNj9n7TMWUFz3j4F7+Ud0GRExJAW2iyvq6c7VKZ0UmtGuiTUN1gFz7ov+cs7Vnf 012u6zZ7SVLBUzlTSBM5sVr+RFajQJ8UpwF+R3EpPhoJd5SORBTS54GiiJqoBlhd9xKH 0OxrZlINEGwdESzy4I4yuLtSfoHMnfiEtYfnk1otaeHEzxW7YbIhz3M/rlXoabBwtarM F8uga9R9BfgjSpDGQP0vCBYH8G3vEPw6Vg7Jb/vvfap9KeKzSytw/nYFKabMa6cFJVFy 0Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 2rhwyda4jq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Apr 2019 15:53:43 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x33FqWhG165584; Wed, 3 Apr 2019 15:53:42 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2rm8f560v0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Apr 2019 15:53:42 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x33Frekr030517; Wed, 3 Apr 2019 15:53:41 GMT Received: from [10.11.111.157] (/10.11.111.157) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 03 Apr 2019 08:53:40 -0700 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3259\)) Subject: Re: [PATCH v2 3/5] locking/qspinlock: Introduce CNA into the slow path of qspinlock From: Alex Kogan In-Reply-To: <20190401093345.GA14281@hirez.programming.kicks-ass.net> Date: Wed, 3 Apr 2019 11:53:53 -0400 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 Content-Transfer-Encoding: quoted-printable Message-Id: <7A8A6827-BF79-47FC-99A1-C9EE00D9C3B1@oracle.com> References: <20190329152006.110370-1-alex.kogan@oracle.com> <20190329152006.110370-4-alex.kogan@oracle.com> <20190401090653.GF11158@hirez.programming.kicks-ass.net> <20190401093345.GA14281@hirez.programming.kicks-ass.net> To: Peter Zijlstra X-Mailer: Apple Mail (2.3259) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9216 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904030108 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9216 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904030107 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Apr 1, 2019, at 5:33 AM, Peter Zijlstra = wrote: >=20 > On Mon, Apr 01, 2019 at 11:06:53AM +0200, Peter Zijlstra wrote: >> 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 @@ >>>=20 >>> 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 */ >>> }; >>=20 >> Please, have another look at the paravirt code, in particular at = struct >> pv_node and its usage. This is horrible. >=20 > Thing is, this turns into a right mess when you also have PV spinlocks > on. >=20 > One thing we could maybe do is change locked and count to u8, then = your > overlay structure could be something like: >=20 > struct mcs_spinlock { > struct mcs_spinlock *next; > u8 locked; > u8 count; > }; I was trying to keep the size of the mcs_spinlock structure for the = non-NUMA variant unchanged. If this is not a huge concern, changing the fields as above would indeed = simplify a few things. =E2=80=94 Alex=20 >=20 > struct cna_node { > /* struct mcs_spinlock overlay */ > struct mcs_spinlock *next; > u8 locked; > u8 count; >=20 > /* our CNA bits, consuming the slack and PV space */ > u16 node; > u32 encoded_tail; > struct mcs_spinlock *head; > struct mcs_spinlock *tail; > }; >=20 > Then you also don't need the first two patches.