summaryrefslogtreecommitdiffstats
path: root/drivers/oprofile/buffer_sync.c
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2008-12-25 17:26:07 +0100
committerRobert Richter <robert.richter@amd.com>2009-01-07 22:40:47 +0100
commitae735e9964b4584923f2997d98a8d80ae9c1a75c (patch)
tree0fc72d18bcc5951f9dd519e8a4527593724b816f /drivers/oprofile/buffer_sync.c
parent2d87b14cf8d0b07720de26d90789d02124141616 (diff)
downloadblackbird-op-linux-ae735e9964b4584923f2997d98a8d80ae9c1a75c.tar.gz
blackbird-op-linux-ae735e9964b4584923f2997d98a8d80ae9c1a75c.zip
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 908202afbae9..d969bb13a252 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -1,11 +1,12 @@
/**
* @file buffer_sync.c
*
- * @remark Copyright 2002 OProfile authors
+ * @remark Copyright 2002-2009 OProfile authors
* @remark Read the file COPYING
*
* @author John Levon <levon@movementarian.org>
* @author Barry Kasindorf
+ * @author Robert Richter <robert.richter@amd.com>
*
* This is the core of the buffer management. Each
* CPU buffer is processed and entered into the
@@ -529,6 +530,7 @@ void sync_buffer(int cpu)
sync_buffer_state state = sb_buffer_start;
unsigned int i;
unsigned long available;
+ unsigned long flags;
struct op_entry entry;
struct op_sample *sample;
@@ -545,38 +547,34 @@ void sync_buffer(int cpu)
break;
if (is_code(sample->eip)) {
- switch (sample->event) {
- case 0:
- case CPU_IS_KERNEL:
+ flags = sample->event;
+ if (flags & TRACE_BEGIN) {
+ state = sb_bt_start;
+ add_trace_begin();
+ }
+ if (flags & KERNEL_CTX_SWITCH) {
/* kernel/userspace switch */
- in_kernel = sample->event;
+ in_kernel = flags & IS_KERNEL;
if (state == sb_buffer_start)
state = sb_sample_start;
- add_kernel_ctx_switch(sample->event);
- break;
- case CPU_TRACE_BEGIN:
- state = sb_bt_start;
- add_trace_begin();
- break;
-#ifdef CONFIG_OPROFILE_IBS
- case IBS_FETCH_BEGIN:
- add_ibs_begin(cpu, IBS_FETCH_CODE, mm);
- break;
- case IBS_OP_BEGIN:
- add_ibs_begin(cpu, IBS_OP_CODE, mm);
- break;
-#endif
- default:
+ add_kernel_ctx_switch(flags & IS_KERNEL);
+ }
+ if (flags & USER_CTX_SWITCH) {
/* userspace context switch */
oldmm = mm;
- new = (struct task_struct *)sample->event;
+ new = (struct task_struct *)sample->data[0];
release_mm(oldmm);
mm = take_tasks_mm(new);
if (mm != oldmm)
cookie = get_exec_dcookie(mm);
add_user_ctx_switch(new, cookie);
- break;
}
+#ifdef CONFIG_OPROFILE_IBS
+ if (flags & IBS_FETCH_BEGIN)
+ add_ibs_begin(cpu, IBS_FETCH_CODE, mm);
+ if (flags & IBS_OP_BEGIN)
+ add_ibs_begin(cpu, IBS_OP_CODE, mm);
+#endif
continue;
}
OpenPOWER on IntegriCloud