From: Peter Zijlstra <peterz@infradead.org>
To: Kris Van Hees <kris.van.hees@oracle.com>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
dtrace-devel@oss.oracle.com, linux-kernel@vger.kernel.org,
rostedt@goodmis.org, mhiramat@kernel.org, acme@kernel.org,
ast@kernel.org, daniel@iogearbox.net, Chris Mason <clm@fb.com>
Subject: Re: [PATCH 1/1] tools/dtrace: initial implementation of DTrace
Date: Thu, 4 Jul 2019 15:05:09 +0200 [thread overview]
Message-ID: <20190704130509.GO3402@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <201907040314.x643EUoA017906@aserv0122.oracle.com>
On Wed, Jul 03, 2019 at 08:14:30PM -0700, Kris Van Hees wrote:
> +int dt_bpf_attach(int event_id, int bpf_fd)
> +{
> + int event_fd;
> + int rc;
> + struct perf_event_attr attr = {};
> +
> + attr.type = PERF_TYPE_TRACEPOINT;
> + attr.sample_type = PERF_SAMPLE_RAW;
> + attr.sample_period = 1;
> + attr.wakeup_events = 1;
> + attr.config = event_id;
> +
> + /* Register the event (based on its id), and obtain a fd. */
> + event_fd = perf_event_open(&attr, -1, 0, -1, 0);
> + if (event_fd < 0) {
> + perror("sys_perf_event_open");
> + return -1;
> + }
> +
> + /* Enable the probe. */
> + rc = ioctl(event_fd, PERF_EVENT_IOC_ENABLE, 0);
AFAICT you didn't use attr.disabled = 1, so this IOC_ENABLE is
completely superfluous.
> + if (rc < 0) {
> + perror("PERF_EVENT_IOC_ENABLE");
> + return -1;
> + }
> +
> + /* Associate the BPF program with the event. */
> + rc = ioctl(event_fd, PERF_EVENT_IOC_SET_BPF, bpf_fd);
> + if (rc < 0) {
> + perror("PERF_EVENT_IOC_SET_BPF");
> + return -1;
> + }
> +
> + return 0;
> +}
next prev parent reply other threads:[~2019-07-04 13:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-04 3:13 [PATCH 0/1] " Kris Van Hees
2019-07-04 3:14 ` [PATCH 1/1] " Kris Van Hees
2019-07-04 13:03 ` Peter Zijlstra
2019-07-08 16:48 ` Kris Van Hees
2019-07-04 13:05 ` Peter Zijlstra [this message]
2019-07-08 16:38 ` Kris Van Hees
2019-07-04 17:13 ` Brendan Gregg
2019-07-08 17:15 ` Arnaldo Carvalho de Melo
2019-07-08 22:38 ` Kris Van Hees
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=20190704130509.GO3402@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@fb.com \
--cc=daniel@iogearbox.net \
--cc=dtrace-devel@oss.oracle.com \
--cc=kris.van.hees@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=netdev@vger.kernel.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
Powered by JetHome