Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1532351

Re: [PATCH 08/22] mm/vmstat: Avoid on each online CPU loops

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 08/22] mm/vmstat: Avoid on each online CPU loops
Date 2016-11-29 15:50 +0100
Message-ID <sIRTj-1hD-3@gated-at.bofh.it> (permalink)
References <sHUqd-4EY-3@gated-at.bofh.it> <sHUqe-4EY-27@gated-at.bofh.it> <sIqq6-f5-23@gated-at.bofh.it> <sIRqh-17H-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue 29-11-16 15:08:10, Thomas Gleixner wrote:
> 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.

Yes, this looks correct. Considering that the same cpumask_weight is
used in another function I guess a small helper would be nice. E.g.
bool node_has_cpus(int node)
{
	return cpumask_weight(cpumask_of_node(node)) > 0;
}

-- 
Michal Hocko
SUSE Labs

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 08/22] mm/vmstat: Avoid on each online CPU loops Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-11-27 00:20 +0100
  Re: [PATCH 08/22] mm/vmstat: Avoid on each online CPU loops Michal Hocko <mhocko@kernel.org> - 2016-11-28 10:30 +0100
    Re: [PATCH 08/22] mm/vmstat: Avoid on each online CPU loops Thomas Gleixner <tglx@linutronix.de> - 2016-11-29 15:20 +0100
      Re: [PATCH 08/22] mm/vmstat: Avoid on each online CPU loops Michal Hocko <mhocko@kernel.org> - 2016-11-29 15:50 +0100
      [PATCH 08/22 v2] mm/vmstat: Avoid on each online CPU loops Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-11-29 16:00 +0100
        Re: [PATCH 08/22 v2] mm/vmstat: Avoid on each online CPU loops Michal Hocko <mhocko@kernel.org> - 2016-11-29 16:30 +0100
        [tip:smp/hotplug] mm/vmstat: Avoid on each online CPU loops tip-bot for Sebastian Andrzej Siewior <tipbot@zytor.com> - 2016-12-02 01:20 +0100

csiph-web