From d7da25c290670f0bb479b997fbe4a1a62f238231 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Mon, 6 Apr 2009 11:45:01 +0200 Subject: [PATCH] --- yaml --- r: 147325 b: refs/heads/master c: 3c446b3d3b38f991f97e9d2df0ad26a60a94dcff h: refs/heads/master i: 147323: 230a3c31ccdb5b16f8a08502ebb61d4207da460f v: v3 --- [refs] | 2 +- trunk/include/linux/perf_counter.h | 2 ++ trunk/kernel/perf_counter.c | 20 +++++++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 19effc47d7c7..f318f37d57b5 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9c03d88e328d5f28f13191622c2ea1349c36b799 +refs/heads/master: 3c446b3d3b38f991f97e9d2df0ad26a60a94dcff diff --git a/trunk/include/linux/perf_counter.h b/trunk/include/linux/perf_counter.h index f9d5cf0bfbdd..8d5d11b8d011 100644 --- a/trunk/include/linux/perf_counter.h +++ b/trunk/include/linux/perf_counter.h @@ -238,6 +238,7 @@ enum perf_event_type { #include #include #include +#include #include struct task_struct; @@ -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; diff --git a/trunk/kernel/perf_counter.c b/trunk/kernel/perf_counter.c index 727624db5078..c58cc64319e1 100644 --- a/trunk/kernel/perf_counter.c +++ b/trunk/kernel/perf_counter.c @@ -1526,6 +1526,22 @@ 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, @@ -1533,6 +1549,7 @@ static const struct file_operations perf_fops = { .unlocked_ioctl = perf_ioctl, .compat_ioctl = perf_ioctl, .mmap = perf_mmap, + .fasync = perf_fasync, }; /* @@ -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() @@ -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); } /*