From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758222AbcLBALq (ORCPT ); Thu, 1 Dec 2016 19:11:46 -0500 Received: from terminus.zytor.com ([198.137.202.10]:55664 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754837AbcLBALo (ORCPT ); Thu, 1 Dec 2016 19:11:44 -0500 Date: Thu, 1 Dec 2016 16:11:28 -0800 From: tip-bot for Sebastian Andrzej Siewior Message-ID: Cc: vbabka@suse.cz, linux-kernel@vger.kernel.org, hannes@cmpxchg.org, mgorman@techsingularity.net, mhocko@suse.com, tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, akpm@linux-foundation.org, bigeasy@linutronix.de Reply-To: vbabka@suse.cz, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, mgorman@techsingularity.net, mhocko@suse.com, akpm@linux-foundation.org, hpa@zytor.com, bigeasy@linutronix.de, tglx@linutronix.de, mingo@kernel.org In-Reply-To: <20161129145113.fn3lw5aazjjvdrr3@linutronix.de> References: <20161129145113.fn3lw5aazjjvdrr3@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:smp/hotplug] mm/vmstat: Avoid on each online CPU loops Git-Commit-ID: 4c501327b4c67f2b874219f20c41d2619b49c78c X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 4c501327b4c67f2b874219f20c41d2619b49c78c Gitweb: http://git.kernel.org/tip/4c501327b4c67f2b874219f20c41d2619b49c78c Author: Sebastian Andrzej Siewior AuthorDate: Tue, 29 Nov 2016 15:51:14 +0100 Committer: Thomas Gleixner CommitDate: Fri, 2 Dec 2016 00:52:35 +0100 mm/vmstat: Avoid on each online CPU loops Both iterations over online cpus can be replaced by the proper node specific functions. Signed-off-by: Sebastian Andrzej Siewior Acked-by: Michal Hocko Cc: linux-mm@kvack.org Cc: rt@linutronix.de Cc: Johannes Weiner Cc: Andrew Morton Cc: Mel Gorman Cc: Vlastimil Babka Link: http://lkml.kernel.org/r/20161129145113.fn3lw5aazjjvdrr3@linutronix.de Signed-off-by: Thomas Gleixner --- mm/vmstat.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 0b63ffb..5152cd1 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1720,19 +1720,21 @@ static void __init start_shepherd_timer(void) static void __init init_cpu_node_state(void) { - int cpu; + int node; - for_each_online_cpu(cpu) - node_set_state(cpu_to_node(cpu), N_CPU); + for_each_online_node(node) { + if (cpumask_weight(cpumask_of_node(node)) > 0) + node_set_state(node, N_CPU); + } } static void vmstat_cpu_dead(int node) { - int cpu; + const struct cpumask *node_cpus; - for_each_online_cpu(cpu) - if (cpu_to_node(cpu) == node) - return; + node_cpus = cpumask_of_node(node); + if (cpumask_weight(node_cpus) > 0) + return; node_clear_state(node, N_CPU); }