Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1918657ybx; Thu, 7 Nov 2019 19:51:12 -0800 (PST) X-Google-Smtp-Source: APXvYqxx0DBgjTjk/XOXVEQK2OHPpLIO1fBEuURMN1yXPsyyXPMY5huIfargc0YCt1j5Qeg9ZJDv X-Received: by 2002:a17:906:d143:: with SMTP id br3mr6706570ejb.215.1573185072484; Thu, 07 Nov 2019 19:51:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573185072; cv=none; d=google.com; s=arc-20160816; b=m3oXO0KE1lo6dgEc/rCOu8F/je5fa4ymICM7pOoAqOUjcnP7J/f5K8S5mx6fK1pD8W 5s5GIkVMHH6rgH86xZ5KvVJkWqLY+Zx3GH1pILtZSOebX7QQlNjqbjVSWmggX4amFGH8 ctlWNMlpOlhJfXroL2JG+AQwuADJjnsDGSmP9eFgyeaA5e7nHvwD/zzxpaZ4i7pFgFig 3+5S65u4/stR5sbqFJ6RyA1+xhFONhzTjdmFpBk9Jt548bQgtcHLrfBPObmwTqtFOBxh zx2tRZ/1zAN+1YbgqU30mU4j6mayS00Vbo9EuQHNauAQSSUMNVbdVe0OPE3TCOK2FUAQ 3cyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=zGtJkis9XePLVlChH2H83/RdSQFmLNul8gX4NVjHH4Y=; b=Km0OBbUt1JE2q6VHk9kEqbSivglftzn/6H5T7+g0eSLZDZG7Qyw3tXSQBbaT3DteSc fHCJwdkl8cunGFFk5pE38rsMla2Oxt0kjvdlxu19OO9R9/bPwsevDCGr5Jg9Coww6dZk uzz8gtRA3W6gOH6q/i58EjzMWzgrAN6qpydwmEiMLK0RhRPPrd0gGE5jeaO3udyLF4WY UYE/FMqYS1Tt42dYL/0fGETHmpTI79VQgpekqoXwrKNdxSiqwpvD24Et67FIWzz2A+qP XVfN/JBF+LSuDaf6xXQ70wCg92LaSf0tAX7aFYrbVaGn1Os3IGQ03zyehEIBZ2vvxrvO sslA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ht1JJP2p; 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 f19si2772683eda.435.2019.11.07.19.50.49; Thu, 07 Nov 2019 19:51:12 -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=@kernel.org header.s=default header.b=Ht1JJP2p; 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 S1729706AbfKHDto (ORCPT + 99 others); Thu, 7 Nov 2019 22:49:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:43490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbfKHDto (ORCPT ); Thu, 7 Nov 2019 22:49:44 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5778B214DB; Fri, 8 Nov 2019 03:49:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573184983; bh=hDn+O714HZCfqIEs2rgREb9No+oC6fIHjDsTtU0o66Q=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Ht1JJP2pBj9xSJeTifsdSQh3tK1GT6ObOVtroZ8OgoROiDSbaG/eE+k49+4ACO9FN Vscfpd4JLJQKrkoG8x4601kkJ2KCHTg68AzurK44fdfMNdbbR0QCMWSN1QeZMrnK6r ygmTvOf5ysIffaDM73lutF00mEIgcFXaDphFVvwM= Date: Thu, 7 Nov 2019 19:49:42 -0800 From: Andrew Morton To: Shaokun Zhang Cc: , yuqi jin , Mike Rapoport , Paul Burton , Michal Hocko , Michael Ellerman , Anshuman Khandual Subject: Re: [PATCH v3] lib: optimize cpumask_local_spread() Message-Id: <20191107194942.734bc867e1c9578d07cf1712@linux-foundation.org> In-Reply-To: <1573091048-10595-1-git-send-email-zhangshaokun@hisilicon.com> References: <1573091048-10595-1-git-send-email-zhangshaokun@hisilicon.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 7 Nov 2019 09:44:08 +0800 Shaokun Zhang wrote: > In the multi-processors and NUMA system, I/O driver will find cpu cores > that which shall be bound IRQ. When cpu cores in the local numa have > been used, it is better to find the node closest to the local numa node, > instead of choosing any online cpu immediately. > > On Huawei Kunpeng 920 server, there are 4 NUMA node(0 -3) in the 2-cpu > system(0 - 1). We perform PS (parameter server) business test, the > behavior of the service is that the client initiates a request through > the network card, the server responds to the request after calculation. > When two PS processes run on node2 and node3 separately and the > network card is located on 'node2' which is in cpu1, the performance > of node2 (26W QPS) and node3 (22W QPS) was different. > It is better that the NIC queues are bound to the cpu1 cores in turn, > then XPS will also be properly initialized, while cpumask_local_spread > only considers the local node. When the number of NIC queues exceeds > the number of cores in the local node, it returns to the online core > directly. So when PS runs on node3 sending a calculated request, > the performance is not as good as the node2. It is considered that > the NIC and other I/O devices shall initialize the interrupt binding, > if the cores of the local node are used up, it is reasonable to return > the node closest to it. > > Let's optimize it and find the nearest node through NUMA distance for the > non-local NUMA nodes. The performance will be better if it return the > nearest node than the random node. > > After this patch, the performance of the node3 is the same as node2 > that is 26W QPS when the network card is still in 'node2'. Since it will > return the closest non-local NUMA code rather than random node, it is no > harm to others at least. This is a little nicer: --- a/lib/cpumask.c~lib-optimize-cpumask_local_spread-v3-fix +++ a/lib/cpumask.c @@ -254,7 +254,6 @@ static unsigned int __cpumask_local_spre BUG(); } -static DEFINE_SPINLOCK(spread_lock); /** * cpumask_local_spread - select the i'th cpu with local numa cpu's first * @i: index number @@ -270,6 +269,7 @@ unsigned int cpumask_local_spread(unsign { static int node_dist[MAX_NUMNODES]; static bool used[MAX_NUMNODES]; + static DEFINE_SPINLOCK(spread_lock); unsigned long flags; int cpu, j, id; _