linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Naveen Rao <naveen.n.rao@linux.vnet.ibm.com>,
	Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Subject: Re: [for-next][PATCH 7/8] tracing/probe: Reject exactly same probe event
Date: Mon, 23 Sep 2019 10:15:26 -0700	[thread overview]
Message-ID: <20190923101526.a1a9ccde50da83fbdc86aad8@kernel.org> (raw)
In-Reply-To: <20190923102035.GA30095@linux.vnet.ibm.com>

On Mon, 23 Sep 2019 16:12:53 +0530
Srikar Dronamraju <srikar@linux.vnet.ibm.com> wrote:

> Hey Masami, Steven
> 
> >  
> > +static bool trace_kprobe_has_same_kprobe(struct trace_kprobe *orig,
> > +					 struct trace_kprobe *comp)
> > +{
> > +	struct trace_probe_event *tpe = orig->tp.event;
> > +	struct trace_probe *pos;
> > +	int i;
> > +
> > +	list_for_each_entry(pos, &tpe->probes, list) {
> > +		orig = container_of(pos, struct trace_kprobe, tp);
> > +		if (strcmp(trace_kprobe_symbol(orig),
> > +			   trace_kprobe_symbol(comp)) ||
> > +		    trace_kprobe_offset(orig) != trace_kprobe_offset(comp))
> > +			continue;
> > +
> > +		/*
> > +		 * trace_probe_compare_arg_type() ensured that nr_args and
> > +		 * each argument name and type are same. Let's compare comm.
> > +		 */
> > +		for (i = 0; i < orig->tp.nr_args; i++) {
> > +			if (strcmp(orig->tp.args[i].comm,
> > +				   comp->tp.args[i].comm))
> > +				continue;
> 
> In a nested loop, *continue* is going to continue iterating through the
> inner loop. In which case, continue is doing nothing here. I thought we
> should have used a goto instead. No?  To me, continue as a last statement of
> a for loop always looks weird.

Oops, thanks for pointing it out!

> 
> > +		}
> > +
> > +		return true;
> > +	}
> 
> I think we need something like this:
> 
> 	list_for_each_entry(pos, &tpe->probes, list) {
> 		orig = container_of(pos, struct trace_kprobe, tp);
> 		if (strcmp(trace_kprobe_symbol(orig),
> 			   trace_kprobe_symbol(comp)) ||
> 		    trace_kprobe_offset(orig) != trace_kprobe_offset(comp))
> 			continue;
> 
> 		/*
> 		 * trace_probe_compare_arg_type() ensured that nr_args and
> 		 * each argument name and type are same. Let's compare comm.
> 		 */
> 		for (i = 0; i < orig->tp.nr_args; i++) {
> 			if (strcmp(orig->tp.args[i].comm,
> 				   comp->tp.args[i].comm))
> 				goto outer_loop;
> 
> 		}
> 
> 		return true;
> outer_loop:
> 	}

Correct, that's what I intended.
Could you make a fix patch on top of it? (or do I?)

Thank you,

> 
> 
> > +
> > +	return false;
> > +}
> > +
> >  
> 
> ......
> 
> > +static bool trace_uprobe_has_same_uprobe(struct trace_uprobe *orig,
> > +					 struct trace_uprobe *comp)
> > +{
> > +	struct trace_probe_event *tpe = orig->tp.event;
> > +	struct trace_probe *pos;
> > +	struct inode *comp_inode = d_real_inode(comp->path.dentry);
> > +	int i;
> > +
> > +	list_for_each_entry(pos, &tpe->probes, list) {
> > +		orig = container_of(pos, struct trace_uprobe, tp);
> > +		if (comp_inode != d_real_inode(orig->path.dentry) ||
> > +		    comp->offset != orig->offset)
> > +			continue;
> > +
> > +		/*
> > +		 * trace_probe_compare_arg_type() ensured that nr_args and
> > +		 * each argument name and type are same. Let's compare comm.
> > +		 */
> > +		for (i = 0; i < orig->tp.nr_args; i++) {
> > +			if (strcmp(orig->tp.args[i].comm,
> > +				   comp->tp.args[i].comm))
> > +				continue;
> 
> Same as above.
> 
> > +		}
> > +
> > +		return true;
> > +	}
> > +
> > +	return false;
> > +}
> > +
> 
> -- 
> Thanks and Regards
> Srikar Dronamraju
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2019-09-23 17:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 23:23 [for-next][PATCH 0/8] tracing: Final updates before sending to Linus Steven Rostedt
2019-09-19 23:23 ` [for-next][PATCH 1/8] ftrace: Simplify ftrace hash lookup code in clear_func_from_hash() Steven Rostedt
2019-09-19 23:23 ` [for-next][PATCH 2/8] tracing: Be more clever when dumping hex in __print_hex() Steven Rostedt
2019-09-19 23:23 ` [for-next][PATCH 3/8] tracing: Make sure variable reference alias has correct var_ref_idx Steven Rostedt
     [not found]   ` <20190921120618.DF81120665@mail.kernel.org>
2019-09-21 12:20     ` Steven Rostedt
2019-09-21 19:21       ` Sasha Levin
2019-09-21 19:23         ` Steven Rostedt
2019-09-19 23:23 ` [for-next][PATCH 4/8] tracing/kprobe: Fix NULL pointer access in trace_porbe_unlink() Steven Rostedt
2019-09-19 23:23 ` [for-next][PATCH 5/8] selftests/ftrace: Select an existing function in kprobe_eventname test Steven Rostedt
2019-09-19 23:23 ` [for-next][PATCH 6/8] tracing/probe: Fix to allow user to enable events on unloaded modules Steven Rostedt
2019-09-19 23:23 ` [for-next][PATCH 7/8] tracing/probe: Reject exactly same probe event Steven Rostedt
2019-09-23 10:42   ` Srikar Dronamraju
2019-09-23 17:15     ` Masami Hiramatsu [this message]
2019-09-23 17:42       ` Srikar Dronamraju
2019-09-19 23:23 ` [for-next][PATCH 8/8] selftests/ftrace: Update kprobe event error testcase Steven Rostedt

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=20190923101526.a1a9ccde50da83fbdc86aad8@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=ravi.bangoria@linux.ibm.com \
    --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).