Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp348616yba; Mon, 1 Apr 2019 07:37:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/ziKppWhZwlb/cZJO8gu/aMR/3hD2feKQ9YtvgnSp+G9WavMkJsXF4YKa8EsEaIim8LKL X-Received: by 2002:a65:6210:: with SMTP id d16mr11884092pgv.110.1554129439095; Mon, 01 Apr 2019 07:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554129439; cv=none; d=google.com; s=arc-20160816; b=UEV4iZ9yrPE6oZz2AQnpnX5ROLUY28nu7Fo+56mPvYg0xwT/D+bXkrubS6WTrcIoS3 8cLNk5p69GC5491E7ch8pnFuMS6rh8a8eMMq1pBVgnaULfYRXsRZDXM8tgYnlAoWgpUF e5QfvFdtr0muIaNIZDWHuahdwGB2NpQpSiFhG0Z0yurVZOEOiyyuQofCWGSp1QX7PNBw HO7sX87aJxki01iiiz7D7XQcTcd9vhsCnFePKYtLMpi78Jyd74/3ngKZgUSsO3sRHmnp sRSLemQv1QnUCN1+vz0Hms2TJsRJ8DOlj+gZB1y/ifpwRLLIc7UPBG6l+HP1ZevVm6CY A8+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:openpgp:from:references:cc:to :subject; bh=1f1hq8xE6gpsbtmgwZy06joeX0ilaj/mDiUpGzr6UCg=; b=P0kT/o73YODhDnngQsQ4P+abxpsrH+y1lbOvFyPktmrPnpkLLyjb+IfYhO43pXdZgf oP3y/0O032UKJwAF5GSxTQqx8ikObZ4su6FZBBGNWXu2nsy9/bvDsPQ0Nq53G8vB5ST5 n8jfryOQjPKZOFjIfbozwMCRPgD6idWC+9dmOh8qERPFtfUVlkOWGGr88x1Vs4VtnaLh B9OT9JT/ORhOo613ixPKiAk4FiGK922okzdXMqgk6a07JxKOS/vXN/58URqHkxnEaO0o CrqPjuRfazOlEnU0vM0aFGJ6N1aD1fYu8GCMtKRDVRswIsc4iadVZvUYJQXX02e64DSh FW9w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 89si9104405pla.124.2019.04.01.07.37.03; Mon, 01 Apr 2019 07:37:19 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728415AbfDAOgY convert rfc822-to-8bit (ORCPT + 99 others); Mon, 1 Apr 2019 10:36:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53452 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726514AbfDAOgX (ORCPT ); Mon, 1 Apr 2019 10:36:23 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BF8D882F0; Mon, 1 Apr 2019 14:36:22 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-19.bos.redhat.com [10.18.17.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E9FA19C7C; Mon, 1 Apr 2019 14:36:20 +0000 (UTC) Subject: Re: [PATCH v2 3/5] locking/qspinlock: Introduce CNA into the slow path of qspinlock To: Alex Kogan , linux@armlinux.org.uk, peterz@infradead.org, mingo@redhat.com, will.deacon@arm.com, arnd@arndb.de, 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 Cc: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, dave.dice@oracle.com, rahul.x.yadav@oracle.com References: <20190329152006.110370-1-alex.kogan@oracle.com> <20190329152006.110370-4-alex.kogan@oracle.com> From: Waiman Long Openpgp: preference=signencrypt Autocrypt: addr=longman@redhat.com; prefer-encrypt=mutual; keydata= xsFNBFgsZGsBEAC3l/RVYISY3M0SznCZOv8aWc/bsAgif1H8h0WPDrHnwt1jfFTB26EzhRea XQKAJiZbjnTotxXq1JVaWxJcNJL7crruYeFdv7WUJqJzFgHnNM/upZuGsDIJHyqBHWK5X9ZO jRyfqV/i3Ll7VIZobcRLbTfEJgyLTAHn2Ipcpt8mRg2cck2sC9+RMi45Epweu7pKjfrF8JUY r71uif2ThpN8vGpn+FKbERFt4hW2dV/3awVckxxHXNrQYIB3I/G6mUdEZ9yrVrAfLw5M3fVU CRnC6fbroC6/ztD40lyTQWbCqGERVEwHFYYoxrcGa8AzMXN9CN7bleHmKZrGxDFWbg4877zX 0YaLRypme4K0ULbnNVRQcSZ9UalTvAzjpyWnlnXCLnFjzhV7qsjozloLTkZjyHimSc3yllH7 VvP/lGHnqUk7xDymgRHNNn0wWPuOpR97J/r7V1mSMZlni/FVTQTRu87aQRYu3nKhcNJ47TGY evz/U0ltaZEU41t7WGBnC7RlxYtdXziEn5fC8b1JfqiP0OJVQfdIMVIbEw1turVouTovUA39 Qqa6Pd1oYTw+Bdm1tkx7di73qB3x4pJoC8ZRfEmPqSpmu42sijWSBUgYJwsziTW2SBi4hRjU h/Tm0NuU1/R1bgv/EzoXjgOM4ZlSu6Pv7ICpELdWSrvkXJIuIwARAQABzR9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yRsg72Nurwzvknv7anSgIkL+doXDaG21DgCYTD wGA5uquIgb8p3/ENgYpDPrsZ72CxVC2NEJjJwwnRBStjJOGQX4lV1uhN1XsZjBbRHdKF2W9g weim8xU= Organization: Red Hat Message-ID: <60a3a2d8-d222-73aa-2df1-64c9d3fa3241@redhat.com> Date: Mon, 1 Apr 2019 10:36:19 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190329152006.110370-4-alex.kogan@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 01 Apr 2019 14:36:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/29/2019 11:20 AM, Alex Kogan wrote: > In CNA, spinning threads are organized in two queues, a main queue for > threads running on the same node as the current lock holder, and a > secondary queue for threads running on other nodes. At the unlock time, > the lock holder scans the main queue looking for a thread running on > the same node. If found (call it thread T), all threads in the main queue > between the current lock holder and T are moved to the end of the > secondary queue, and the lock is passed to T. If such T is not found, the > lock is passed to the first node in the secondary queue. Finally, if the > secondary queue is empty, the lock is passed to the next thread in the > main queue. For more details, see https://arxiv.org/abs/1810.05600. > > Note that this variant of CNA may introduce starvation by continuously > passing the lock to threads running on the same node. This issue > will be addressed later in the series. > > Enabling CNA is controlled via a new configuration option > (NUMA_AWARE_SPINLOCKS), which is enabled by default if NUMA is enabled. > > Signed-off-by: Alex Kogan > Reviewed-by: Steve Sistare > --- > arch/x86/Kconfig | 14 +++ > include/asm-generic/qspinlock_types.h | 13 +++ > kernel/locking/mcs_spinlock.h | 10 ++ > kernel/locking/qspinlock.c | 29 +++++- > kernel/locking/qspinlock_cna.h | 173 ++++++++++++++++++++++++++++++++++ > 5 files changed, 236 insertions(+), 3 deletions(-) > create mode 100644 kernel/locking/qspinlock_cna.h > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index 68261430fe6e..e70c39a901f2 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -1554,6 +1554,20 @@ config NUMA > > Otherwise, you should say N. > > +config NUMA_AWARE_SPINLOCKS > + bool "Numa-aware spinlocks" > + depends on NUMA > + default y > + help > + Introduce NUMA (Non Uniform Memory Access) awareness into > + the slow path of spinlocks. > + > + The kernel will try to keep the lock on the same node, > + thus reducing the number of remote cache misses, while > + trading some of the short term fairness for better performance. > + > + Say N if you want absolute first come first serve fairness. > + The patch that I am looking for is to have a separate numa_queued_spinlock_slowpath() that coexists with native_queued_spinlock_slowpath() and paravirt_queued_spinlock_slowpath(). At boot time, we select the most appropriate one for the system at hand. If you are going for the configuration option route, keep in mind that we optimize for the most common cases which are single-socket systems. Please default to "n" unless you can prove that your change won't regress performance for single-socket systems. Cheers, Longman