linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] perf probe: fix module name matching
@ 2016-08-05 12:22 Konstantin Khlebnikov
  2016-08-06 10:30 ` Masami Hiramatsu
  2016-08-09 19:18 ` [tip:perf/urgent] perf probe: Fix " tip-bot for Konstantin Khlebnikov
  0 siblings, 2 replies; 4+ messages in thread
From: Konstantin Khlebnikov @ 2016-08-05 12:22 UTC (permalink / raw)
  To: linux-kernel, Arnaldo Carvalho de Melo, Masami Hiramatsu

If module is "module" then dso->short_name is "[module]".
Substring comparing is't enough: "raid10" matches to "[raid1]".
This patch also checks terminating zero in module name.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 tools/perf/util/probe-event.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 953dc1ab2ed7..dd2d60ef05d3 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -170,8 +170,10 @@ static struct map *kernel_get_module_map(const char *module)
 		module = "kernel";
 
 	for (pos = maps__first(maps); pos; pos = map__next(pos)) {
+		/* short_name is "[module]" */
 		if (strncmp(pos->dso->short_name + 1, module,
-			    pos->dso->short_name_len - 2) == 0) {
+			    pos->dso->short_name_len - 2) == 0 &&
+		    module[pos->dso->short_name_len - 2] == '\0') {
 			return pos;
 		}
 	}

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] perf probe: fix module name matching
  2016-08-05 12:22 [PATCH v2] perf probe: fix module name matching Konstantin Khlebnikov
@ 2016-08-06 10:30 ` Masami Hiramatsu
  2016-08-08 19:34   ` Arnaldo Carvalho de Melo
  2016-08-09 19:18 ` [tip:perf/urgent] perf probe: Fix " tip-bot for Konstantin Khlebnikov
  1 sibling, 1 reply; 4+ messages in thread
From: Masami Hiramatsu @ 2016-08-06 10:30 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: linux-kernel, Arnaldo Carvalho de Melo

On Fri, 05 Aug 2016 15:22:36 +0300
Konstantin Khlebnikov <khlebnikov@yandex-team.ru> wrote:

> If module is "module" then dso->short_name is "[module]".
> Substring comparing is't enough: "raid10" matches to "[raid1]".
> This patch also checks terminating zero in module name.
> 
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>

Looks good to me :)

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks!

> ---
>  tools/perf/util/probe-event.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 953dc1ab2ed7..dd2d60ef05d3 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -170,8 +170,10 @@ static struct map *kernel_get_module_map(const char *module)
>  		module = "kernel";
>  
>  	for (pos = maps__first(maps); pos; pos = map__next(pos)) {
> +		/* short_name is "[module]" */
>  		if (strncmp(pos->dso->short_name + 1, module,
> -			    pos->dso->short_name_len - 2) == 0) {
> +			    pos->dso->short_name_len - 2) == 0 &&
> +		    module[pos->dso->short_name_len - 2] == '\0') {
>  			return pos;
>  		}
>  	}
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] perf probe: fix module name matching
  2016-08-06 10:30 ` Masami Hiramatsu
@ 2016-08-08 19:34   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-08-08 19:34 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Konstantin Khlebnikov, linux-kernel

Em Sat, Aug 06, 2016 at 07:30:45PM +0900, Masami Hiramatsu escreveu:
> On Fri, 05 Aug 2016 15:22:36 +0300
> Konstantin Khlebnikov <khlebnikov@yandex-team.ru> wrote:
> 
> > If module is "module" then dso->short_name is "[module]".
> > Substring comparing is't enough: "raid10" matches to "[raid1]".
> > This patch also checks terminating zero in module name.
> > 
> > Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> 
> Looks good to me :)
> 
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Ok, nevermind that other message, I hadn't seen this one, thanks!
 
> Thanks!
> 
> > ---
> >  tools/perf/util/probe-event.c |    4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> > index 953dc1ab2ed7..dd2d60ef05d3 100644
> > --- a/tools/perf/util/probe-event.c
> > +++ b/tools/perf/util/probe-event.c
> > @@ -170,8 +170,10 @@ static struct map *kernel_get_module_map(const char *module)
> >  		module = "kernel";
> >  
> >  	for (pos = maps__first(maps); pos; pos = map__next(pos)) {
> > +		/* short_name is "[module]" */
> >  		if (strncmp(pos->dso->short_name + 1, module,
> > -			    pos->dso->short_name_len - 2) == 0) {
> > +			    pos->dso->short_name_len - 2) == 0 &&
> > +		    module[pos->dso->short_name_len - 2] == '\0') {
> >  			return pos;
> >  		}
> >  	}
> > 
> 
> 
> -- 
> Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/urgent] perf probe: Fix module name matching
  2016-08-05 12:22 [PATCH v2] perf probe: fix module name matching Konstantin Khlebnikov
  2016-08-06 10:30 ` Masami Hiramatsu
@ 2016-08-09 19:18 ` tip-bot for Konstantin Khlebnikov
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Konstantin Khlebnikov @ 2016-08-09 19:18 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, khlebnikov, mhiramat, hpa, tglx, acme, mingo

Commit-ID:  cb3f3378cd09aa3fe975b4ad5ee0229dc76315bb
Gitweb:     http://git.kernel.org/tip/cb3f3378cd09aa3fe975b4ad5ee0229dc76315bb
Author:     Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
AuthorDate: Fri, 5 Aug 2016 15:22:36 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 9 Aug 2016 10:48:09 -0300

perf probe: Fix module name matching

If module is "module" then dso->short_name is "[module]".  Substring
comparing is't enough: "raid10" matches to "[raid1]".  This patch also
checks terminating zero in module name.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Link: http://lkml.kernel.org/r/147039975648.715620.12985971832789032159.stgit@buzz
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index d5ccb65..1201f73 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -170,8 +170,10 @@ static struct map *kernel_get_module_map(const char *module)
 		module = "kernel";
 
 	for (pos = maps__first(maps); pos; pos = map__next(pos)) {
+		/* short_name is "[module]" */
 		if (strncmp(pos->dso->short_name + 1, module,
-			    pos->dso->short_name_len - 2) == 0) {
+			    pos->dso->short_name_len - 2) == 0 &&
+		    module[pos->dso->short_name_len - 2] == '\0') {
 			return pos;
 		}
 	}

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-09 19:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-05 12:22 [PATCH v2] perf probe: fix module name matching Konstantin Khlebnikov
2016-08-06 10:30 ` Masami Hiramatsu
2016-08-08 19:34   ` Arnaldo Carvalho de Melo
2016-08-09 19:18 ` [tip:perf/urgent] perf probe: Fix " tip-bot for Konstantin Khlebnikov

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).