aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/ring_buffer.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index f50f43107e93..d9f3e7a82137 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2119,6 +2119,7 @@ rb_reserve_next_event(struct ring_buffer *buffer,
2119 u64 ts, delta; 2119 u64 ts, delta;
2120 int nr_loops = 0; 2120 int nr_loops = 0;
2121 int add_timestamp; 2121 int add_timestamp;
2122 u64 diff;
2122 2123
2123 rb_start_commit(cpu_buffer); 2124 rb_start_commit(cpu_buffer);
2124 2125
@@ -2155,29 +2156,13 @@ rb_reserve_next_event(struct ring_buffer *buffer,
2155 goto out_fail; 2156 goto out_fail;
2156 2157
2157 ts = rb_time_stamp(cpu_buffer->buffer); 2158 ts = rb_time_stamp(cpu_buffer->buffer);
2159 diff = ts - cpu_buffer->write_stamp;
2158 2160
2159 /* 2161 /* make sure this diff is calculated here */
2160 * Only the first commit can update the timestamp. 2162 barrier();
2161 * Yes there is a race here. If an interrupt comes in
2162 * just after the conditional and it traces too, then it
2163 * will also check the deltas. More than one timestamp may
2164 * also be made. But only the entry that did the actual
2165 * commit will be something other than zero.
2166 */
2167 if (likely(cpu_buffer->tail_page == cpu_buffer->commit_page &&
2168 rb_page_write(cpu_buffer->tail_page) ==
2169 rb_commit_index(cpu_buffer))) {
2170 u64 diff;
2171
2172 diff = ts - cpu_buffer->write_stamp;
2173
2174 /* make sure this diff is calculated here */
2175 barrier();
2176
2177 /* Did the write stamp get updated already? */
2178 if (unlikely(ts < cpu_buffer->write_stamp))
2179 goto get_event;
2180 2163
2164 /* Did the write stamp get updated already? */
2165 if (likely(ts >= cpu_buffer->write_stamp)) {
2181 delta = diff; 2166 delta = diff;
2182 if (unlikely(test_time_stamp(delta))) { 2167 if (unlikely(test_time_stamp(delta))) {
2183 WARN_ONCE(delta > (1ULL << 59), 2168 WARN_ONCE(delta > (1ULL << 59),
@@ -2189,7 +2174,6 @@ rb_reserve_next_event(struct ring_buffer *buffer,
2189 } 2174 }
2190 } 2175 }
2191 2176
2192 get_event:
2193 event = __rb_reserve_next(cpu_buffer, length, ts, 2177 event = __rb_reserve_next(cpu_buffer, length, ts,
2194 delta, add_timestamp); 2178 delta, add_timestamp);
2195 if (unlikely(PTR_ERR(event) == -EAGAIN)) 2179 if (unlikely(PTR_ERR(event) == -EAGAIN))