Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147325
b: refs/heads/master
c: 3c446b3
h: refs/heads/master
i:
  147323: 230a3c3
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Apr 7, 2009
1 parent eb37694 commit d7da25c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 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: 9c03d88e328d5f28f13191622c2ea1349c36b799
refs/heads/master: 3c446b3d3b38f991f97e9d2df0ad26a60a94dcff
2 changes: 2 additions & 0 deletions trunk/include/linux/perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ enum perf_event_type {
#include <linux/rcupdate.h>
#include <linux/spinlock.h>
#include <linux/hrtimer.h>
#include <linux/fs.h>
#include <asm/atomic.h>

struct task_struct;
Expand Down Expand Up @@ -398,6 +399,7 @@ struct perf_counter {

/* poll related */
wait_queue_head_t waitq;
struct fasync_struct *fasync;
/* optional: for NMIs */
struct perf_wakeup_entry wakeup;

Expand Down
20 changes: 19 additions & 1 deletion trunk/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,13 +1526,30 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
return ret;
}

static int perf_fasync(int fd, struct file *filp, int on)
{
struct perf_counter *counter = filp->private_data;
struct inode *inode = filp->f_path.dentry->d_inode;
int retval;

mutex_lock(&inode->i_mutex);
retval = fasync_helper(fd, filp, on, &counter->fasync);
mutex_unlock(&inode->i_mutex);

if (retval < 0)
return retval;

return 0;
}

static const struct file_operations perf_fops = {
.release = perf_release,
.read = perf_read,
.poll = perf_poll,
.unlocked_ioctl = perf_ioctl,
.compat_ioctl = perf_ioctl,
.mmap = perf_mmap,
.fasync = perf_fasync,
};

/*
Expand All @@ -1549,7 +1566,7 @@ void perf_counter_wakeup(struct perf_counter *counter)
rcu_read_lock();
data = rcu_dereference(counter->data);
if (data) {
(void)atomic_xchg(&data->wakeup, POLL_IN);
atomic_set(&data->wakeup, POLL_IN);
/*
* Ensure all data writes are issued before updating the
* user-space data head information. The matching rmb()
Expand All @@ -1561,6 +1578,7 @@ void perf_counter_wakeup(struct perf_counter *counter)
rcu_read_unlock();

wake_up_all(&counter->waitq);
kill_fasync(&counter->fasync, SIGIO, POLL_IN);
}

/*
Expand Down

0 comments on commit d7da25c

Please sign in to comment.