Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191027
b: refs/heads/master
c: ff0ff84
h: refs/heads/master
i:
  191025: 6fdc63f
  191023: c80c2f1
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Apr 1, 2010
1 parent adfeb65 commit 713beee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bc21b478425ac73f66a5ec0b375a5e0d12d609ce
refs/heads/master: ff0ff84a0767df48d728c36510365344a7e7d582
37 changes: 33 additions & 4 deletions trunk/kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ EXPORT_SYMBOL_GPL(ring_buffer_event_data);

/* Flag when events were overwritten */
#define RB_MISSED_EVENTS (1 << 31)
/* Missed count stored at end */
#define RB_MISSED_STORED (1 << 30)

struct buffer_data_page {
u64 time_stamp; /* page time stamp */
Expand All @@ -340,6 +342,7 @@ struct buffer_page {
local_t write; /* index for next write */
unsigned read; /* index for next read */
local_t entries; /* entries on this page */
unsigned long real_end; /* real end of data */
struct buffer_data_page *page; /* Actual data page */
};

Expand Down Expand Up @@ -1769,6 +1772,13 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
event = __rb_page_index(tail_page, tail);
kmemcheck_annotate_bitfield(event, bitfield);

/*
* Save the original length to the meta data.
* This will be used by the reader to add lost event
* counter.
*/
tail_page->real_end = tail;

/*
* If this event is bigger than the minimum size, then
* we need to be careful that we don't subtract the
Expand Down Expand Up @@ -2888,6 +2898,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
local_set(&cpu_buffer->reader_page->write, 0);
local_set(&cpu_buffer->reader_page->entries, 0);
local_set(&cpu_buffer->reader_page->page->commit, 0);
cpu_buffer->reader_page->real_end = 0;

spin:
/*
Expand Down Expand Up @@ -3728,11 +3739,11 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
struct ring_buffer_event *event;
struct buffer_data_page *bpage;
struct buffer_page *reader;
unsigned long missed_events;
unsigned long flags;
unsigned int commit;
unsigned int read;
u64 save_timestamp;
int missed_events = 0;
int ret = -1;

if (!cpumask_test_cpu(cpu, buffer->cpumask))
Expand Down Expand Up @@ -3766,8 +3777,7 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
commit = rb_page_commit(reader);

/* Check if any events were dropped */
if (cpu_buffer->lost_events)
missed_events = 1;
missed_events = cpu_buffer->lost_events;

/*
* If this page has been partially read or
Expand Down Expand Up @@ -3829,15 +3839,34 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
local_set(&reader->entries, 0);
reader->read = 0;
*data_page = bpage;

/*
* Use the real_end for the data size,
* This gives us a chance to store the lost events
* on the page.
*/
if (reader->real_end)
local_set(&bpage->commit, reader->real_end);
}
ret = read;

cpu_buffer->lost_events = 0;
/*
* Set a flag in the commit field if we lost events
*/
if (missed_events)
if (missed_events) {
commit = local_read(&bpage->commit);

/* If there is room at the end of the page to save the
* missed events, then record it there.
*/
if (BUF_PAGE_SIZE - commit >= sizeof(missed_events)) {
memcpy(&bpage->data[commit], &missed_events,
sizeof(missed_events));
local_add(RB_MISSED_STORED, &bpage->commit);
}
local_add(RB_MISSED_EVENTS, &bpage->commit);
}

out_unlock:
spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
Expand Down

0 comments on commit 713beee

Please sign in to comment.