]> git.hungrycats.org Git - linux/commitdiff
[PATCH] use for_each_cpu in oprofile code
authorAnton Blanchard <anton@samba.org>
Wed, 8 Sep 2004 00:57:15 +0000 (17:57 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 8 Sep 2004 00:57:15 +0000 (17:57 -0700)
Replace open coded versions with for_each_cpu()/for_each_online_cpu().

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/oprofile/cpu_buffer.c
drivers/oprofile/oprofile_stats.c

index 1f6efb0686afd7c3d9bdd7a21cbd4536a968c361..5dbda9c5fd2f5a2a1c5e1e160a56bf33dcddffd0 100644 (file)
@@ -36,11 +36,8 @@ static void __free_cpu_buffers(int num)
 {
        int i;
  
-       for (i = 0; i < NR_CPUS; ++i) {
-               if (!cpu_online(i))
-                       continue;
+       for_each_online_cpu(i)
                vfree(cpu_buffer[i].buffer);
-       }
 }
  
  
@@ -50,12 +47,9 @@ int alloc_cpu_buffers(void)
  
        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];
  
-               if (!cpu_online(i))
-                       continue;
-
                b->buffer = vmalloc(sizeof(struct op_sample) * buffer_size);
                if (!b->buffer)
                        goto fail;
@@ -94,12 +88,9 @@ void start_cpu_timers(void)
 
        timers_enabled = 1;
 
-       for (i = 0; i < NR_CPUS; ++i) {
+       for_each_online_cpu(i) {
                struct oprofile_cpu_buffer * b = &cpu_buffer[i];
 
-               if (!cpu_online(i))
-                       continue;
-
                add_timer_on(&b->timer, i);
        }
 }
@@ -111,12 +102,9 @@ void end_cpu_timers(void)
 
        timers_enabled = 0;
 
-       for (i = 0; i < NR_CPUS; ++i) {
+       for_each_online_cpu(i) {
                struct oprofile_cpu_buffer * b = &cpu_buffer[i];
 
-               if (!cpu_online(i))
-                       continue;
-
                del_timer_sync(&b->timer);
        }
 
index 06dc3009385e0b69496d921355acb6b4871fa49d..3ec23d8a643befe3e2c04a47eb6abf31ff5a1227 100644 (file)
@@ -22,10 +22,7 @@ void oprofile_reset_stats(void)
        struct oprofile_cpu_buffer * cpu_buf; 
        int i;
  
-       for (i = 0; i < NR_CPUS; ++i) {
-               if (!cpu_possible(i))
-                       continue;
-
+       for_each_cpu(i) {
                cpu_buf = &cpu_buffer[i]; 
                cpu_buf->sample_received = 0;
                cpu_buf->sample_lost_overflow = 0;
@@ -49,10 +46,7 @@ void oprofile_create_stats_files(struct super_block * sb, struct dentry * root)
        if (!dir)
                return;
 
-       for (i = 0; i < NR_CPUS; ++i) {
-               if (!cpu_possible(i))
-                       continue;
-
+       for_each_cpu(i) {
                cpu_buf = &cpu_buffer[i]; 
                snprintf(buf, 10, "cpu%d", i);
                cpudir = oprofilefs_mkdir(sb, dir, buf);