diff options
author | Robert Richter <robert.richter@amd.com> | 2008-11-27 12:36:08 -0500 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2008-12-10 08:20:14 -0500 |
commit | 229234ae4a5ed9376b2e0524da04b0e5edadbf76 (patch) | |
tree | 9f0434cbac64aa2d040b0b806d239b2335c163e1 /drivers | |
parent | 7d468abee0f1a7e918b5e2f23120436a54ba9f33 (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/oprofile/cpu_buffer.c | 18 | ||||
-rw-r--r-- | drivers/oprofile/cpu_buffer.h | 17 |
2 files changed, 18 insertions, 17 deletions
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c index 7e5e650e409f..d6f5de686363 100644 --- a/drivers/oprofile/cpu_buffer.c +++ b/drivers/oprofile/cpu_buffer.c | |||
@@ -148,22 +148,6 @@ static unsigned long nr_available_slots(struct oprofile_cpu_buffer const *b) | |||
148 | return tail + (b->buffer_size - head) - 1; | 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 | static inline void | 151 | static inline void |
168 | add_sample(struct oprofile_cpu_buffer *cpu_buf, | 152 | add_sample(struct oprofile_cpu_buffer *cpu_buf, |
169 | unsigned long pc, unsigned long event) | 153 | unsigned long pc, unsigned long event) |
@@ -171,7 +155,7 @@ add_sample(struct oprofile_cpu_buffer *cpu_buf, | |||
171 | struct op_sample *entry = cpu_buffer_write_entry(cpu_buf); | 155 | struct op_sample *entry = cpu_buffer_write_entry(cpu_buf); |
172 | entry->eip = pc; | 156 | entry->eip = pc; |
173 | entry->event = event; | 157 | entry->event = event; |
174 | increment_head(cpu_buf); | 158 | cpu_buffer_write_commit(cpu_buf); |
175 | } | 159 | } |
176 | 160 | ||
177 | static inline void | 161 | static inline void |
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h index 08706991fdd2..e6089768ae66 100644 --- a/drivers/oprofile/cpu_buffer.h +++ b/drivers/oprofile/cpu_buffer.h | |||
@@ -59,6 +59,23 @@ struct op_sample *cpu_buffer_write_entry(struct oprofile_cpu_buffer *cpu_buf) | |||
59 | } | 59 | } |
60 | 60 | ||
61 | static inline | 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 | struct op_sample *cpu_buffer_read_entry(struct oprofile_cpu_buffer *cpu_buf) | 79 | struct op_sample *cpu_buffer_read_entry(struct oprofile_cpu_buffer *cpu_buf) |
63 | { | 80 | { |
64 | return &cpu_buf->buffer[cpu_buf->tail_pos]; | 81 | return &cpu_buf->buffer[cpu_buf->tail_pos]; |