* [PATCH] tracing: Don't assume possible cpu list have contenious number
@ 2009-03-10 1:49 KOSAKI Motohiro
2009-03-10 12:18 ` [tip:tracing/ftrace] tracing: Don't assume possible cpu list have continuous numbers KOSAKI Motohiro
0 siblings, 1 reply; 2+ messages in thread
From: KOSAKI Motohiro @ 2009-03-10 1:49 UTC (permalink / raw)
To: Ingo Molnar, Lai Jiangshan, Steven Rostedt, Frederic Weisbecker,
LKML
Cc: kosaki.motohiro
"for (++cpu ; cpu < num_possible_cpus(); cpu++)" statement assume
possible cpus have contenious number. but that's wrong assumption.
Insted, cpumask_next() should be used.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
kernel/trace/trace_workqueue.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/kernel/trace/trace_workqueue.c b/kernel/trace/trace_workqueue.c
index e6c4d00..46b12db 100644
--- a/kernel/trace/trace_workqueue.c
+++ b/kernel/trace/trace_workqueue.c
@@ -91,7 +91,7 @@ static void probe_workqueue_creation(struct task_struct *wq_thread, int cpu)
struct cpu_workqueue_stats *cws;
unsigned long flags;
- WARN_ON(cpu < 0 || cpu >= num_possible_cpus());
+ WARN_ON(cpu < 0);
/* Workqueues are sometimes created in atomic context */
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);
if (list_is_last(&prev_cws->list, &workqueue_cpu_stat(cpu)->list)) {
spin_unlock_irqrestore(&workqueue_cpu_stat(cpu)->lock, flags);
- for (++cpu ; cpu < num_possible_cpus(); cpu++) {
- ret = workqueue_stat_start_cpu(cpu);
- if (ret)
- return ret;
- }
- return NULL;
+ do {
+ cpu = cpumask_next(cpu, cpu_possible_mask);
+ if (cpu >= nr_cpu_ids)
+ return NULL;
+ } while (!(ret = workqueue_stat_start_cpu(cpu)));
+ return ret;
}
spin_unlock_irqrestore(&workqueue_cpu_stat(cpu)->lock, flags);
--
1.6.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip:tracing/ftrace] tracing: Don't assume possible cpu list have continuous numbers
2009-03-10 1:49 [PATCH] tracing: Don't assume possible cpu list have contenious number KOSAKI Motohiro
@ 2009-03-10 12:18 ` KOSAKI Motohiro
0 siblings, 0 replies; 2+ messages in thread
From: KOSAKI Motohiro @ 2009-03-10 12:18 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, fweisbec, srostedt, tglx,
kosaki.motohiro, laijs, mingo
Commit-ID: bbcd3063597a3824357cd83c501c2a2aa21ef37b
Gitweb: http://git.kernel.org/tip/bbcd3063597a3824357cd83c501c2a2aa21ef37b
Author: "KOSAKI Motohiro" <kosaki.motohiro@jp.fujitsu.com>
AuthorDate: Tue, 10 Mar 2009 10:49:53 +0900
Commit: Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 10 Mar 2009 10:20:30 +0100
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>
---
kernel/trace/trace_workqueue.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/kernel/trace/trace_workqueue.c b/kernel/trace/trace_workqueue.c
index 46c8dc8..739fdac 100644
--- a/kernel/trace/trace_workqueue.c
+++ b/kernel/trace/trace_workqueue.c
@@ -91,7 +91,7 @@ static void probe_workqueue_creation(struct task_struct *wq_thread, int cpu)
struct cpu_workqueue_stats *cws;
unsigned long flags;
- WARN_ON(cpu < 0 || cpu >= num_possible_cpus());
+ WARN_ON(cpu < 0);
/* Workqueues are sometimes created in atomic context */
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);
if (list_is_last(&prev_cws->list, &workqueue_cpu_stat(cpu)->list)) {
spin_unlock_irqrestore(&workqueue_cpu_stat(cpu)->lock, flags);
- for (++cpu ; cpu < num_possible_cpus(); cpu++) {
- ret = workqueue_stat_start_cpu(cpu);
- if (ret)
- return ret;
- }
- return NULL;
+ do {
+ cpu = cpumask_next(cpu, cpu_possible_mask);
+ if (cpu >= nr_cpu_ids)
+ return NULL;
+ } while (!(ret = workqueue_stat_start_cpu(cpu)));
+ return ret;
}
spin_unlock_irqrestore(&workqueue_cpu_stat(cpu)->lock, flags);
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-10 12:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-10 1:49 [PATCH] tracing: Don't assume possible cpu list have contenious number KOSAKI Motohiro
2009-03-10 12:18 ` [tip:tracing/ftrace] tracing: Don't assume possible cpu list have continuous numbers KOSAKI Motohiro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox