Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147311
b: refs/heads/master
c: 78d613e
h: refs/heads/master
i:
  147309: 96f7e58
  147307: eb64b76
  147303: c4566f7
  147295: 3f219f9
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Apr 6, 2009
1 parent dad4467 commit 3e01645
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 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: 31f004df8d14212f0a8a2fb12a8ed44a3d80e2fb
refs/heads/master: 78d613eb129fc4edf0e2cabfcc6a4c5285482d21
42 changes: 26 additions & 16 deletions trunk/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1663,10 +1663,20 @@ struct perf_output_handle {
unsigned int offset;
unsigned int head;
int wakeup;
int nmi;
};

static inline void __perf_output_wakeup(struct perf_output_handle *handle)
{
if (handle->nmi)
perf_pending_queue(handle->counter);
else
perf_counter_wakeup(handle->counter);
}

static int perf_output_begin(struct perf_output_handle *handle,
struct perf_counter *counter, unsigned int size)
struct perf_counter *counter, unsigned int size,
int nmi)
{
struct perf_mmap_data *data;
unsigned int offset, head;
Expand All @@ -1676,22 +1686,26 @@ static int perf_output_begin(struct perf_output_handle *handle,
if (!data)
goto out;

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

if (!data->nr_pages)
goto out;
goto fail;

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

handle->counter = counter;
handle->data = data;
handle->offset = offset;
handle->head = head;
handle->wakeup = (offset >> PAGE_SHIFT) != (head >> PAGE_SHIFT);

return 0;

fail:
__perf_output_wakeup(handle);
out:
rcu_read_unlock();

Expand Down Expand Up @@ -1733,14 +1747,10 @@ static void perf_output_copy(struct perf_output_handle *handle,
#define perf_output_put(handle, x) \
perf_output_copy((handle), &(x), sizeof(x))

static void perf_output_end(struct perf_output_handle *handle, int nmi)
static void perf_output_end(struct perf_output_handle *handle)
{
if (handle->wakeup) {
if (nmi)
perf_pending_queue(handle->counter);
else
perf_counter_wakeup(handle->counter);
}
if (handle->wakeup)
__perf_output_wakeup(handle);
rcu_read_unlock();
}

Expand All @@ -1750,12 +1760,12 @@ static int perf_output_write(struct perf_counter *counter, int nmi,
struct perf_output_handle handle;
int ret;

ret = perf_output_begin(&handle, counter, size);
ret = perf_output_begin(&handle, counter, size, nmi);
if (ret)
goto out;

perf_output_copy(&handle, buf, size);
perf_output_end(&handle, nmi);
perf_output_end(&handle);

out:
return ret;
Expand Down Expand Up @@ -1804,7 +1814,7 @@ static void perf_output_group(struct perf_counter *counter, int nmi)

size = sizeof(header) + counter->nr_siblings * sizeof(entry);

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

Expand All @@ -1824,7 +1834,7 @@ static void perf_output_group(struct perf_counter *counter, int nmi)
perf_output_put(&handle, entry);
}

perf_output_end(&handle, nmi);
perf_output_end(&handle);
}

void perf_counter_output(struct perf_counter *counter,
Expand Down Expand Up @@ -1869,15 +1879,15 @@ 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);
int ret = perf_output_begin(&handle, counter, size, 0);

if (ret)
return;

perf_output_put(&handle, mmap_event->event);
perf_output_copy(&handle, mmap_event->file_name,
mmap_event->file_size);
perf_output_end(&handle, 0);
perf_output_end(&handle);
}

static int perf_counter_mmap_match(struct perf_counter *counter,
Expand Down

0 comments on commit 3e01645

Please sign in to comment.