All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Kris Van Hees <kris.van.hees@oracle.com>,
	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: Mon, 8 Jul 2019 12:38:11 -0400	[thread overview]
Message-ID: <20190708163811.GB20847@oracle.com> (raw)
In-Reply-To: <20190704130509.GO3402@hirez.programming.kicks-ass.net>

On Thu, Jul 04, 2019 at 03:05:09PM +0200, Peter Zijlstra wrote:
> 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.

Oh yes, good point (and the same applies to the dt_buffer.c code where I set
up the events that own each buffer - no point in doing an explicit enable there
eiteher).

Thanks for catching this!

> > +	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;
> > +}

  reply	other threads:[~2019-07-08 16:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-04  3:13 [PATCH 0/1] tools/dtrace: initial implementation of DTrace 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
2019-07-08 16:38     ` Kris Van Hees [this message]
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=20190708163811.GB20847@oracle.com \
    --to=kris.van.hees@oracle.com \
    --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=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.