diff options
author | Robert Richter <robert.richter@amd.com> | 2008-12-04 10:27:00 -0500 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2008-12-10 08:20:16 -0500 |
commit | fbc9bf9f0ed4f0fbc47dcb5b1c26c28c93b60e33 (patch) | |
tree | 30cf2c1e7e2e7c0277c61758280edcbcd9689292 /drivers/oprofile | |
parent | bf589e32960181fa8cbca7bfdd92265e49dc2dfa (diff) |
oprofile: moving cpu_buffer_reset() to cpu_buffer.h
This is in preparation for changes in the cpu buffer implementation.
Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'drivers/oprofile')
-rw-r--r-- | drivers/oprofile/buffer_sync.c | 1 | ||||
-rw-r--r-- | drivers/oprofile/cpu_buffer.c | 12 | ||||
-rw-r--r-- | drivers/oprofile/cpu_buffer.h | 28 |
3 files changed, 14 insertions, 27 deletions
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c index aed286c3f16e..944a5832d9e4 100644 --- a/drivers/oprofile/buffer_sync.c +++ b/drivers/oprofile/buffer_sync.c | |||
@@ -548,6 +548,7 @@ void sync_buffer(int cpu) | |||
548 | 548 | ||
549 | /* Remember, only we can modify tail_pos */ | 549 | /* Remember, only we can modify tail_pos */ |
550 | 550 | ||
551 | cpu_buffer_reset(cpu); | ||
551 | #ifndef CONFIG_OPROFILE_IBS | 552 | #ifndef CONFIG_OPROFILE_IBS |
552 | available = cpu_buffer_entries(cpu_buf); | 553 | available = cpu_buffer_entries(cpu_buf); |
553 | 554 | ||
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c index d6f5de686363..5cf7efe38e67 100644 --- a/drivers/oprofile/cpu_buffer.c +++ b/drivers/oprofile/cpu_buffer.c | |||
@@ -124,18 +124,6 @@ void end_cpu_work(void) | |||
124 | flush_scheduled_work(); | 124 | flush_scheduled_work(); |
125 | } | 125 | } |
126 | 126 | ||
127 | /* Resets the cpu buffer to a sane state. */ | ||
128 | void cpu_buffer_reset(struct oprofile_cpu_buffer *cpu_buf) | ||
129 | { | ||
130 | /* | ||
131 | * reset these to invalid values; the next sample collected | ||
132 | * will populate the buffer with proper values to initialize | ||
133 | * the buffer | ||
134 | */ | ||
135 | cpu_buf->last_is_kernel = -1; | ||
136 | cpu_buf->last_task = NULL; | ||
137 | } | ||
138 | |||
139 | /* compute number of available slots in cpu_buffer queue */ | 127 | /* compute number of available slots in cpu_buffer queue */ |
140 | static unsigned long nr_available_slots(struct oprofile_cpu_buffer const *b) | 128 | static unsigned long nr_available_slots(struct oprofile_cpu_buffer const *b) |
141 | { | 129 | { |
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h index 6055b5678394..895763f065e9 100644 --- a/drivers/oprofile/cpu_buffer.h +++ b/drivers/oprofile/cpu_buffer.h | |||
@@ -50,7 +50,19 @@ struct oprofile_cpu_buffer { | |||
50 | 50 | ||
51 | DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer); | 51 | DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer); |
52 | 52 | ||
53 | void cpu_buffer_reset(struct oprofile_cpu_buffer *cpu_buf); | 53 | /* |
54 | * Resets the cpu buffer to a sane state. | ||
55 | * | ||
56 | * reset these to invalid values; the next sample collected will | ||
57 | * populate the buffer with proper values to initialize the buffer | ||
58 | */ | ||
59 | static inline void cpu_buffer_reset(int cpu) | ||
60 | { | ||
61 | struct oprofile_cpu_buffer *cpu_buf = &per_cpu(cpu_buffer, cpu); | ||
62 | |||
63 | cpu_buf->last_is_kernel = -1; | ||
64 | cpu_buf->last_task = NULL; | ||
65 | } | ||
54 | 66 | ||
55 | static inline | 67 | static inline |
56 | struct op_sample *cpu_buffer_write_entry(struct oprofile_cpu_buffer *cpu_buf) | 68 | struct op_sample *cpu_buffer_write_entry(struct oprofile_cpu_buffer *cpu_buf) |
@@ -88,20 +100,6 @@ unsigned long cpu_buffer_entries(struct oprofile_cpu_buffer *b) | |||
88 | unsigned long head = b->head_pos; | 100 | unsigned long head = b->head_pos; |
89 | unsigned long tail = b->tail_pos; | 101 | unsigned long tail = b->tail_pos; |
90 | 102 | ||
91 | /* | ||
92 | * Subtle. This resets the persistent last_task | ||
93 | * and in_kernel values used for switching notes. | ||
94 | * BUT, there is a small window between reading | ||
95 | * head_pos, and this call, that means samples | ||
96 | * can appear at the new head position, but not | ||
97 | * be prefixed with the notes for switching | ||
98 | * kernel mode or a task switch. This small hole | ||
99 | * can lead to mis-attribution or samples where | ||
100 | * we don't know if it's in the kernel or not, | ||
101 | * at the start of an event buffer. | ||
102 | */ | ||
103 | cpu_buffer_reset(b); | ||
104 | |||
105 | if (head >= tail) | 103 | if (head >= tail) |
106 | return head - tail; | 104 | return head - tail; |
107 | 105 | ||