Commit 319cb26c authored by Anton Blanchard's avatar Anton Blanchard Committed by Linus Torvalds

[PATCH] use for_each_cpu in oprofile code

Replace open coded versions with for_each_cpu()/for_each_online_cpu().
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 185764d1
...@@ -36,11 +36,8 @@ static void __free_cpu_buffers(int num) ...@@ -36,11 +36,8 @@ static void __free_cpu_buffers(int num)
{ {
int i; int i;
for (i = 0; i < NR_CPUS; ++i) { for_each_online_cpu(i)
if (!cpu_online(i))
continue;
vfree(cpu_buffer[i].buffer); vfree(cpu_buffer[i].buffer);
}
} }
...@@ -50,12 +47,9 @@ int alloc_cpu_buffers(void) ...@@ -50,12 +47,9 @@ int alloc_cpu_buffers(void)
unsigned long buffer_size = fs_cpu_buffer_size; unsigned long buffer_size = fs_cpu_buffer_size;
for (i = 0; i < NR_CPUS; ++i) { for_each_online_cpu(i) {
struct oprofile_cpu_buffer * b = &cpu_buffer[i]; struct oprofile_cpu_buffer * b = &cpu_buffer[i];
if (!cpu_online(i))
continue;
b->buffer = vmalloc(sizeof(struct op_sample) * buffer_size); b->buffer = vmalloc(sizeof(struct op_sample) * buffer_size);
if (!b->buffer) if (!b->buffer)
goto fail; goto fail;
...@@ -94,12 +88,9 @@ void start_cpu_timers(void) ...@@ -94,12 +88,9 @@ void start_cpu_timers(void)
timers_enabled = 1; timers_enabled = 1;
for (i = 0; i < NR_CPUS; ++i) { for_each_online_cpu(i) {
struct oprofile_cpu_buffer * b = &cpu_buffer[i]; struct oprofile_cpu_buffer * b = &cpu_buffer[i];
if (!cpu_online(i))
continue;
add_timer_on(&b->timer, i); add_timer_on(&b->timer, i);
} }
} }
...@@ -111,12 +102,9 @@ void end_cpu_timers(void) ...@@ -111,12 +102,9 @@ void end_cpu_timers(void)
timers_enabled = 0; timers_enabled = 0;
for (i = 0; i < NR_CPUS; ++i) { for_each_online_cpu(i) {
struct oprofile_cpu_buffer * b = &cpu_buffer[i]; struct oprofile_cpu_buffer * b = &cpu_buffer[i];
if (!cpu_online(i))
continue;
del_timer_sync(&b->timer); del_timer_sync(&b->timer);
} }
......
...@@ -22,10 +22,7 @@ void oprofile_reset_stats(void) ...@@ -22,10 +22,7 @@ void oprofile_reset_stats(void)
struct oprofile_cpu_buffer * cpu_buf; struct oprofile_cpu_buffer * cpu_buf;
int i; int i;
for (i = 0; i < NR_CPUS; ++i) { for_each_cpu(i) {
if (!cpu_possible(i))
continue;
cpu_buf = &cpu_buffer[i]; cpu_buf = &cpu_buffer[i];
cpu_buf->sample_received = 0; cpu_buf->sample_received = 0;
cpu_buf->sample_lost_overflow = 0; cpu_buf->sample_lost_overflow = 0;
...@@ -49,10 +46,7 @@ void oprofile_create_stats_files(struct super_block * sb, struct dentry * root) ...@@ -49,10 +46,7 @@ void oprofile_create_stats_files(struct super_block * sb, struct dentry * root)
if (!dir) if (!dir)
return; return;
for (i = 0; i < NR_CPUS; ++i) { for_each_cpu(i) {
if (!cpu_possible(i))
continue;
cpu_buf = &cpu_buffer[i]; cpu_buf = &cpu_buffer[i];
snprintf(buf, 10, "cpu%d", i); snprintf(buf, 10, "cpu%d", i);
cpudir = oprofilefs_mkdir(sb, dir, buf); cpudir = oprofilefs_mkdir(sb, dir, buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment