diff options
author | Robert Richter <robert.richter@amd.com> | 2008-09-26 17:50:31 -0400 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2008-12-10 08:20:09 -0500 |
commit | fd7826d56bde11ab142d2431093773ad2b3f0a59 (patch) | |
tree | 35f84fb4a49fbbec86fba399181cbac015e9e3f9 | |
parent | fe615cbf34fc6a1c53c359417da4696328a488ed (diff) |
oprofile: implement switch/case in buffer_sync.c
Signed-off-by: Robert Richter <robert.richter@amd.com>
-rw-r--r-- | drivers/oprofile/buffer_sync.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c index 774b081b9b7f..7d61ae8ee8cf 100644 --- a/drivers/oprofile/buffer_sync.c +++ b/drivers/oprofile/buffer_sync.c | |||
@@ -561,6 +561,7 @@ void sync_buffer(int cpu) | |||
561 | { | 561 | { |
562 | struct oprofile_cpu_buffer *cpu_buf = &per_cpu(cpu_buffer, cpu); | 562 | struct oprofile_cpu_buffer *cpu_buf = &per_cpu(cpu_buffer, cpu); |
563 | struct mm_struct *mm = NULL; | 563 | struct mm_struct *mm = NULL; |
564 | struct mm_struct *oldmm; | ||
564 | struct task_struct *new; | 565 | struct task_struct *new; |
565 | unsigned long cookie = 0; | 566 | unsigned long cookie = 0; |
566 | int in_kernel = 1; | 567 | int in_kernel = 1; |
@@ -586,34 +587,39 @@ void sync_buffer(int cpu) | |||
586 | struct op_sample *s = &cpu_buf->buffer[cpu_buf->tail_pos]; | 587 | struct op_sample *s = &cpu_buf->buffer[cpu_buf->tail_pos]; |
587 | 588 | ||
588 | if (is_code(s->eip)) { | 589 | if (is_code(s->eip)) { |
589 | if (s->event <= CPU_IS_KERNEL) { | 590 | switch (s->event) { |
591 | case 0: | ||
592 | case CPU_IS_KERNEL: | ||
590 | /* kernel/userspace switch */ | 593 | /* kernel/userspace switch */ |
591 | in_kernel = s->event; | 594 | in_kernel = s->event; |
592 | if (state == sb_buffer_start) | 595 | if (state == sb_buffer_start) |
593 | state = sb_sample_start; | 596 | state = sb_sample_start; |
594 | add_kernel_ctx_switch(s->event); | 597 | add_kernel_ctx_switch(s->event); |
595 | } else if (s->event == CPU_TRACE_BEGIN) { | 598 | break; |
599 | case CPU_TRACE_BEGIN: | ||
596 | state = sb_bt_start; | 600 | state = sb_bt_start; |
597 | add_trace_begin(); | 601 | add_trace_begin(); |
602 | break; | ||
598 | #ifdef CONFIG_OPROFILE_IBS | 603 | #ifdef CONFIG_OPROFILE_IBS |
599 | } else if (s->event == IBS_FETCH_BEGIN) { | 604 | case IBS_FETCH_BEGIN: |
600 | state = sb_bt_start; | 605 | state = sb_bt_start; |
601 | add_ibs_begin(cpu_buf, IBS_FETCH_CODE, mm); | 606 | add_ibs_begin(cpu_buf, IBS_FETCH_CODE, mm); |
602 | } else if (s->event == IBS_OP_BEGIN) { | 607 | break; |
608 | case IBS_OP_BEGIN: | ||
603 | state = sb_bt_start; | 609 | state = sb_bt_start; |
604 | add_ibs_begin(cpu_buf, IBS_OP_CODE, mm); | 610 | add_ibs_begin(cpu_buf, IBS_OP_CODE, mm); |
611 | break; | ||
605 | #endif | 612 | #endif |
606 | } else { | 613 | default: |
607 | struct mm_struct *oldmm = mm; | ||
608 | |||
609 | /* userspace context switch */ | 614 | /* userspace context switch */ |
615 | oldmm = mm; | ||
610 | new = (struct task_struct *)s->event; | 616 | new = (struct task_struct *)s->event; |
611 | |||
612 | release_mm(oldmm); | 617 | release_mm(oldmm); |
613 | mm = take_tasks_mm(new); | 618 | mm = take_tasks_mm(new); |
614 | if (mm != oldmm) | 619 | if (mm != oldmm) |
615 | cookie = get_exec_dcookie(mm); | 620 | cookie = get_exec_dcookie(mm); |
616 | add_user_ctx_switch(new, cookie); | 621 | add_user_ctx_switch(new, cookie); |
622 | break; | ||
617 | } | 623 | } |
618 | } else if (state >= sb_bt_start && | 624 | } else if (state >= sb_bt_start && |
619 | !add_sample(mm, s, in_kernel)) { | 625 | !add_sample(mm, s, in_kernel)) { |