Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5637595ybl; Tue, 27 Aug 2019 07:37:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtrsXk/2VXODOC3ldTxAy4oB6IYN8ilYqRsZ89Vge46Dq6nSSC1RzQpWxwL9hYVELz4bWn X-Received: by 2002:a62:f245:: with SMTP id y5mr26555395pfl.156.1566916675502; Tue, 27 Aug 2019 07:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566916675; cv=none; d=google.com; s=arc-20160816; b=CuKmJCkdXoqjezqXcf7erNS4JQH+HMxe3xJykNkvvPKXNPW4K+P9IUSwrtQKEMJVxO jZ7/fkBJVoLowwkaJ7reofOK9ZfZV/vf4NpnmjCqnYMDgydFOEA+ogi0uFRu5FunwWeN vuvQVn9lyNAv0tP//xZek2hejUV+Z92q+Fjp7JvJkgcSDZAYaUjUzUOQvqle+XFRLwV1 tAonF0JVZkgmBWSQMKKTJpKmJXbV3gI1JdAp/f6w/MlTaeUv+4psHW6n6URmnDtZR9En bUzo/FH1lGiaU1pJSJ0NjJQ5M1i6Qtij3q2slwXH27HQXmintOdoONG0K9bPOn66uvPU cw9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:robot-unsubscribe:robot-id:message-id :mime-version:references:in-reply-to:cc:subject:to:reply-to:from :date; bh=lSgGI4PNdGzczHRzsPzlDTSXOzOrXefexeClxD4vroY=; b=qAXL/x+ZNFaGop78OYO449Z1GhemjxNTx/3jfP8oUIvMy4Fk3daDceNRMKZg4Kh2Qo QUjm1VkXQYuPmfg0KgZMK4tsrHcv8BTm8weTBA0vhj2yvXnLv2/yGL0jZ65644eYAPBK i7LbC5dcLh9nyoZnziQEZ0yclccYQETH8kYN6R1Db8H+FxVMvVBlBgepCtZZdM1uvnzE Yj9lDm6gFD9vNu2zaIw2c0EixA0GIkED6JAd4vy+8xV42M9GnvhqJW/256fMpSk3GZIB DHjfhxiYxlhBH0kEwa5QnZ1TSReTcFQQKXoVkOct0c1mf+qTjs1Q8bbAt6gEjyLx4RLF 14bw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o191si13774430pfg.155.2019.08.27.07.37.40; Tue, 27 Aug 2019 07:37:55 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729925AbfH0Ogo (ORCPT + 99 others); Tue, 27 Aug 2019 10:36:44 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:43960 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728834AbfH0Ogk (ORCPT ); Tue, 27 Aug 2019 10:36:40 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1i2caJ-0008Qw-4q; Tue, 27 Aug 2019 16:36:35 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 9ACE21C07DC; Tue, 27 Aug 2019 16:36:34 +0200 (CEST) Date: Tue, 27 Aug 2019 14:36:34 -0000 From: "tip-bot2 for Ming Lei" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] genirq/affinity: Improve __irq_build_affinity_masks() Cc: Ming Lei , Thomas Gleixner , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20190816022849.14075-2-ming.lei@redhat.com> References: <20190816022849.14075-2-ming.lei@redhat.com> MIME-Version: 1.0 Message-ID: <156691659442.23585.17929718097373200199.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Disposition: inline X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/core branch of tip: Commit-ID: 53c1788b7d7720565214a466afffdc818d8c6e5f Gitweb: https://git.kernel.org/tip/53c1788b7d7720565214a466afffdc818d8c6e5f Author: Ming Lei AuthorDate: Fri, 16 Aug 2019 10:28:48 +08:00 Committer: Thomas Gleixner CommitterDate: Tue, 27 Aug 2019 16:31:17 +02:00 genirq/affinity: Improve __irq_build_affinity_masks() One invariant of __irq_build_affinity_masks() is that all CPUs in the specified masks (cpu_mask AND node_to_cpumask for each node) should be covered during the spread. Even though all requested vectors have been reached, it's still required to spread vectors among remained CPUs. A similar policy has been taken in case of 'numvecs <= nodes' already. So remove the following check inside the loop: if (done >= numvecs) break; Meantime assign at least 1 vector for remaining nodes if 'numvecs' vectors have been handled already. Also, if the specified cpumask for one numa node is empty, simply do not spread vectors on this node. Signed-off-by: Ming Lei Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20190816022849.14075-2-ming.lei@redhat.com --- kernel/irq/affinity.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index 6fef480..c7cca94 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c @@ -129,14 +129,26 @@ static int __irq_build_affinity_masks(unsigned int startvec, for_each_node_mask(n, nodemsk) { unsigned int ncpus, v, vecs_to_assign, vecs_per_node; - /* Spread the vectors per node */ - vecs_per_node = (numvecs - (curvec - firstvec)) / nodes; - /* Get the cpus on this node which are in the mask */ cpumask_and(nmsk, cpu_mask, node_to_cpumask[n]); - - /* Calculate the number of cpus per vector */ ncpus = cpumask_weight(nmsk); + if (!ncpus) + continue; + + /* + * Calculate the number of cpus per vector + * + * Spread the vectors evenly per node. If the requested + * vector number has been reached, simply allocate one + * vector for each remaining node so that all nodes can + * be covered + */ + if (numvecs > done) + vecs_per_node = max_t(unsigned, + (numvecs - done) / nodes, 1); + else + vecs_per_node = 1; + vecs_to_assign = min(vecs_per_node, ncpus); /* Account for rounding errors */ @@ -156,13 +168,11 @@ static int __irq_build_affinity_masks(unsigned int startvec, } done += v; - if (done >= numvecs) - break; if (curvec >= last_affv) curvec = firstvec; --nodes; } - return done; + return done < numvecs ? done : numvecs; } /*