From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Steven Rostedt <rostedt@goodmis.org>,
Anton Arapov <anton@redhat.com>, Frank Eigler <fche@redhat.com>,
Jiri Olsa <jolsa@redhat.com>, Josh Stone <jistone@redhat.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
"Suzuki K. Poulose" <suzuki@in.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/7] perf: Introduce hw_perf_event->tp_target and ->tp_list
Date: Mon, 11 Feb 2013 15:14:24 +0530 [thread overview]
Message-ID: <20130211094424.GE525@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130204190246.GA10865@redhat.com>
* Oleg Nesterov <oleg@redhat.com> [2013-02-04 20:02:46]:
> sys_perf_event_open()->perf_init_event(event) is called before
> find_get_context(event), this means that event->ctx == NULL when
> class->reg(TRACE_REG_PERF_REGISTER/OPEN) is called and thus it
> can't know if this event is per-task or system-wide.
>
> This patch adds hw_perf_event->tp_target for PERF_TYPE_TRACEPOINT,
> this is analogous to PERF_TYPE_BREAKPOINT/bp_target we already have.
> The patch also moves ->bp_target up so that it can overlap with the
> new member, this can help the compiler to generate the better code.
>
> trace_uprobe_register() will use it for prefiltering to avoid the
> unnecessary breakpoints in mm's we do not want to trace.
>
> ->tp_target doesn't have its own reference, but we can rely on the
> fact that either sys_perf_event_open() holds a reference, or it is
> equal to event->ctx->task. So this pointer is always valid until
> free_event().
>
> Also add the "struct list_head tp_list" into this union. It is not
> strictly necessary, but it can simplify the next changes and we can
> add it for free.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> ---
> include/linux/perf_event.h | 9 +++++++--
> kernel/events/core.c | 5 ++++-
> 2 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 6bfb2fa..c9775e9 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -135,16 +135,21 @@ struct hw_perf_event {
> struct { /* software */
> struct hrtimer hrtimer;
> };
> + struct { /* tracepoint */
> + struct task_struct *tp_target;
> + /* for tp_event->class */
> + struct list_head tp_list;
> + };
> #ifdef CONFIG_HAVE_HW_BREAKPOINT
> struct { /* breakpoint */
> - struct arch_hw_breakpoint info;
> - struct list_head bp_list;
> /*
> * Crufty hack to avoid the chicken and egg
> * problem hw_breakpoint has with context
> * creation and event initalization.
> */
> struct task_struct *bp_target;
> + struct arch_hw_breakpoint info;
> + struct list_head bp_list;
> };
> #endif
> };
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 1b2e516..340fb53 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -6162,11 +6162,14 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
>
> if (task) {
> event->attach_state = PERF_ATTACH_TASK;
> +
> + if (attr->type == PERF_TYPE_TRACEPOINT)
> + event->hw.tp_target = task;
> #ifdef CONFIG_HAVE_HW_BREAKPOINT
> /*
> * hw_breakpoint is a bit difficult here..
> */
> - if (attr->type == PERF_TYPE_BREAKPOINT)
> + else if (attr->type == PERF_TYPE_BREAKPOINT)
> event->hw.bp_target = task;
> #endif
> }
> --
> 1.5.5.1
>
--
Thanks and Regards
Srikar Dronamraju
next prev parent reply other threads:[~2013-02-11 9:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-04 19:02 [PATCH 0/7] uprobes/perf: pre-filtering Oleg Nesterov
2013-02-04 19:02 ` [PATCH 1/7] perf: Ensure we do not free event->parent before event Oleg Nesterov
2013-03-20 13:35 ` Jiri Olsa
2013-02-04 19:02 ` [PATCH 2/7] perf: Introduce hw_perf_event->tp_target and ->tp_list Oleg Nesterov
2013-02-11 9:44 ` Srikar Dronamraju [this message]
2013-02-04 19:02 ` [PATCH 3/7] uprobes: Introduce uprobe_apply() Oleg Nesterov
2013-02-11 9:43 ` Srikar Dronamraju
2013-02-04 19:02 ` [PATCH 4/7] uprobes/perf: Teach trace_uprobe/perf code to track the active perf_event's Oleg Nesterov
2013-02-11 9:45 ` Srikar Dronamraju
2013-02-04 19:02 ` [PATCH 5/7] uprobes/perf: Teach trace_uprobe/perf code to pre-filter Oleg Nesterov
2013-02-11 9:46 ` Srikar Dronamraju
2013-02-04 19:03 ` [PATCH 6/7] uprobes/perf: Teach trace_uprobe/perf code to use UPROBE_HANDLER_REMOVE Oleg Nesterov
2013-02-11 9:54 ` Srikar Dronamraju
2013-02-04 19:03 ` [PATCH 7/7] uprobes/perf: Avoid uprobe_apply() whenever possible Oleg Nesterov
2013-02-11 9:55 ` Srikar Dronamraju
2013-02-06 18:10 ` [PATCH 0/7] uprobes/perf: pre-filtering Oleg Nesterov
2013-02-06 19:42 ` [PATCH 0/1] (Was uprobes/perf: pre-filtering) Oleg Nesterov
2013-02-06 19:42 ` [PATCH 1/1] perf/tools: Fix "perf record -C... workload" behaviour Oleg Nesterov
2013-02-25 9:58 ` Jiri Olsa
2013-02-07 6:01 ` [PATCH 0/1] (Was uprobes/perf: pre-filtering) Namhyung Kim
2013-02-07 15:22 ` Oleg Nesterov
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=20130211094424.GE525@linux.vnet.ibm.com \
--to=srikar@linux.vnet.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=anton@redhat.com \
--cc=fche@redhat.com \
--cc=jistone@redhat.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=rostedt@goodmis.org \
--cc=suzuki@in.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).