From: Song Liu <songliubraving@fb.com>
To: lkml <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Cc: Kernel Team <Kernel-team@fb.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
"Naveen N . Rao" <naveen.n.rao@linux.vnet.ibm.com>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH RESEND] trace_uprobe: support reference counter in fd-based uprobe
Date: Fri, 28 Sep 2018 07:23:20 +0000 [thread overview]
Message-ID: <9489EF78-07EA-41AC-8A4D-F3FD3359C826@fb.com> (raw)
In-Reply-To: <20180924211236.4149482-1-songliubraving@fb.com>
Hi Peter,
> On Sep 24, 2018, at 2:12 PM, Song Liu <songliubraving@fb.com> wrote:
>
> This patch enables uprobes with reference counter in fd-based uprobe.
> Highest 40 bits of perf_event_attr.config is used to stored offset
> of the reference counter (semaphore).
>
> Format information in /sys/bus/event_source/devices/uprobe/format/ is
> updated to reflect this new feature.
>
> Signed-off-by: Song Liu <songliubraving@fb.com>
> Reviewed-and-tested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
> include/linux/trace_events.h | 3 +-
> kernel/events/core.c | 49 ++++++++++++++++++++++++++-------
> kernel/trace/trace_event_perf.c | 7 +++--
> kernel/trace/trace_probe.h | 3 +-
> kernel/trace/trace_uprobe.c | 4 ++-
> 5 files changed, 50 insertions(+), 16 deletions(-)
>
> diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
> index 78a010e19ed4..4130a5497d40 100644
> --- a/include/linux/trace_events.h
> +++ b/include/linux/trace_events.h
> @@ -575,7 +575,8 @@ extern int bpf_get_kprobe_info(const struct perf_event *event,
> bool perf_type_tracepoint);
> #endif
> #ifdef CONFIG_UPROBE_EVENTS
> -extern int perf_uprobe_init(struct perf_event *event, bool is_retprobe);
> +extern int perf_uprobe_init(struct perf_event *event,
> + unsigned long ref_ctr_offset, bool is_retprobe);
> extern void perf_uprobe_destroy(struct perf_event *event);
> extern int bpf_get_uprobe_info(const struct perf_event *event,
> u32 *fd_type, const char **filename,
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index c80549bf82c6..a4ad5235ec9b 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -8368,30 +8368,39 @@ static struct pmu perf_tracepoint = {
> *
> * PERF_PROBE_CONFIG_IS_RETPROBE if set, create kretprobe/uretprobe
> * if not set, create kprobe/uprobe
> + *
> + * The following values specify a reference counter (or semaphore in the
> + * terminology of tools like dtrace, systemtap, etc.) Userspace Statically
> + * Defined Tracepoints (USDT). Currently, we use 40 bit for the offset.
> + *
> + * PERF_UPROBE_REF_CTR_OFFSET_BITS # of bits in config as th offset
> + * PERF_UPROBE_REF_CTR_OFFSET_SHIFT # of bits to shift left
> */
> enum perf_probe_config {
> PERF_PROBE_CONFIG_IS_RETPROBE = 1U << 0, /* [k,u]retprobe */
> + PERF_UPROBE_REF_CTR_OFFSET_BITS = 40,
> + PERF_UPROBE_REF_CTR_OFFSET_SHIFT = 64 - PERF_UPROBE_REF_CTR_OFFSET_BITS,
> };
>
> PMU_FORMAT_ATTR(retprobe, "config:0");
> +#endif
>
> -static struct attribute *probe_attrs[] = {
> +#ifdef CONFIG_KPROBE_EVENTS
> +static struct attribute *kprobe_attrs[] = {
> &format_attr_retprobe.attr,
> NULL,
> };
>
> -static struct attribute_group probe_format_group = {
> +static struct attribute_group kprobe_format_group = {
> .name = "format",
> - .attrs = probe_attrs,
> + .attrs = kprobe_attrs,
> };
>
> -static const struct attribute_group *probe_attr_groups[] = {
> - &probe_format_group,
> +static const struct attribute_group *kprobe_attr_groups[] = {
> + &kprobe_format_group,
> NULL,
> };
> -#endif
>
> -#ifdef CONFIG_KPROBE_EVENTS
> static int perf_kprobe_event_init(struct perf_event *event);
> static struct pmu perf_kprobe = {
> .task_ctx_nr = perf_sw_context,
> @@ -8401,7 +8410,7 @@ static struct pmu perf_kprobe = {
> .start = perf_swevent_start,
> .stop = perf_swevent_stop,
> .read = perf_swevent_read,
> - .attr_groups = probe_attr_groups,
> + .attr_groups = kprobe_attr_groups,
> };
>
> static int perf_kprobe_event_init(struct perf_event *event)
> @@ -8433,6 +8442,24 @@ static int perf_kprobe_event_init(struct perf_event *event)
> #endif /* CONFIG_KPROBE_EVENTS */
>
> #ifdef CONFIG_UPROBE_EVENTS
> +PMU_FORMAT_ATTR(ref_ctr_offset, "config:63-24");
I guess you meant this part? This is for uprobe only, so I put
it here.
Thanks,
Song
> +
> +static struct attribute *uprobe_attrs[] = {
> + &format_attr_retprobe.attr,
> + &format_attr_ref_ctr_offset.attr,
> + NULL,
> +};
> +
> +static struct attribute_group uprobe_format_group = {
> + .name = "format",
> + .attrs = uprobe_attrs,
> +};
> +
> +static const struct attribute_group *uprobe_attr_groups[] = {
> + &uprobe_format_group,
> + NULL,
> +};
> +
> static int perf_uprobe_event_init(struct perf_event *event);
> static struct pmu perf_uprobe = {
> .task_ctx_nr = perf_sw_context,
> @@ -8442,12 +8469,13 @@ static struct pmu perf_uprobe = {
> .start = perf_swevent_start,
> .stop = perf_swevent_stop,
> .read = perf_swevent_read,
> - .attr_groups = probe_attr_groups,
> + .attr_groups = uprobe_attr_groups,
> };
>
next prev parent reply other threads:[~2018-09-28 7:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-24 21:12 [PATCH RESEND] trace_uprobe: support reference counter in fd-based uprobe Song Liu
2018-09-25 6:26 ` kbuild test robot
2018-09-25 14:46 ` Song Liu
2018-09-26 16:06 ` Steven Rostedt
2018-09-28 7:18 ` Peter Zijlstra
2018-09-28 7:23 ` Song Liu [this message]
2018-09-28 7:52 ` Peter Zijlstra
2018-09-28 14:50 ` Song Liu
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=9489EF78-07EA-41AC-8A4D-F3FD3359C826@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=srikar@linux.vnet.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).