diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-03-03 23:52:42 -0500 |
---|---|---|
committer | Steven Rostedt <srostedt@redhat.com> | 2009-03-04 19:01:45 -0500 |
commit | 4f3640f8a358f2183a8c966f299eeb55ca523e06 (patch) | |
tree | ff8b1a10b449fbb823523b09a192e6b5563d56e8 | |
parent | e543ad76914abec1acf6631604a4154cd7a2ca6b (diff) |
ring-buffer: fix timestamp in partial ring_buffer_page_read
If a partial ring_buffer_page_read happens, then some of the
incremental timestamps may be lost. This patch writes the
recent timestamp into the page that is passed back to the caller.
A partial ring_buffer_page_read is where the full page would not
be written back to the user, and instead, just part of the page
is copied to the user. A full page would be a page swap with the
ring buffer and the timestamps would be correct.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
-rw-r--r-- | kernel/trace/ring_buffer.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index f2a163db52f9..f7473645b9c6 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
@@ -2461,6 +2461,7 @@ int ring_buffer_read_page(struct ring_buffer *buffer, | |||
2461 | unsigned long flags; | 2461 | unsigned long flags; |
2462 | unsigned int commit; | 2462 | unsigned int commit; |
2463 | unsigned int read; | 2463 | unsigned int read; |
2464 | u64 save_timestamp; | ||
2464 | int ret = -1; | 2465 | int ret = -1; |
2465 | 2466 | ||
2466 | /* | 2467 | /* |
@@ -2515,6 +2516,9 @@ int ring_buffer_read_page(struct ring_buffer *buffer, | |||
2515 | if (len < size) | 2516 | if (len < size) |
2516 | goto out; | 2517 | goto out; |
2517 | 2518 | ||
2519 | /* save the current timestamp, since the user will need it */ | ||
2520 | save_timestamp = cpu_buffer->read_stamp; | ||
2521 | |||
2518 | /* Need to copy one event at a time */ | 2522 | /* Need to copy one event at a time */ |
2519 | do { | 2523 | do { |
2520 | memcpy(bpage->data + pos, rpage->data + rpos, size); | 2524 | memcpy(bpage->data + pos, rpage->data + rpos, size); |
@@ -2531,7 +2535,7 @@ int ring_buffer_read_page(struct ring_buffer *buffer, | |||
2531 | 2535 | ||
2532 | /* update bpage */ | 2536 | /* update bpage */ |
2533 | local_set(&bpage->commit, pos); | 2537 | local_set(&bpage->commit, pos); |
2534 | bpage->time_stamp = rpage->time_stamp; | 2538 | bpage->time_stamp = save_timestamp; |
2535 | 2539 | ||
2536 | /* we copied everything to the beginning */ | 2540 | /* we copied everything to the beginning */ |
2537 | read = 0; | 2541 | read = 0; |