Skip to content

Commit fbc9bf9

Browse files
author
Robert Richter
committed
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>
1 parent bf589e3 commit fbc9bf9

3 files changed

Lines changed: 14 additions & 27 deletions

File tree

‎drivers/oprofile/buffer_sync.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ void sync_buffer(int cpu)
548548

549549
/* Remember, only we can modify tail_pos */
550550

551+
cpu_buffer_reset(cpu);
551552
#ifndef CONFIG_OPROFILE_IBS
552553
available = cpu_buffer_entries(cpu_buf);
553554

‎drivers/oprofile/cpu_buffer.c‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,6 @@ void end_cpu_work(void)
124124
flush_scheduled_work();
125125
}
126126

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-
139127
/* compute number of available slots in cpu_buffer queue */
140128
static unsigned long nr_available_slots(struct oprofile_cpu_buffer const *b)
141129
{

‎drivers/oprofile/cpu_buffer.h‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,19 @@ struct oprofile_cpu_buffer {
5050

5151
DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer);
5252

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+
}
5466

5567
static inline
5668
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)
88100
unsigned long head = b->head_pos;
89101
unsigned long tail = b->tail_pos;
90102

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-
105103
if (head >= tail)
106104
return head - tail;
107105

0 commit comments

Comments
 (0)