From: highguy@gmail.com
To: mingo@elte.hu, linux-kernel@vger.kernel.org
Cc: torvalds@linux-foundation.org, efault@gmx.de,
a.p.zijlstra@chello.nl, andrea@suse.de, tglx@linutronix.de,
akpm@linux-foundation.org, peterz@infradead.org,
Stijn Devriendt <stijn@stijn.telenet.be>
Subject: [PATCH 1/6] Move poll into perf_event and allow for wakeups when fd has not been mmap'd. This is useful when using read() to read out the current counter value.
Date: Sun, 7 Feb 2010 12:30:54 +0100 [thread overview]
Message-ID: <1265542259-5596-2-git-send-email-HIGHGuY@gmail.com> (raw)
In-Reply-To: <1265542259-5596-1-git-send-email-HIGHGuY@gmail.com>
From: Stijn Devriendt <stijn@stijn.telenet.be>
---
include/linux/perf_event.h | 2 +-
kernel/perf_event.c | 30 +++++++++++++++---------------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index c66b34f..827a221 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -538,7 +538,6 @@ struct perf_mmap_data {
int writable; /* are we writable */
int nr_locked; /* nr pages mlocked */
- atomic_t poll; /* POLL_ for wakeups */
atomic_t events; /* event_id limit */
atomic_long_t head; /* write position */
@@ -639,6 +638,7 @@ struct perf_event {
struct perf_mmap_data *data;
/* poll related */
+ atomic_t poll; /* POLL_ for wakeups */
wait_queue_head_t waitq;
struct fasync_struct *fasync;
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index e0eb4a2..42dc18d 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1919,14 +1919,7 @@ 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_event *event = file->private_data;
- struct perf_mmap_data *data;
- unsigned int events = POLL_HUP;
-
- rcu_read_lock();
- data = rcu_dereference(event->data);
- if (data)
- events = atomic_xchg(&data->poll, 0);
- rcu_read_unlock();
+ unsigned int events = atomic_xchg(&event->poll, 0);
poll_wait(file, &event->waitq, wait);
@@ -2680,16 +2673,20 @@ static bool perf_output_space(struct perf_mmap_data *data, unsigned long tail,
return true;
}
-static void perf_output_wakeup(struct perf_output_handle *handle)
+static void __perf_output_wakeup(struct perf_event* event, int nmi)
{
- atomic_set(&handle->data->poll, POLL_IN);
+ atomic_set(&event->poll, POLLIN);
- if (handle->nmi) {
- handle->event->pending_wakeup = 1;
- perf_pending_queue(&handle->event->pending,
- perf_pending_event);
+ if (nmi) {
+ event->pending_wakeup = 1;
+ perf_pending_queue(&event->pending, perf_pending_event);
} else
- perf_event_wakeup(handle->event);
+ perf_event_wakeup(event);
+}
+
+static void perf_output_wakeup(struct perf_output_handle *handle)
+{
+ __perf_output_wakeup(handle->event, handle->nmi);
}
/*
@@ -3171,6 +3168,9 @@ static void perf_event_output(struct perf_event *event, int nmi,
struct perf_output_handle handle;
struct perf_event_header header;
+ if (!event->data)
+ return __perf_output_wakeup(event, nmi);
+
perf_prepare_sample(&header, data, event, regs);
if (perf_output_begin(&handle, event, header.size, nmi, 1))
--
1.6.6
next prev parent reply other threads:[~2010-02-07 11:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-07 11:30 [RFC][PATCH] PERF_COUNT_SW_RUNNABLE_TASKS: measure and act upon parallellism highguy
2010-02-07 11:30 ` highguy [this message]
2010-02-07 11:30 ` [PATCH 2/6] Allow min/max thresholds for wakeups highguy
2010-02-07 11:30 ` [PATCH 3/6] Add handlers for adding counter events, reading counter events, counter resets, wakeups. Renamed old read handler to update highguy
2010-02-07 11:30 ` [PATCH 4/6] Fix HW breakpoint handlers highguy
2010-02-07 11:30 ` [PATCH 5/6] Allow decrementing counters highguy
2010-02-07 11:30 ` [PATCH 6/6] Add PERF_COUNT_SW_RUNNABLE_TASKS highguy
2010-02-08 10:00 ` [RFC][PATCH] PERF_COUNT_SW_RUNNABLE_TASKS: measure and act upon parallellism Peter Zijlstra
2010-02-08 11:52 ` Stijn Devriendt
2010-02-08 11:59 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1265542259-5596-2-git-send-email-HIGHGuY@gmail.com \
--to=highguy@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=andrea@suse.de \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=stijn@stijn.telenet.be \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome