Commit 229234ae authored by Robert Richter's avatar Robert Richter

oprofile: adding cpu_buffer_write_commit()

This is in preparation for changes in the cpu buffer implementation.
Signed-off-by: default avatarRobert Richter <robert.richter@amd.com>
parent 7d468abe
...@@ -148,22 +148,6 @@ static unsigned long nr_available_slots(struct oprofile_cpu_buffer const *b) ...@@ -148,22 +148,6 @@ static unsigned long nr_available_slots(struct oprofile_cpu_buffer const *b)
return tail + (b->buffer_size - head) - 1; return tail + (b->buffer_size - head) - 1;
} }
static void increment_head(struct oprofile_cpu_buffer *b)
{
unsigned long new_head = b->head_pos + 1;
/*
* Ensure anything written to the slot before we increment is
* visible
*/
wmb();
if (new_head < b->buffer_size)
b->head_pos = new_head;
else
b->head_pos = 0;
}
static inline void static inline void
add_sample(struct oprofile_cpu_buffer *cpu_buf, add_sample(struct oprofile_cpu_buffer *cpu_buf,
unsigned long pc, unsigned long event) unsigned long pc, unsigned long event)
...@@ -171,7 +155,7 @@ add_sample(struct oprofile_cpu_buffer *cpu_buf, ...@@ -171,7 +155,7 @@ add_sample(struct oprofile_cpu_buffer *cpu_buf,
struct op_sample *entry = cpu_buffer_write_entry(cpu_buf); struct op_sample *entry = cpu_buffer_write_entry(cpu_buf);
entry->eip = pc; entry->eip = pc;
entry->event = event; entry->event = event;
increment_head(cpu_buf); cpu_buffer_write_commit(cpu_buf);
} }
static inline void static inline void
......
...@@ -58,6 +58,23 @@ struct op_sample *cpu_buffer_write_entry(struct oprofile_cpu_buffer *cpu_buf) ...@@ -58,6 +58,23 @@ struct op_sample *cpu_buffer_write_entry(struct oprofile_cpu_buffer *cpu_buf)
return &cpu_buf->buffer[cpu_buf->head_pos]; return &cpu_buf->buffer[cpu_buf->head_pos];
} }
static inline
void cpu_buffer_write_commit(struct oprofile_cpu_buffer *b)
{
unsigned long new_head = b->head_pos + 1;
/*
* Ensure anything written to the slot before we increment is
* visible
*/
wmb();
if (new_head < b->buffer_size)
b->head_pos = new_head;
else
b->head_pos = 0;
}
static inline static inline
struct op_sample *cpu_buffer_read_entry(struct oprofile_cpu_buffer *cpu_buf) struct op_sample *cpu_buffer_read_entry(struct oprofile_cpu_buffer *cpu_buf)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment