From: Peter Zijlstra <peterz@infradead.org>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
Li Zefan <lizf@cn.fujitsu.com>,
Prasad <prasad@linux.vnet.ibm.com>,
Alan Stern <stern@rowland.harvard.edu>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
Jan Kiszka <jan.kiszka@web.de>, Jiri Slaby <jirislaby@gmail.com>,
Avi Kivity <avi@redhat.com>, Paul Mackerras <paulus@samba.org>,
Mike Galbraith <efault@gmx.de>,
Masami Hiramatsu <mhiramat@redhat.com>,
Paul Mundt <lethal@linux-sh.org>,
Arjan van de Ven <arjan@linux.intel.com>
Subject: Re: [PATCH 3/7 v6] perf/core: Add a callback to perf events
Date: Thu, 19 Nov 2009 23:40:53 +0100 [thread overview]
Message-ID: <1258670453.11284.278.camel@laptop> (raw)
In-Reply-To: <20091119154349.GA4967@nowhere>
On Thu, 2009-11-19 at 16:43 +0100, Frederic Weisbecker wrote:
> On Wed, Nov 18, 2009 at 10:31:09AM +0100, Peter Zijlstra wrote:
> > On Wed, 2009-11-18 at 01:18 +0100, Frederic Weisbecker wrote:
> > > On Tue, Nov 17, 2009 at 12:28:53PM +0100, Peter Zijlstra wrote:
> > > > On Sun, 2009-11-08 at 16:28 +0100, Frederic Weisbecker wrote:
> > > > > A simple callback in a perf event can be used for multiple purposes.
> > > > > For example it is useful for triggered based events like hardware
> > > > > breakpoints that need a callback to dispatch a triggered breakpoint
> > > > > event.
> > > > >
> > > > > v2: Simplify a bit the callback attribution as suggested by Paul
> > > > > Mackerras
> > > >
> > > > Yuck! So we add an opaque callback without semantics nor usage.
> > >
> > >
> > > Yeah, this is intended for events that need to be able to trigger
> > > events to different channels. In the case of hw-breakpoints, it's
> > > either perf buffer, ptrace, etc...
> > >
> > > Should I add some comments about it?
> >
> > At the very least.. describe its semantics and preferably rename the
> > thing.
>
>
> May be "event_triggered"?
What event? There is no caller.
> > Currently I've no clue what it does and why, your description above
> > about multiple channels does not at all help me understand how this
> > function pointer is used to make that happen.
> >
>
>
> We need it for hardware breakpoints because if we register a breakpoint
> for perf syscall use, we need to dispatch the event to perf. But if we
> register it for ptrace, or any in-kernel uses, we need to dispatch the
> event somewhere else and then we need another callback.
So you simply want to have a different overflow/sample handler?
Doesn't something like the below work? We need that anyway for kernel
based consumers that want to do anything with the sampling event.
Index: linux-2.6/include/linux/perf_event.h
===================================================================
--- linux-2.6.orig/include/linux/perf_event.h
+++ linux-2.6/include/linux/perf_event.h
@@ -567,6 +567,8 @@ struct perf_pending_entry {
typedef void (*perf_callback_t)(struct perf_event *, void *);
+struct perf_sample_data;
+
/**
* struct perf_event - performance event kernel representation:
*/
@@ -658,6 +660,10 @@ struct perf_event {
struct pid_namespace *ns;
u64 id;
+ void (*overflow_handler)(struct perf_event *event,
+ int nmi, struct perf_sample_data *data,
+ struct pt_regs *regs);
+
#ifdef CONFIG_EVENT_PROFILE
struct event_filter *filter;
#endif
Index: linux-2.6/kernel/perf_event.c
===================================================================
--- linux-2.6.orig/kernel/perf_event.c
+++ linux-2.6/kernel/perf_event.c
@@ -3710,7 +3710,11 @@ static int __perf_event_overflow(struct
perf_event_disable(event);
}
- perf_event_output(event, nmi, data, regs);
+ if (event->overflow_handler)
+ event->overflow_handler(event, nmi, data, regs);
+ else
+ perf_event_output(event, nmi, data, regs);
+
return ret;
}
@@ -4836,6 +4849,8 @@ inherit_event(struct perf_event *parent_
if (parent_event->attr.freq)
child_event->hw.sample_period = parent_event->hw.sample_period;
+ child_event->overflow_handler = parent->overflow_handler;
+
/*
* Link it up in the child's context:
*/
next prev parent reply other threads:[~2009-11-19 22:41 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-08 15:28 [GIT PULL v6] hw-breakpoints: Rewrite on top of perf events v6 Frederic Weisbecker
2009-11-08 15:28 ` [PATCH 1/7 v6] perf/core: Provide a kernel-internal interface to get to performance counters Frederic Weisbecker
2009-11-08 15:28 ` [PATCH 2/7 v6] x86/hw-breakpoints: Actually flush thread breakpoints in flush_thread() Frederic Weisbecker
2009-11-08 15:28 ` [PATCH 3/7 v6] perf/core: Add a callback to perf events Frederic Weisbecker
2009-11-17 11:28 ` Peter Zijlstra
2009-11-18 0:18 ` Frederic Weisbecker
2009-11-18 9:31 ` Peter Zijlstra
2009-11-19 15:43 ` Frederic Weisbecker
2009-11-19 22:40 ` Peter Zijlstra [this message]
2009-11-08 15:28 ` [PATCH 4/7 v6] hw-breakpoint: Move asm-generic/hw_breakpoint.h to linux/hw_breakpoint.h Frederic Weisbecker
2009-11-08 15:28 ` [PATCH 5/7 v6] hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events Frederic Weisbecker
2009-11-08 17:24 ` Jan Kiszka
2009-11-12 14:32 ` Frederic Weisbecker
2009-11-11 13:02 ` K.Prasad
2009-11-12 4:25 ` K.Prasad
2009-11-17 1:36 ` Frederic Weisbecker
2009-11-17 1:31 ` Frederic Weisbecker
2009-11-17 11:30 ` Peter Zijlstra
2009-11-18 0:19 ` Frederic Weisbecker
2009-11-08 15:29 ` [PATCH 6/7 v6] hw-breakpoints: Arbitrate access to pmu following registers constraints Frederic Weisbecker
2009-11-08 15:29 ` [PATCH 7/7 v6] ksym_tracer: Remove KSYM_SELFTEST_ENTRY Frederic Weisbecker
2009-11-08 17:03 ` [GIT PULL v6] hw-breakpoints: Rewrite on top of perf events v6 Ingo Molnar
2009-11-24 9:44 ` K.Prasad
2009-11-24 10:13 ` Ingo Molnar
2009-11-24 13:21 ` K.Prasad
2009-11-26 5:59 ` Frederic Weisbecker
2009-11-27 19:07 ` K.Prasad
2009-12-01 6:43 ` Frederic Weisbecker
2009-11-26 5:47 ` Frederic Weisbecker
2009-11-26 9:01 ` Ingo Molnar
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=1258670453.11284.278.camel@laptop \
--to=peterz@infradead.org \
--cc=acme@redhat.com \
--cc=arjan@linux.intel.com \
--cc=avi@redhat.com \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=jan.kiszka@web.de \
--cc=jirislaby@gmail.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=mhiramat@redhat.com \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=prasad@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=stern@rowland.harvard.edu \
/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