From: Peter Zijlstra <peterz@infradead.org>
To: Andrew Vagin <avagin@openvz.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Paul Mackerras <paulus@samba.org>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
Arun Sharma <asharma@fb.com>
Subject: Re: [PATCH] trace: add ability to set a target task for events
Date: Tue, 10 Jul 2012 12:20:09 +0200 [thread overview]
Message-ID: <1341915609.3462.113.camel@twins> (raw)
In-Reply-To: <1341392911-1888300-1-git-send-email-avagin@openvz.org>
On Wed, 2012-07-04 at 13:08 +0400, Andrew Vagin wrote:
> From: Peter Zijlstra <a.p.zijlstra@chello.nl>
>
> A few events are interesting not only for a current task.
> For example, sched_stat_* are interesting to a task, which
> wake up. For this reason, it will be good, if such events will
> be delivered to a target task too.
>
> Now a target task can be set by using __perf_task().
Right, I suspect you actually tested this and it works?
It would be good it you can expand the Changelog a bit to include your
entire use-case. IIRC you're wanting to measure task block latency and
need the time and place where it goes to sleep, provided by
trace_sched_switch + callchain, and the time when it gets woken up,
provided by trace_sched_wakeup().
Hmm.. you only add __perf_task() to sched_stat_template, should it also
be added to sched_wakeup_template?
ISTR us talking about dis-allowing callgraphs on such cross-task events,
since that would be nigh impossible to interpret, right?
So do we want something like this on top?
---
kernel/events/callchain.c | 12 +++++++++---
kernel/events/core.c | 2 +-
kernel/events/internal.h | 3 ++-
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
index 6581a04..35de8b1 100644
--- a/kernel/events/callchain.c
+++ b/kernel/events/callchain.c
@@ -153,11 +153,11 @@ put_callchain_entry(int rctx)
put_recursion_context(__get_cpu_var(callchain_recursion), rctx);
}
-struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
+struct perf_callchain_entry *
+perf_callchain(struct perf_event *event, struct pt_regs *regs)
{
- int rctx;
struct perf_callchain_entry *entry;
-
+ int rctx;
entry = get_callchain_entry(&rctx);
if (rctx == -1)
@@ -178,6 +178,12 @@ struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
}
if (regs) {
+ /*
+ * Disallow cross-task user callchains.
+ */
+ if (event->ctx->task && event->ctx->task != current)
+ goto exit_put;
+
perf_callchain_store(entry, PERF_CONTEXT_USER);
perf_callchain_user(entry, regs);
}
diff --git a/kernel/events/core.c b/kernel/events/core.c
index f1cf0ed..74d22c9 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4039,7 +4039,7 @@ void perf_prepare_sample(struct perf_event_header *header,
if (sample_type & PERF_SAMPLE_CALLCHAIN) {
int size = 1;
- data->callchain = perf_callchain(regs);
+ data->callchain = perf_callchain(event, regs);
if (data->callchain)
size += data->callchain->nr;
diff --git a/kernel/events/internal.h b/kernel/events/internal.h
index b0b107f..a096c19 100644
--- a/kernel/events/internal.h
+++ b/kernel/events/internal.h
@@ -101,7 +101,8 @@ __output_copy(struct perf_output_handle *handle,
}
/* Callchain handling */
-extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs);
+extern struct perf_callchain_entry *
+perf_callchain(struct perf_event *event, struct pt_regs *regs);
extern int get_callchain_buffers(void);
extern void put_callchain_buffers(void);
next prev parent reply other threads:[~2012-07-10 10:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-04 9:08 [PATCH] trace: add ability to set a target task for events Andrew Vagin
2012-07-10 10:20 ` Peter Zijlstra [this message]
2012-07-10 19:51 ` Andrey Wagin
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=1341915609.3462.113.camel@twins \
--to=peterz@infradead.org \
--cc=acme@ghostprotocols.net \
--cc=asharma@fb.com \
--cc=avagin@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulus@samba.org \
--cc=rostedt@goodmis.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