Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147333
b: refs/heads/master
c: 4c9e254
h: refs/heads/master
i:
  147331: 82feeef
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Apr 7, 2009
1 parent fd3eb4f commit 7140961
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 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: 0c593b3411341e3a05a61f5527df36ab02bd11e8
refs/heads/master: 4c9e25428ff46b968a30f1dfafdba550cb6e4141
1 change: 1 addition & 0 deletions trunk/include/linux/perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ struct perf_counter {

/* delayed work for NMIs and such */
int pending_wakeup;
int pending_kill;
int pending_disable;
struct perf_pending_entry pending;

Expand Down
22 changes: 15 additions & 7 deletions trunk/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,11 @@ void perf_counter_wakeup(struct perf_counter *counter)
rcu_read_unlock();

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

if (counter->pending_kill) {
kill_fasync(&counter->fasync, SIGIO, counter->pending_kill);
counter->pending_kill = 0;
}
}

/*
Expand Down Expand Up @@ -1727,6 +1731,7 @@ struct perf_output_handle {
unsigned int head;
int wakeup;
int nmi;
int overflow;
};

static inline void __perf_output_wakeup(struct perf_output_handle *handle)
Expand All @@ -1741,7 +1746,7 @@ static inline void __perf_output_wakeup(struct perf_output_handle *handle)

static int perf_output_begin(struct perf_output_handle *handle,
struct perf_counter *counter, unsigned int size,
int nmi)
int nmi, int overflow)
{
struct perf_mmap_data *data;
unsigned int offset, head;
Expand All @@ -1751,8 +1756,9 @@ static int perf_output_begin(struct perf_output_handle *handle,
if (!data)
goto out;

handle->counter = counter;
handle->nmi = nmi;
handle->counter = counter;
handle->nmi = nmi;
handle->overflow = overflow;

if (!data->nr_pages)
goto fail;
Expand Down Expand Up @@ -1816,7 +1822,7 @@ static void perf_output_end(struct perf_output_handle *handle)
{
int wakeup_events = handle->counter->hw_event.wakeup_events;

if (wakeup_events) {
if (handle->overflow && wakeup_events) {
int events = atomic_inc_return(&handle->data->events);
if (events >= wakeup_events) {
atomic_sub(wakeup_events, &handle->data->events);
Expand Down Expand Up @@ -1891,7 +1897,7 @@ static void perf_counter_output(struct perf_counter *counter,
header.size += sizeof(u64);
}

ret = perf_output_begin(&handle, counter, header.size, nmi);
ret = perf_output_begin(&handle, counter, header.size, nmi, 1);
if (ret)
return;

Expand Down Expand Up @@ -1955,7 +1961,7 @@ static void perf_counter_mmap_output(struct perf_counter *counter,
{
struct perf_output_handle handle;
int size = mmap_event->event.header.size;
int ret = perf_output_begin(&handle, counter, size, 0);
int ret = perf_output_begin(&handle, counter, size, 0, 0);

if (ret)
return;
Expand Down Expand Up @@ -2084,8 +2090,10 @@ int perf_counter_overflow(struct perf_counter *counter,
int events = atomic_read(&counter->event_limit);
int ret = 0;

counter->pending_kill = POLL_IN;
if (events && atomic_dec_and_test(&counter->event_limit)) {
ret = 1;
counter->pending_kill = POLL_HUP;
if (nmi) {
counter->pending_disable = 1;
perf_pending_queue(&counter->pending,
Expand Down

0 comments on commit 7140961

Please sign in to comment.