From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757783AbcK2OwV convert rfc822-to-8bit (ORCPT ); Tue, 29 Nov 2016 09:52:21 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:51399 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757148AbcK2OwE (ORCPT ); Tue, 29 Nov 2016 09:52:04 -0500 Date: Tue, 29 Nov 2016 15:51:14 +0100 From: Sebastian Andrzej Siewior To: Thomas Gleixner Cc: Michal Hocko , linux-kernel@vger.kernel.org, rt@linutronix.de, Andrew Morton , Vlastimil Babka , Mel Gorman , Johannes Weiner , linux-mm@kvack.org Subject: [PATCH 08/22 v2] mm/vmstat: Avoid on each online CPU loops Message-ID: <20161129145113.fn3lw5aazjjvdrr3@linutronix.de> References: <20161126231350.10321-1-bigeasy@linutronix.de> <20161126231350.10321-9-bigeasy@linutronix.de> <20161128092800.GC14835@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: User-Agent: NeoMutt/20161104 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Both iterations over online cpus can be replaced by the proper node specific functions. Cc: Andrew Morton Cc: Vlastimil Babka Cc: Mel Gorman Cc: Johannes Weiner Cc: linux-mm@kvack.org Signed-off-by: Sebastian Andrzej Siewior --- v1…v2: take into account that we may have online nodes with no CPUs. mm/vmstat.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 0b63ffb5c407..5152cd1c490f 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); } -- 2.10.2