]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
oprofile: implement switch/case in buffer_sync.c
authorRobert Richter <robert.richter@amd.com>
Fri, 26 Sep 2008 21:50:31 +0000 (17:50 -0400)
committerRobert Richter <robert.richter@amd.com>
Wed, 10 Dec 2008 13:20:09 +0000 (14:20 +0100)
Signed-off-by: Robert Richter <robert.richter@amd.com>
drivers/oprofile/buffer_sync.c

index 774b081b9b7f4d7d56828d6455251c5d0f4bc4bf..7d61ae8ee8cf64a07c83fa3a898dbf6ddcf325ec 100644 (file)
@@ -561,6 +561,7 @@ void sync_buffer(int cpu)
 {
        struct oprofile_cpu_buffer *cpu_buf = &per_cpu(cpu_buffer, cpu);
        struct mm_struct *mm = NULL;
+       struct mm_struct *oldmm;
        struct task_struct *new;
        unsigned long cookie = 0;
        int in_kernel = 1;
@@ -586,34 +587,39 @@ void sync_buffer(int cpu)
                struct op_sample *s = &cpu_buf->buffer[cpu_buf->tail_pos];
 
                if (is_code(s->eip)) {
-                       if (s->event <= CPU_IS_KERNEL) {
+                       switch (s->event) {
+                       case 0:
+                       case CPU_IS_KERNEL:
                                /* kernel/userspace switch */
                                in_kernel = s->event;
                                if (state == sb_buffer_start)
                                        state = sb_sample_start;
                                add_kernel_ctx_switch(s->event);
-                       } else if (s->event == CPU_TRACE_BEGIN) {
+                               break;
+                       case CPU_TRACE_BEGIN:
                                state = sb_bt_start;
                                add_trace_begin();
+                               break;
 #ifdef CONFIG_OPROFILE_IBS
-                       } else if (s->event == IBS_FETCH_BEGIN) {
+                       case IBS_FETCH_BEGIN:
                                state = sb_bt_start;
                                add_ibs_begin(cpu_buf, IBS_FETCH_CODE, mm);
-                       } else if (s->event == IBS_OP_BEGIN) {
+                               break;
+                       case IBS_OP_BEGIN:
                                state = sb_bt_start;
                                add_ibs_begin(cpu_buf, IBS_OP_CODE, mm);
+                               break;
 #endif
-                       } else {
-                               struct mm_struct *oldmm = mm;
-
+                       default:
                                /* userspace context switch */
+                               oldmm = mm;
                                new = (struct task_struct *)s->event;
-
                                release_mm(oldmm);
                                mm = take_tasks_mm(new);
                                if (mm != oldmm)
                                        cookie = get_exec_dcookie(mm);
                                add_user_ctx_switch(new, cookie);
+                               break;
                        }
                } else if (state >= sb_bt_start &&
                           !add_sample(mm, s, in_kernel)) {