Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp247358ybx; Tue, 5 Nov 2019 23:18:50 -0800 (PST) X-Google-Smtp-Source: APXvYqzxvAOxHMtQwophjiUzmxms51qv1sGGawg4Bn03fcvLTj6mIfngAvo0YE2EVSgsOeOrzDjL X-Received: by 2002:aa7:c645:: with SMTP id z5mr1069424edr.204.1573024730305; Tue, 05 Nov 2019 23:18:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573024730; cv=none; d=google.com; s=arc-20160816; b=CHk5zIRGIQpU+tpOjzpQTqx7qV0rMMn0B11QKwIuq/wShizUxuud3Bdbt8+9ex56eO ZWfp1xsTPR/QIZxYUawWmdlTTIi5VrY+PG+TdxCDa7v9GY4NefkgMUZUOVUgQDP3nt4G fSJ2o8fivv6JrLjuY+9zhG+HImvCQMYUs7/kcCdYxVBXFg9jVBlamMNCwlAZbgWZieXv CyDxq5mEJ7l+OMNu9dhQIvZBcqcbfzGKsd9XBmhgnZ9xpTHN2drNEGH0IILUfg39XGoM l9WANTJm9IklJBZynxO7xDZNHcpcWO+EEq8HjSfTZodtR8+soyUD25i25kGGeUwzTqch ta0Q== 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; bh=3RxpAmoGeudLVCfc650kQvozy2pBWWSyO4xHjcKk/aY=; b=IZe1XY/uigDbcsAgu+CxgckObl+yv8udNy0vVQDX682prQZA/MtmchmoaHqH835nOu Nvs9kGV53gvIY0ltOZrUKb9OtadDh5zial+Zr8Sk3W5Gx9qbzXzuLnAtgruu8vbW7jeP ve5UElW+Stzn/GLE0JK5QTouVR7LVY20+rM04VyTyuIGe48l0KOUXx44SmdYfL0a8r5a ERYdaFoEgn7yCmD7e2flI1BKN0B2kKiOp3/momaoleNatNm/UWsSbqCF9lX+IDBjwCbu 1oPD6ffPwrVPHKniwN+LowA+UmveJcQtu/sZtjAG21s63a5DtBDRPL0FUHkrui1VGHei kGOg== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11si12992498edf.93.2019.11.05.23.18.26; Tue, 05 Nov 2019 23:18:50 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731136AbfKFHRq (ORCPT + 99 others); Wed, 6 Nov 2019 02:17:46 -0500 Received: from mx2.suse.de ([195.135.220.15]:55262 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729979AbfKFHRq (ORCPT ); Wed, 6 Nov 2019 02:17:46 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7F0A7AFB0; Wed, 6 Nov 2019 07:17:44 +0000 (UTC) Date: Wed, 6 Nov 2019 08:17:42 +0100 From: Michal Hocko To: Andrew Morton Cc: Shaokun Zhang , linux-kernel@vger.kernel.org, yuqi jin , Mike Rapoport , Paul Burton , Michael Ellerman , Anshuman Khandual Subject: Re: [PATCH v2] lib: optimize cpumask_local_spread() Message-ID: <20191106071742.GB8314@dhcp22.suse.cz> References: <1572863268-28585-1-git-send-email-zhangshaokun@hisilicon.com> <20191105070141.GF22672@dhcp22.suse.cz> <20191105173359.39052327cf221d9c4b26b783@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191105173359.39052327cf221d9c4b26b783@linux-foundation.org> 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 Tue 05-11-19 17:33:59, Andrew Morton wrote: > On Tue, 5 Nov 2019 08:01:41 +0100 Michal Hocko wrote: > > > On Mon 04-11-19 18:27:48, Shaokun Zhang wrote: > > > From: yuqi jin > > > > > > In the multi-processor and NUMA system, I/O device may have many numa > > > nodes belonging to multiple cpus. When we get a local numa, it is > > > better to find the node closest to the local numa node, instead > > > of choosing any online cpu immediately. > > > > > > For the current code, it only considers the local NUMA node and it > > > doesn't compute the distances between different NUMA nodes for the > > > non-local NUMA nodes. Let's optimize it and find the nearest node > > > through NUMA distance. The performance will be better if it return > > > the nearest node than the random node. > > > > Numbers please > > The changelog had > > : When Parameter Server workload is tested using NIC device on Huawei > : Kunpeng 920 SoC: > : Without the patch, the performance is 22W QPS; > : Added this patch, the performance become better and it is 26W QPS. Maybe it is just me but this doesn't really tell me a lot. What is Parameter Server workload? What do I do to replicate those numbers? Is this really specific to the Kunpeng 920 server? What is the usual variance of the performance numbers? > > [...] > > > +/** > > > + * cpumask_local_spread - select the i'th cpu with local numa cpu's first > > > + * @i: index number > > > + * @node: local numa_node > > > + * > > > + * This function selects an online CPU according to a numa aware policy; > > > + * local cpus are returned first, followed by the nearest non-local ones, > > > + * then it wraps around. > > > + * > > > + * It's not very efficient, but useful for setup. > > > + */ > > > +unsigned int cpumask_local_spread(unsigned int i, int node) > > > +{ > > > + int node_dist[MAX_NUMNODES] = {0}; > > > + bool used[MAX_NUMNODES] = {0}; > > > > Ugh. This might be a lot of stack space. Some distro kernels use large > > NODE_SHIFT (e.g 10 so this would be 4kB of stack space just for the > > node_dist). > > Yes, that's big. From a quick peek I suspect we could get by using an > array of unsigned shorts here but that might be fragile over time even > if it works now? Whatever data type we use it will be still quite large to be on the stack. > Perhaps we could make it a statically allocated array and protect the > entire thing with a spin_lock_irqsave()? It's not a frequently called > function. This is what I was suggesting in previous review feedback. -- Michal Hocko SUSE Labs