History

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.

KOSAKI Motohiro committed 17 years ago

Commit bbcd3061 parent 8293dd61 file · +7 −7Browse files

Showing the changes to kernel/trace/trace_workqueue.c (1 of 1 file). Show all

Unified · Split

kernel/trace/trace_workqueue.c+7−7
@@ -91,7 +91,7 @@ static void probe_workqueue_creation(struct task_struct *wq_thread, int cpu) · 90 unmodified lines
9191 struct cpu_workqueue_stats *cws;
9292 unsigned long flags;
9393
94− WARN_ON(cpu < 0 || cpu >= num_possible_cpus());
94+ WARN_ON(cpu < 0);
9595
9696 /* Workqueues are sometimes created in atomic context */
9797 cws = kzalloc(sizeof(struct cpu_workqueue_stats), GFP_ATOMIC);
@@ -175,12 +175,12 @@ static void *workqueue_stat_next(void *prev, int idx) · 77 unmodified lines
175175 spin_lock_irqsave(&workqueue_cpu_stat(cpu)->lock, flags);
176176 if (list_is_last(&prev_cws->list, &workqueue_cpu_stat(cpu)->list)) {
177177 spin_unlock_irqrestore(&workqueue_cpu_stat(cpu)->lock, flags);
178− for (++cpu ; cpu < num_possible_cpus(); cpu++) {
179− ret = workqueue_stat_start_cpu(cpu);
180− if (ret)
181− return ret;
182− }
183− return NULL;
178+ do {
179+ cpu = cpumask_next(cpu, cpu_possible_mask);
180+ if (cpu >= nr_cpu_ids)
181+ return NULL;
182+ } while (!(ret = workqueue_stat_start_cpu(cpu)));
183+ return ret;
184184 }
185185 spin_unlock_irqrestore(&workqueue_cpu_stat(cpu)->lock, flags);
186186