Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147293
b: refs/heads/master
c: c7138f3
h: refs/heads/master
i:
  147291: 3014c9d
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Apr 6, 2009
1 parent c0aaada commit 3636646
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 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: f66c6b2066b44d4ab8e8ac1ee4cae543738fe2ac
refs/heads/master: c7138f37f905bb7987b1f9f5a8ee73667db39f25
1 change: 1 addition & 0 deletions trunk/include/linux/perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ struct file;
struct perf_mmap_data {
struct rcu_head rcu_head;
int nr_pages;
atomic_t wakeup;
atomic_t head;
struct perf_counter_mmap_page *user_page;
void *data_pages[0];
Expand Down
14 changes: 12 additions & 2 deletions trunk/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,16 @@ perf_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
static unsigned int perf_poll(struct file *file, poll_table *wait)
{
struct perf_counter *counter = file->private_data;
unsigned int events = POLLIN;
struct perf_mmap_data *data;
unsigned int events;

rcu_read_lock();
data = rcu_dereference(counter->data);
if (data)
events = atomic_xchg(&data->wakeup, 0);
else
events = POLL_HUP;
rcu_read_unlock();

poll_wait(file, &counter->waitq, wait);

Expand Down Expand Up @@ -1425,7 +1434,7 @@ static int perf_output_write(struct perf_counter *counter, int nmi,

do {
offset = head = atomic_read(&data->head);
head += sizeof(u64);
head += size;
} while (atomic_cmpxchg(&data->head, offset, head) != offset);

wakeup = (offset >> PAGE_SHIFT) != (head >> PAGE_SHIFT);
Expand All @@ -1446,6 +1455,7 @@ static int perf_output_write(struct perf_counter *counter, int nmi,
* generate a poll() wakeup for every page boundary crossed
*/
if (wakeup) {
atomic_xchg(&data->wakeup, POLL_IN);
__perf_counter_update_userpage(counter, data);
if (nmi) {
counter->wakeup_pending = 1;
Expand Down

0 comments on commit 3636646

Please sign in to comment.