Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 167463
b: refs/heads/master
c: c086893
h: refs/heads/master
i:
  167461: e969431
  167459: b82c8c1
  167455: 2964524
v: v3
  • Loading branch information
Robert Richter committed Oct 9, 2009
1 parent 6b6414d commit aa29d10
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 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: 066b3aa8454bee3cdc665d86b5de812d8d0513b3
refs/heads/master: c0868934e536e0ff508f2d359d006b25abc4970d
25 changes: 15 additions & 10 deletions trunk/drivers/oprofile/event_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,22 @@ static size_t buffer_pos;
/* atomic_t because wait_event checks it outside of buffer_mutex */
static atomic_t buffer_ready = ATOMIC_INIT(0);

/* Add an entry to the event buffer. When we
* get near to the end we wake up the process
* sleeping on the read() of the file.
/*
* Add an entry to the event buffer. When we get near to the end we
* wake up the process sleeping on the read() of the file. To protect
* the event_buffer this function may only be called when buffer_mutex
* is set.
*/
void add_event_entry(unsigned long value)
{
/*
* catch potential error
* This shouldn't happen since all workqueues or handlers are
* canceled or flushed before the event buffer is freed.
*/
if (!event_buffer)
if (!event_buffer) {
WARN_ON_ONCE(1);
return;
}

if (buffer_pos == buffer_size) {
atomic_inc(&oprofile_stats.event_lost_overflow);
Expand Down Expand Up @@ -75,7 +80,6 @@ void wake_up_buffer_waiter(void)

int alloc_event_buffer(void)
{
int err = -ENOMEM;
unsigned long flags;

spin_lock_irqsave(&oprofilefs_lock, flags);
Expand All @@ -86,20 +90,20 @@ int alloc_event_buffer(void)
if (buffer_watershed >= buffer_size)
return -EINVAL;

buffer_pos = 0;
event_buffer = vmalloc(sizeof(unsigned long) * buffer_size);
if (!event_buffer)
goto out;
return -ENOMEM;

err = 0;
out:
return err;
return 0;
}


void free_event_buffer(void)
{
mutex_lock(&buffer_mutex);
vfree(event_buffer);
buffer_pos = 0;
event_buffer = NULL;
mutex_unlock(&buffer_mutex);
}
Expand Down Expand Up @@ -174,6 +178,7 @@ static ssize_t event_buffer_read(struct file *file, char __user *buf,

mutex_lock(&buffer_mutex);

/* May happen if the buffer is freed during pending reads. */
if (!event_buffer) {
retval = -EINTR;
goto out;
Expand Down

0 comments on commit aa29d10

Please sign in to comment.