tracing: Don't assume possible cpu list have continuous numbers

"for (++cpu ; cpu < num_possible_cpus(); cpu++)" statement assumes
possible cpus have continuous number - but that's a wrong assumption.

Insted, cpumask_next() should be used.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Steven Rostedt <srostedt@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <20090310104437.A480.A69D9226@jp.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
KOSAKI Motohiro 2009-03-10 10:49:53 +09:00 committed by Ingo Molnar
parent 8293dd6f86
commit bbcd306359
1 changed files with 7 additions and 7 deletions

View File

@ -91,7 +91,7 @@ static void probe_workqueue_creation(struct task_struct *wq_thread, int cpu)
struct cpu_workqueue_stats *cws; struct cpu_workqueue_stats *cws;
unsigned long flags; unsigned long flags;
WARN_ON(cpu < 0 || cpu >= num_possible_cpus()); WARN_ON(cpu < 0);
/* Workqueues are sometimes created in atomic context */ /* Workqueues are sometimes created in atomic context */
cws = kzalloc(sizeof(struct cpu_workqueue_stats), GFP_ATOMIC); cws = kzalloc(sizeof(struct cpu_workqueue_stats), GFP_ATOMIC);
@ -175,12 +175,12 @@ static void *workqueue_stat_next(void *prev, int idx)
spin_lock_irqsave(&workqueue_cpu_stat(cpu)->lock, flags); spin_lock_irqsave(&workqueue_cpu_stat(cpu)->lock, flags);
if (list_is_last(&prev_cws->list, &workqueue_cpu_stat(cpu)->list)) { if (list_is_last(&prev_cws->list, &workqueue_cpu_stat(cpu)->list)) {
spin_unlock_irqrestore(&workqueue_cpu_stat(cpu)->lock, flags); spin_unlock_irqrestore(&workqueue_cpu_stat(cpu)->lock, flags);
for (++cpu ; cpu < num_possible_cpus(); cpu++) { do {
ret = workqueue_stat_start_cpu(cpu); cpu = cpumask_next(cpu, cpu_possible_mask);
if (ret) if (cpu >= nr_cpu_ids)
return ret; return NULL;
} } while (!(ret = workqueue_stat_start_cpu(cpu)));
return NULL; return ret;
} }
spin_unlock_irqrestore(&workqueue_cpu_stat(cpu)->lock, flags); spin_unlock_irqrestore(&workqueue_cpu_stat(cpu)->lock, flags);