Commit 229234ae4a5ed9376b2e0524da04b0e5edadbf76

Authored by Robert Richter
1 parent 7d468abee0

oprofile: adding cpu_buffer_write_commit()

This is in preparation for changes in the cpu buffer implementation.

Signed-off-by: Robert Richter <robert.richter@amd.com>

Showing 2 changed files with 18 additions and 17 deletions Side-by-side Diff

drivers/oprofile/cpu_buffer.c
... ... @@ -148,22 +148,6 @@
148 148 return tail + (b->buffer_size - head) - 1;
149 149 }
150 150  
151   -static void increment_head(struct oprofile_cpu_buffer *b)
152   -{
153   - unsigned long new_head = b->head_pos + 1;
154   -
155   - /*
156   - * Ensure anything written to the slot before we increment is
157   - * visible
158   - */
159   - wmb();
160   -
161   - if (new_head < b->buffer_size)
162   - b->head_pos = new_head;
163   - else
164   - b->head_pos = 0;
165   -}
166   -
167 151 static inline void
168 152 add_sample(struct oprofile_cpu_buffer *cpu_buf,
169 153 unsigned long pc, unsigned long event)
... ... @@ -171,7 +155,7 @@
171 155 struct op_sample *entry = cpu_buffer_write_entry(cpu_buf);
172 156 entry->eip = pc;
173 157 entry->event = event;
174   - increment_head(cpu_buf);
  158 + cpu_buffer_write_commit(cpu_buf);
175 159 }
176 160  
177 161 static inline void
drivers/oprofile/cpu_buffer.h
... ... @@ -59,6 +59,23 @@
59 59 }
60 60  
61 61 static inline
  62 +void cpu_buffer_write_commit(struct oprofile_cpu_buffer *b)
  63 +{
  64 + unsigned long new_head = b->head_pos + 1;
  65 +
  66 + /*
  67 + * Ensure anything written to the slot before we increment is
  68 + * visible
  69 + */
  70 + wmb();
  71 +
  72 + if (new_head < b->buffer_size)
  73 + b->head_pos = new_head;
  74 + else
  75 + b->head_pos = 0;
  76 +}
  77 +
  78 +static inline
62 79 struct op_sample *cpu_buffer_read_entry(struct oprofile_cpu_buffer *cpu_buf)
63 80 {
64 81 return &cpu_buf->buffer[cpu_buf->tail_pos];