Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140719
b: refs/heads/master
c: 667d241
h: refs/heads/master
i:
  140717: f5e5805
  140715: 4f575f9
  140711: aa74c4d
  140703: 33662c5
v: v3
  • Loading branch information
Lai Jiangshan authored and Steven Rostedt committed Feb 10, 2009
1 parent ffc91a5 commit 47005ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 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: b85fa01ed958ca59523a2db3c2ee647b98745d6a
refs/heads/master: 667d24125839b6f3363d8177d7ed9fab8a40e45f
33 changes: 20 additions & 13 deletions trunk/kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2332,13 +2332,14 @@ int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);

static void rb_remove_entries(struct ring_buffer_per_cpu *cpu_buffer,
struct buffer_data_page *bpage)
struct buffer_data_page *bpage,
unsigned int offset)
{
struct ring_buffer_event *event;
unsigned long head;

__raw_spin_lock(&cpu_buffer->lock);
for (head = 0; head < local_read(&bpage->commit);
for (head = offset; head < local_read(&bpage->commit);
head += rb_event_length(event)) {

event = __rb_data_page_index(bpage, head);
Expand Down Expand Up @@ -2410,8 +2411,8 @@ void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data)
* if (!rpage)
* return error;
* ret = ring_buffer_read_page(buffer, &rpage, cpu, 0);
* if (ret)
* process_page(rpage);
* if (ret >= 0)
* process_page(rpage, ret);
*
* When @full is set, the function will not return true unless
* the writer is off the reader page.
Expand All @@ -2422,8 +2423,8 @@ void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data)
* responsible for that.
*
* Returns:
* 1 if data has been transferred
* 0 if no data has been transferred.
* >=0 if data has been transferred, returns the offset of consumed data.
* <0 if no data has been transferred.
*/
int ring_buffer_read_page(struct ring_buffer *buffer,
void **data_page, int cpu, int full)
Expand All @@ -2432,7 +2433,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
struct ring_buffer_event *event;
struct buffer_data_page *bpage;
unsigned long flags;
int ret = 0;
unsigned int read;
int ret = -1;

if (!data_page)
return 0;
Expand All @@ -2454,24 +2456,29 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
/* check for data */
if (!local_read(&cpu_buffer->reader_page->page->commit))
goto out;

read = cpu_buffer->reader_page->read;
/*
* If the writer is already off of the read page, then simply
* switch the read page with the given page. Otherwise
* we need to copy the data from the reader to the writer.
*/
if (cpu_buffer->reader_page == cpu_buffer->commit_page) {
unsigned int read = cpu_buffer->reader_page->read;
unsigned int commit = rb_page_commit(cpu_buffer->reader_page);
struct buffer_data_page *rpage = cpu_buffer->reader_page->page;

if (full)
goto out;
/* The writer is still on the reader page, we must copy */
memcpy(bpage->data,
cpu_buffer->reader_page->page->data + read,
commit - read);
memcpy(bpage->data + read, rpage->data + read, commit - read);

/* consume what was read */
cpu_buffer->reader_page->read = commit;

/* update bpage */
local_set(&bpage->commit, commit);
if (!read)
bpage->time_stamp = rpage->time_stamp;
} else {
/* swap the pages */
rb_init_page(bpage);
Expand All @@ -2480,10 +2487,10 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
cpu_buffer->reader_page->read = 0;
*data_page = bpage;
}
ret = 1;
ret = read;

/* update the entry counter */
rb_remove_entries(cpu_buffer, bpage);
rb_remove_entries(cpu_buffer, bpage, read);
out:
spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);

Expand Down

0 comments on commit 47005ba

Please sign in to comment.