All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 05/16] staging/lustre: fix up obsolete cpu function usage.
Date: Mon, 2 Mar 2015 20:16:23 -0500	[thread overview]
Message-ID: <2CED6DE1-CF72-42D7-AEB6-247E4FB20539@linuxhacker.ru> (raw)
In-Reply-To: <87twy3j7fo.fsf@rustcorp.com.au>


On Mar 2, 2015, at 6:39 PM, Rusty Russell wrote:
>> if (i == NR_CPUS)
>>    blah;
>> 
>> when we are replacing for_each_cpu_mask with for_each_cpu,
>> what do we check the counter against now to see that the entire loop was executed
>> and we did not exit prematurely? nr_cpu_ids?
> You want >= nr_cpu_ids here.

Aha, Thanks!

>> Also I assume we still want to get rid of direct cpumask assignments like
>>> mask = *cpumask_of_node(cpu_to_node(index));
> 
> Yes, but this code is wrong anyway:
> 
> 		mask = *cpumask_of_node(cpu_to_node(index));
> 		for (i = max; i < num_online_cpus(); i++)
> 			cpumask_clear_cpu(i, &mask);
> 
> *Never* iterate to num_online_cpus().  eg. if cpus 0 and 3 are online,
> num_online_cpus() == 2.  I'm not sure what this code is doing, but it's
> not doing it well :)

Oh my, I don't know how I have not seen it sooner. I think I developed an
idea of what it is trying to do.
Thanks for highlighting it.

So there are 7 more users like this outside of Lustre in the kernel then, I'll try for a patch:
./drivers/scsi/hpsa.c:	for (i = 0; i < num_online_cpus(); i++) { -- this one seems to be just opencoding for_each_cpu, though

./arch/um/kernel/smp.c:	for (i = 0; i < num_online_cpus(); i++) { -- I wonder if UML is able to have discontiguous cpus up?

./arch/sh/include/asm/mmu_context.h:	for (i = 0; i < num_online_cpus(); i++) -- this seems to be the same bug we have.

./arch/sh/kernel/smp.c:		for (i = 0; i < num_online_cpus(); i++) -- this and the two below it too
./arch/sh/kernel/smp.c:		for (i = 0; i < num_online_cpus(); i++)
./arch/sh/kernel/smp.c:		for (i = 0; i < num_online_cpus(); i++)

./arch/m32r/kernel/smpboot.c:	for (cpu_id = 0 ; cpu_id < num_online_cpus() ; cpu_id++) -- this also is buggy, though it's just an info print.

Bye,
    Oleg

  reply	other threads:[~2015-03-03  1:16 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02 11:35 [PATCH 01/16] CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS: set if CPUMASK_OFFSTACK Rusty Russell
2015-03-02 11:35 ` [PATCH 02/16] cpumask: fix cpu-hotplug documentation Rusty Russell
2015-03-02 11:35 ` [PATCH 03/16] ia64: Use for_each_cpu_and() and cpumask_any_and() instead of temp var Rusty Russell
2015-03-02 11:47   ` Rusty Russell
2015-03-02 11:35 ` [PATCH 04/16] drivers: fix up obsolete cpu function usage Rusty Russell
2015-03-02 22:23   ` Rafael J. Wysocki
2015-03-02 11:35 ` [PATCH 05/16] staging/lustre: " Rusty Russell
2015-03-02 17:50   ` Oleg Drokin
2015-03-02 23:39     ` Rusty Russell
2015-03-03  1:16       ` Oleg Drokin [this message]
2015-03-03  3:12         ` Rusty Russell
2015-03-02 11:35 ` [PATCH 06/16] ia64: " Rusty Russell
2015-03-02 11:47   ` Rusty Russell
2015-05-26 20:45   ` Tony Luck
2015-05-26 20:45     ` Tony Luck
2015-05-27  1:18     ` Rusty Russell
2015-05-27  1:30       ` Rusty Russell
2015-05-27 17:37       ` Tony Luck
2015-05-27 17:37         ` Tony Luck
2015-05-28  3:44         ` Rusty Russell
2015-05-28  3:56           ` Rusty Russell
2015-03-02 11:35 ` [PATCH 07/16] um: " Rusty Russell
2015-03-02 11:35   ` [uml-devel] " Rusty Russell
2015-03-02 11:35 ` [PATCH 08/16] x86: " Rusty Russell
2015-03-02 13:36   ` [tip:x86/cleanups] x86: Fix up obsolete __cpu_set() " tip-bot for Rusty Russell
2015-03-02 11:35 ` [PATCH 09/16] mips: fix up obsolete cpu " Rusty Russell
2015-03-02 12:34 ` [PATCH 01/16] CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS: set if CPUMASK_OFFSTACK Paul Bolle
2015-03-02 23:40   ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2CED6DE1-CF72-42D7-AEB6-247E4FB20539@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.