diff options
| author | Andrew Morton <akpm@osdl.org> | 2004-01-18 18:30:55 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.osdl.org> | 2004-01-18 18:30:55 -0800 |
| commit | 012061cc70e9c7e0d794a3e609fd79fdf9f5267d (patch) | |
| tree | a1a1cee6d1e7b4576a7ee148e297c04936388402 /kernel | |
| parent | 90c7f71962cc5aa0bf128ce68b9a8607176558c4 (diff) | |
[PATCH] Use for_each_cpu() Where It's Meant To Be
From: Rusty Russell <rusty@rustcorp.com.au>
Some places use cpu_online() where they should be using cpu_possible, most
commonly for tallying statistics. This makes no difference without hotplug
CPU.
Use the for_each_cpu() macro in those places, providing good examples (and
making the external hotplug CPU patch smaller).
Some places use cpu_online() where they should be using cpu_possible, most
commonly for tallying statistics. This makes no difference without hotplug
CPU.
Use the for_each_cpu() macro in those places, providing good examples (and
making the external hotplug CPU patch smaller).
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/fork.c | 7 | ||||
| -rw-r--r-- | kernel/sched.c | 18 | ||||
| -rw-r--r-- | kernel/timer.c | 5 | ||||
| -rw-r--r-- | kernel/workqueue.c | 4 |
4 files changed, 11 insertions, 23 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index b9a13609b635..ea2eeb1ed644 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -60,10 +60,9 @@ int nr_processes(void) int cpu; int total = 0; - for (cpu = 0; cpu < NR_CPUS; cpu++) { - if (cpu_online(cpu)) - total += per_cpu(process_counts, cpu); - } + for_each_cpu(cpu) + total += per_cpu(process_counts, cpu); + return total; } diff --git a/kernel/sched.c b/kernel/sched.c index 7cccd854709f..87c77974e10a 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -902,11 +902,9 @@ unsigned long nr_uninterruptible(void) { unsigned long i, sum = 0; - for (i = 0; i < NR_CPUS; i++) { - if (!cpu_online(i)) - continue; + for_each_cpu(i) sum += cpu_rq(i)->nr_uninterruptible; - } + return sum; } @@ -914,11 +912,9 @@ unsigned long nr_context_switches(void) { unsigned long i, sum = 0; - for (i = 0; i < NR_CPUS; i++) { - if (!cpu_online(i)) - continue; + for_each_cpu(i) sum += cpu_rq(i)->nr_switches; - } + return sum; } @@ -926,11 +922,9 @@ unsigned long nr_iowait(void) { unsigned long i, sum = 0; - for (i = 0; i < NR_CPUS; ++i) { - if (!cpu_online(i)) - continue; + for_each_cpu(i) sum += atomic_read(&cpu_rq(i)->nr_iowait); - } + return sum; } diff --git a/kernel/timer.c b/kernel/timer.c index a9c8c1958b6a..51df7364331c 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -332,10 +332,7 @@ int del_timer_sync(struct timer_list *timer) del_again: ret += del_timer(timer); - for (i = 0; i < NR_CPUS; i++) { - if (!cpu_online(i)) - continue; - + for_each_cpu(i) { base = &per_cpu(tvec_bases, i); if (base->running_timer == timer) { while (base->running_timer == timer) { diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 7b77fb75dc07..4b109a7d390b 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -366,9 +366,7 @@ int current_is_keventd(void) BUG_ON(!keventd_wq); - for (cpu = 0; cpu < NR_CPUS; cpu++) { - if (!cpu_online(cpu)) - continue; + for_each_cpu(cpu) { cwq = keventd_wq->cpu_wq + cpu; if (current == cwq->thread) return 1; |
