netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Alban Crequy <alban.crequy@gmail.com>,
	Alban Crequy <alban@kinvolk.io>,
	Alexei Starovoitov <ast@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>, Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Omar Sandoval <osandov@fb.com>,
	linux-doc@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, iago@kinvolk.io,
	michael@kinvolk.io, "Dorau, Lukasz" <lukasz.dorau@intel.com>
Subject: Re: [PATCH v1] tracing/kprobes: expose maxactive for kretprobe in kprobe_events
Date: Wed, 29 Mar 2017 08:44:35 +0900	[thread overview]
Message-ID: <20170329084435.e2f4a2805e2139c2bf646f5b@kernel.org> (raw)
In-Reply-To: <20170328113407.56926eec@gandalf.local.home>

On Tue, 28 Mar 2017 11:34:07 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Wed, 29 Mar 2017 00:23:35 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> > > @@ -598,8 +601,10 @@ static int create_trace_kprobe(int argc, char **argv)
> > >  {
> > >  	/*
> > >  	 * Argument syntax:
> > > -	 *  - Add kprobe: p[:[GRP/]EVENT] [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS]
> > > -	 *  - Add kretprobe: r[:[GRP/]EVENT] [MOD:]KSYM[+0] [FETCHARGS]
> > > +	 *  - Add kprobe:
> > > +	 *      p[:[GRP/]EVENT] [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS]
> > > +	 *  - Add kretprobe:
> > > +	 *      r[MAXACTIVE][:[GRP/]EVENT] [MOD:]KSYM[+0] [FETCHARGS]
> > >  	 * Fetch args:
> > >  	 *  $retval	: fetch return value
> > >  	 *  $stack	: fetch stack address
> > > @@ -619,6 +624,7 @@ static int create_trace_kprobe(int argc, char **argv)
> > >  	int i, ret = 0;
> > >  	bool is_return = false, is_delete = false;
> > >  	char *symbol = NULL, *event = NULL, *group = NULL;
> > > +	int maxactive = 0;
> > >  	char *arg;
> > >  	unsigned long offset = 0;
> > >  	void *addr = NULL;
> > > @@ -637,8 +643,26 @@ static int create_trace_kprobe(int argc, char **argv)
> > >  		return -EINVAL;
> > >  	}
> > >  
> > > -	if (argv[0][1] == ':') {
> > > +	if (is_return && isdigit(argv[0][1]) && strchr(&argv[0][1], ':')) {  
> > 
> > This only supports r[MAXACTIVE:[GRP/]EVENT]. e.g "r100" without event name.
> 
> You mean it doesn't support adding MAXACTIVE without the ':event'.

Yeah, sorry for lacking the explanation...

> 
> > 
> > Thank you,
> > 
> > > +		event = strchr(&argv[0][1], ':') + 1;
> > > +		event[-1] = '\0';
> > > +		ret = kstrtouint(&argv[0][1], 0, &maxactive);
> > > +		if (ret) {
> > > +			pr_info("Failed to parse maxactive.\n");
> > > +			return ret;
> > > +		}
> > > +		/* kretprobes instances are iterated over via a list. The
> > > +		 * maximum should stay reasonable.
> > > +		 */
> > > +		if (maxactive > 1024) {
> 
> Also, can we get rid of magic numbers within the code. There should be a
> const or macro defined as MAX_MAXACTIVE or something, and use that here.

Good catch!

Thanks,

> 
> -- Steve
> 
> 
> > > +			pr_info("Maxactive is too big.\n");
> > > +			return -EINVAL;
> > > +		}
> > > +	} else if (argv[0][1] == ':') {
> > >  		event = &argv[0][2];
> > > +	}
> > > +
> > > +	if (event) {
> > >  		if (strchr(event, '/')) {
> > >  			group = event;
> > >  			event = strchr(group, '/') + 1;
> > > @@ -718,8 +742,8 @@ static int create_trace_kprobe(int argc, char **argv)
> > >  				 is_return ? 'r' : 'p', addr);
> > >  		event = buf;
> > >  	}
> > > -	tk = alloc_trace_kprobe(group, event, addr, symbol, offset, argc,
> > > -			       is_return);
> > > +	tk = alloc_trace_kprobe(group, event, addr, symbol, offset, maxactive,
> > > +			       argc, is_return);
> > >  	if (IS_ERR(tk)) {
> > >  		pr_info("Failed to allocate trace_probe.(%d)\n",
> > >  			(int)PTR_ERR(tk));
> > > -- 
> > > 2.7.4
> > >   
> > 
> > 
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2017-03-28 23:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-28 13:52 [PATCH v1] tracing/kprobes: expose maxactive for kretprobe in kprobe_events Alban Crequy
2017-03-28 15:11 ` Steven Rostedt
2017-03-28 15:23 ` Masami Hiramatsu
2017-03-28 15:34   ` Steven Rostedt
2017-03-28 23:44     ` Masami Hiramatsu [this message]
2017-03-28 16:08   ` Alban Crequy
2017-03-28 23:50     ` Masami Hiramatsu

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=20170329084435.e2f4a2805e2139c2bf646f5b@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=acme@redhat.com \
    --cc=alban.crequy@gmail.com \
    --cc=alban@kinvolk.io \
    --cc=ast@kernel.org \
    --cc=corbet@lwn.net \
    --cc=iago@kinvolk.io \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukasz.dorau@intel.com \
    --cc=michael@kinvolk.io \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=osandov@fb.com \
    --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;
as well as URLs for NNTP newsgroup(s).