forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
Robert Richter
committed
Jan 7, 2009
1 parent
2d87b14
commit ae735e9
Showing
4 changed files
with
106 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,15 @@ | |
* @file op_model_amd.c | ||
* athlon / K7 / K8 / Family 10h model-specific MSR operations | ||
* | ||
* @remark Copyright 2002-2008 OProfile authors | ||
* @remark Copyright 2002-2009 OProfile authors | ||
* @remark Read the file COPYING | ||
* | ||
* @author John Levon | ||
* @author Philippe Elie | ||
* @author Graydon Hoare | ||
* @author Robert Richter <[email protected]> | ||
* @author Barry Kasindorf | ||
*/ | ||
*/ | ||
|
||
#include <linux/oprofile.h> | ||
#include <linux/device.h> | ||
|
@@ -62,8 +62,8 @@ static unsigned long reset_value[NUM_COUNTERS]; | |
|
||
/* Codes used in cpu_buffer.c */ | ||
/* This produces duplicate code, need to be fixed */ | ||
#define IBS_FETCH_BEGIN 3 | ||
#define IBS_OP_BEGIN 4 | ||
#define IBS_FETCH_BEGIN (1UL << 4) | ||
#define IBS_OP_BEGIN (1UL << 5) | ||
|
||
/* | ||
* The function interface needs to be fixed, something like add | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
* @author Barry Kasindorf | ||
* @author Robert Richter <[email protected]> | ||
* | ||
* 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; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters