From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756550AbcK2OLA (ORCPT ); Tue, 29 Nov 2016 09:11:00 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:51215 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754902AbcK2OKw (ORCPT ); Tue, 29 Nov 2016 09:10:52 -0500 Date: Tue, 29 Nov 2016 15:08:10 +0100 (CET) From: Thomas Gleixner To: Michal Hocko cc: Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, rt@linutronix.de, Andrew Morton , Vlastimil Babka , Mel Gorman , Johannes Weiner , linux-mm@kvack.org Subject: Re: [PATCH 08/22] mm/vmstat: Avoid on each online CPU loops In-Reply-To: <20161128092800.GC14835@dhcp22.suse.cz> Message-ID: References: <20161126231350.10321-1-bigeasy@linutronix.de> <20161126231350.10321-9-bigeasy@linutronix.de> <20161128092800.GC14835@dhcp22.suse.cz> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 28 Nov 2016, Michal Hocko wrote: > On Sun 27-11-16 00:13:36, Sebastian Andrzej Siewior wrote: > [...] > > 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) > > + node_set_state(node, N_CPU); > > Is this really correct? The point of the original code was to mark only > those nodes which have at least one CPU. Or am I missing something? You're right. An online node does not necessarily have an online CPU. for_each_online_node(node) { if (cpumask_weight(cpumask_of_node(node)) > 0) node_set_state(node, N_CPU); } is probably more correct. Thanks, tglx