aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/oprofile/buffer_sync.c
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2008-12-25 11:26:07 -0500
committerRobert Richter <robert.richter@amd.com>2009-01-07 16:40:47 -0500
commitae735e9964b4584923f2997d98a8d80ae9c1a75c (patch)
tree0fc72d18bcc5951f9dd519e8a4527593724b816f /drivers/oprofile/buffer_sync.c
parent2d87b14cf8d0b07720de26d90789d02124141616 (diff)
oprofile: rework implementation of cpu buffer events
Special events such as task or context switches are marked with an escape code in the cpu buffer followed by an event code or a task identifier. There is one escape code per event. To make escape sequences also available for data samples the internal cpu buffer format must be changed. The current implementation does not allow the extension of event codes since this would lead to collisions with the task identifiers. To avoid this, this patch introduces an event mask that allows the storage of multiple events with one escape code. Now, task identifiers are stored in the data section of the sample. The implementation also allows the usage of custom data in a sample. As a side effect the new code is much more readable and easier to understand. Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'drivers/oprofile/buffer_sync.c')
-rw-r--r--drivers/oprofile/buffer_sync.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index 908202afbae..d969bb13a25 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -1,11 +1,12 @@
1/** 1/**
2 * @file buffer_sync.c 2 * @file buffer_sync.c
3 * 3 *
4 * @remark Copyright 2002 OProfile authors 4 * @remark Copyright 2002-2009 OProfile authors
5 * @remark Read the file COPYING 5 * @remark Read the file COPYING
6 * 6 *
7 * @author John Levon <levon@movementarian.org> 7 * @author John Levon <levon@movementarian.org>
8 * @author Barry Kasindorf 8 * @author Barry Kasindorf
9 * @author Robert Richter <robert.richter@amd.com>
9 * 10 *
10 * This is the core of the buffer management. Each 11 * This is the core of the buffer management. Each
11 * CPU buffer is processed and entered into the 12 * CPU buffer is processed and entered into the
@@ -529,6 +530,7 @@ void sync_buffer(int cpu)
529 sync_buffer_state state = sb_buffer_start; 530 sync_buffer_state state = sb_buffer_start;
530 unsigned int i; 531 unsigned int i;
531 unsigned long available; 532 unsigned long available;
533 unsigned long flags;
532 struct op_entry entry; 534 struct op_entry entry;
533 struct op_sample *sample; 535 struct op_sample *sample;
534 536
@@ -545,38 +547,34 @@ void sync_buffer(int cpu)
545 break; 547 break;
546 548
547 if (is_code(sample->eip)) { 549 if (is_code(sample->eip)) {
548 switch (sample->event) { 550 flags = sample->event;
549 case 0: 551 if (flags & TRACE_BEGIN) {
550 case CPU_IS_KERNEL: 552 state = sb_bt_start;
553 add_trace_begin();
554 }
555 if (flags & KERNEL_CTX_SWITCH) {
551 /* kernel/userspace switch */ 556 /* kernel/userspace switch */
552 in_kernel = sample->event; 557 in_kernel = flags & IS_KERNEL;
553 if (state == sb_buffer_start) 558 if (state == sb_buffer_start)
554 state = sb_sample_start; 559 state = sb_sample_start;
555 add_kernel_ctx_switch(sample->event); 560 add_kernel_ctx_switch(flags & IS_KERNEL);
556 break; 561 }
557 case CPU_TRACE_BEGIN: 562 if (flags & USER_CTX_SWITCH) {
558 state = sb_bt_start;
559 add_trace_begin();
560 break;
561#ifdef CONFIG_OPROFILE_IBS
562 case IBS_FETCH_BEGIN:
563 add_ibs_begin(cpu, IBS_FETCH_CODE, mm);
564 break;
565 case IBS_OP_BEGIN:
566 add_ibs_begin(cpu, IBS_OP_CODE, mm);
567 break;
568#endif
569 default:
570 /* userspace context switch */ 563 /* userspace context switch */
571 oldmm = mm; 564 oldmm = mm;
572 new = (struct task_struct *)sample->event; 565 new = (struct task_struct *)sample->data[0];
573 release_mm(oldmm); 566 release_mm(oldmm);
574 mm = take_tasks_mm(new); 567 mm = take_tasks_mm(new);
575 if (mm != oldmm) 568 if (mm != oldmm)
576 cookie = get_exec_dcookie(mm); 569 cookie = get_exec_dcookie(mm);
577 add_user_ctx_switch(new, cookie); 570 add_user_ctx_switch(new, cookie);
578 break;
579 } 571 }
572#ifdef CONFIG_OPROFILE_IBS
573 if (flags & IBS_FETCH_BEGIN)
574 add_ibs_begin(cpu, IBS_FETCH_CODE, mm);
575 if (flags & IBS_OP_BEGIN)
576 add_ibs_begin(cpu, IBS_OP_CODE, mm);
577#endif
580 continue; 578 continue;
581 } 579 }
582 580