Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21605204ybl; Mon, 6 Jan 2020 07:49:41 -0800 (PST) X-Google-Smtp-Source: APXvYqzxcKJg1QdJJZRjLhVQ14zo4c+CxUG9XAqU4LHK0bKH9hkdgE9KEYJu+IsIAE6Fm679pioU X-Received: by 2002:a9d:2de5:: with SMTP id g92mr98518353otb.217.1578325781467; Mon, 06 Jan 2020 07:49:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578325781; cv=none; d=google.com; s=arc-20160816; b=hBMBQYKpkq5SaO/DAGRRTj7xge1kyLbcEKz0hjhGC5nWCk7nddZhTImXPKCxJILRsj 4Su7q2dATHCidDgWIRWLd4nTuNU7Gy5Sb/wbPz3fEYyAH9CwHq1TiSDxyipi/Bgmo1bD LWLj4g8UrKvmx1qd+hyKVqcFxqJrmLfLuL6J8EHhAz8j95YIjI8H4a1gIjUIZEbvMpAP EbN8y0cmvgsHPFv53Tnn5pIC/xf/qgkJtbp6DP/1ewh6mu8BFTH29CUZmVd03ntcsYzd XQ/jKyivrTwIT3k0blSkx7yP0lxNEsG+NPVljHnAG19ecEhFTCRVYIe67bnpujb54VGr RYuQ== 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:from:references:cc:to:subject :dkim-signature; bh=0eu0mqm9VOScBHtEc/NIyPA5j+hZ0W1aSfm/aRuoupk=; b=sPIoZlEvnJQr1YgDAxvnxA3YNt50BHTnP5Crp1bb2VlPJdPpQ+NdCYKsWJPK+HHQb2 AiaXcnwLA4B4hP+sO80hiLMTHAz+8IWPKml8SsFbgy1zNnN+bN8JdUq7ncursyaQ1/5U oRGuyMWd4+DOv/DyriJDDK2RYYIgxcS3jYUi1BOd0HhT3IeAxo+i21k2PamypKKyThAl 5fkT+d8vCUt7QEV5QjEwF1FnQT92TwovSttP4ygXOUnBx4I1C+NL9o0EACPMuVqdWhg/ Tomxt/NM3NmNKFPp5eXwsgBOoVn8k5DeN5Jp0QhnfTiNeNaa4h1tkt4HRI44QjV3MVT9 9C2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J10l0RgS; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f23si35458243oto.205.2020.01.06.07.49.28; Mon, 06 Jan 2020 07:49:41 -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=@redhat.com header.s=mimecast20190719 header.b=J10l0RgS; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726620AbgAFPsa (ORCPT + 99 others); Mon, 6 Jan 2020 10:48:30 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:53468 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726437AbgAFPsa (ORCPT ); Mon, 6 Jan 2020 10:48:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578325709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0eu0mqm9VOScBHtEc/NIyPA5j+hZ0W1aSfm/aRuoupk=; b=J10l0RgSI30d+77aHUizV48kU3i+cS0bw8H23Qt59D+9JLBpsy1exmua9JbyxkIVzD8BIj YqNcp7ZzMBTxzrImMSXaaH2O4+hertjsxrFHpzcideSGOOpAucRU4gmajRv6wFP6BHWbUk MpSUWOxzw9Gl+9w6btvwAwFzlyMClXw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-90-dDdDuHUTNfevb3mrvnBG4w-1; Mon, 06 Jan 2020 10:48:20 -0500 X-MC-Unique: dDdDuHUTNfevb3mrvnBG4w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A294E18B414A; Mon, 6 Jan 2020 15:48:17 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-59.bos.redhat.com [10.18.17.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id E49687C00D; Mon, 6 Jan 2020 15:48:15 +0000 (UTC) Subject: Re: [PATCH v8 0/5] Add NUMA-awareness to 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, guohanjun@huawei.com, jglauber@marvell.com Cc: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, dave.dice@oracle.com References: <20191230194042.67789-1-alex.kogan@oracle.com> From: Waiman Long Organization: Red Hat Message-ID: <13cde730-34c1-8b99-6990-1f64cc78670d@redhat.com> Date: Mon, 6 Jan 2020 10:48:15 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20191230194042.67789-1-alex.kogan@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/30/19 2:40 PM, Alex Kogan wrote: > Minor changes from v7 based on feedback from Longman: > ----------------------------------------------------- > > - Move __init functions from alternative.c to qspinlock_cna.h > > - Introduce enum for return values from cna_pre_scan(), for better > readability. > > - Add/revise a few comments to improve readability. > > > Summary > ------- > > Lock throughput can be increased by handing a lock to a waiter on the > same NUMA node as the lock holder, provided care is taken to avoid > starvation of waiters on other NUMA nodes. This patch introduces CNA > (compact NUMA-aware lock) as the slow path for qspinlock. It is > enabled through a configuration option (NUMA_AWARE_SPINLOCKS). > > CNA is a NUMA-aware version of the MCS lock. 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. Threads store the ID of the node on which > they are running in their queue nodes. After acquiring the MCS lock and > before acquiring the spinlock, the lock holder scans the main queue > looking for a thread running on the same node (pre-scan). 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. If such T > is not found, we make another scan of the main queue after acquiring > the spinlock when unlocking the MCS lock (post-scan), starting at the > node where pre-scan stopped. If both scans fail to find such T, the > MCS lock is passed to the first thread in the secondary queue. If the > secondary queue is empty, the MCS lock is passed to the next thread in the > main queue. To avoid starvation of threads in the secondary queue, those > threads are moved back to the head of the main queue after a certain > number of intra-node lock hand-offs. > > More details are available at https://arxiv.org/abs/1810.05600. > > The series applies on top of v5.5.0-rc2, commit ea200dec51. > Performance numbers are available in previous revisions > of the series. > > Further comments are welcome and appreciated. > > Alex Kogan (5): > locking/qspinlock: Rename mcs lock/unlock macros and make them more > generic > locking/qspinlock: Refactor the qspinlock slow path > locking/qspinlock: Introduce CNA into the slow path of qspinlock > locking/qspinlock: Introduce starvation avoidance into CNA > locking/qspinlock: Introduce the shuffle reduction optimization into > CNA > > .../admin-guide/kernel-parameters.txt | 18 + > arch/arm/include/asm/mcs_spinlock.h | 6 +- > arch/x86/Kconfig | 20 + > arch/x86/include/asm/qspinlock.h | 4 + > arch/x86/kernel/alternative.c | 4 + > include/asm-generic/mcs_spinlock.h | 4 +- > kernel/locking/mcs_spinlock.h | 20 +- > kernel/locking/qspinlock.c | 82 +++- > kernel/locking/qspinlock_cna.h | 400 ++++++++++++++++++ > kernel/locking/qspinlock_paravirt.h | 2 +- > 10 files changed, 537 insertions(+), 23 deletions(-) > create mode 100644 kernel/locking/qspinlock_cna.h > I have reviewed this patch series. Besides a few minor nits, the rests look solid to me. So you can put my review tag. Reviewed-by: Waiman Long Peter and Will, would you mind taking a look to see if you have anything to add? Thanks, Longman