Skip to content

Commit

Permalink
oprofile: adding cpu_buffer_write_commit()
Browse files Browse the repository at this point in the history
This is in preparation for changes in the cpu buffer implementation.

Signed-off-by: Robert Richter <robert.richter@amd.com>
  • Loading branch information
Robert Richter committed Dec 10, 2008
1 parent 7d468ab commit 229234a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
18 changes: 1 addition & 17 deletions drivers/oprofile/cpu_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,30 +148,14 @@ static unsigned long nr_available_slots(struct oprofile_cpu_buffer const *b)
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
add_sample(struct oprofile_cpu_buffer *cpu_buf,
unsigned long pc, unsigned long event)
{
struct op_sample *entry = cpu_buffer_write_entry(cpu_buf);
entry->eip = pc;
entry->event = event;
increment_head(cpu_buf);
cpu_buffer_write_commit(cpu_buf);
}

static inline void
Expand Down
17 changes: 17 additions & 0 deletions drivers/oprofile/cpu_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

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
struct op_sample *cpu_buffer_read_entry(struct oprofile_cpu_buffer *cpu_buf)
{
Expand Down

0 comments on commit 229234a

Please sign in to comment.