Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146210
b: refs/heads/master
c: edd813b
h: refs/heads/master
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Jun 3, 2009
1 parent d0da116 commit c1256e5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 27 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: a2023556409cf7fec5d67a26f7fcfa57c5a4086d
refs/heads/master: edd813bffc62a980bb4fb9b1243f31c1cce78da3
67 changes: 41 additions & 26 deletions trunk/kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,38 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
return event;
}

static inline int
rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
struct ring_buffer_event *event)
{
unsigned long new_index, old_index;
struct buffer_page *bpage;
unsigned long index;
unsigned long addr;

new_index = rb_event_index(event);
old_index = new_index + rb_event_length(event);
addr = (unsigned long)event;
addr &= PAGE_MASK;

bpage = cpu_buffer->tail_page;

if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
/*
* This is on the tail page. It is possible that
* a write could come in and move the tail page
* and write to the next page. That is fine
* because we just shorten what is on this page.
*/
index = local_cmpxchg(&bpage->write, old_index, new_index);
if (index == old_index)
return 1;
}

/* could not discard */
return 0;
}

static int
rb_add_time_stamp(struct ring_buffer_per_cpu *cpu_buffer,
u64 *ts, u64 *delta)
Expand Down Expand Up @@ -1384,10 +1416,13 @@ rb_add_time_stamp(struct ring_buffer_per_cpu *cpu_buffer,
/* let the caller know this was the commit */
ret = 1;
} else {
/* Darn, this is just wasted space */
event->time_delta = 0;
event->array[0] = 0;
ret = 0;
/* Try to discard the event */
if (!rb_try_to_discard(cpu_buffer, event)) {
/* Darn, this is just wasted space */
event->time_delta = 0;
event->array[0] = 0;
ret = 0;
}
}

*delta = 0;
Expand Down Expand Up @@ -1682,10 +1717,6 @@ void ring_buffer_discard_commit(struct ring_buffer *buffer,
struct ring_buffer_event *event)
{
struct ring_buffer_per_cpu *cpu_buffer;
unsigned long new_index, old_index;
struct buffer_page *bpage;
unsigned long index;
unsigned long addr;
int cpu;

/* The event is discarded regardless */
Expand All @@ -1701,24 +1732,8 @@ void ring_buffer_discard_commit(struct ring_buffer *buffer,
cpu = smp_processor_id();
cpu_buffer = buffer->buffers[cpu];

new_index = rb_event_index(event);
old_index = new_index + rb_event_length(event);
addr = (unsigned long)event;
addr &= PAGE_MASK;

bpage = cpu_buffer->tail_page;

if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
/*
* This is on the tail page. It is possible that
* a write could come in and move the tail page
* and write to the next page. That is fine
* because we just shorten what is on this page.
*/
index = local_cmpxchg(&bpage->write, old_index, new_index);
if (index == old_index)
goto out;
}
if (!rb_try_to_discard(cpu_buffer, event))
goto out;

/*
* The commit is still visible by the reader, so we
Expand Down

0 comments on commit c1256e5

Please sign in to comment.