linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/probe: Skip same probe address
@ 2019-09-19  3:41 Masami Hiramatsu
  2019-09-20 18:26 ` Arnaldo Carvalho de Melo
  2019-09-22 10:52 ` [tip: perf/urgent] perf probe: Skip same probe address for a given line tip-bot2 for Masami Hiramatsu
  0 siblings, 2 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2019-09-19  3:41 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Wang Nan, Jiri Olsa, Namhyung Kim, Masami Hiramatsu, linux-kernel

Fix to skip making a same probe address on given line.

Since dwarf line info contains several entries for one line
with different column, perf probe will make a different
probe on same address if user specifies a probe point by
"function:line" or "file:line".

e.g.
 $ perf probe -D kernel_read:8
 p:probe/kernel_read_L8 kernel_read+39
 p:probe/kernel_read_L8_1 kernel_read+39

This skips such duplicated probe address.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/perf/util/probe-finder.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 025fc4491993..02ca95deaf2c 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1244,6 +1244,17 @@ static int expand_probe_args(Dwarf_Die *sc_die, struct probe_finder *pf,
 	return n;
 }
 
+static bool trace_event_finder_overlap(struct trace_event_finder *tf)
+{
+	int i;
+
+	for (i = 0; i < tf->ntevs; i++) {
+		if (tf->pf.addr == tf->tevs[i].point.address)
+			return true;
+	}
+	return false;
+}
+
 /* Add a found probe point into trace event list */
 static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
 {
@@ -1254,6 +1265,14 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
 	struct perf_probe_arg *args = NULL;
 	int ret, i;
 
+	/*
+	 * For some reason (e.g. different column assigned to same address)
+	 * This callback can be called with the address which already passed.
+	 * Ignore it first.
+	 */
+	if (trace_event_finder_overlap(tf))
+		return 0;
+
 	/* Check number of tevs */
 	if (tf->ntevs == tf->max_tevs) {
 		pr_warning("Too many( > %d) probe point found.\n",


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

* Re: [PATCH] perf/probe: Skip same probe address
  2019-09-19  3:41 [PATCH] perf/probe: Skip same probe address Masami Hiramatsu
@ 2019-09-20 18:26 ` Arnaldo Carvalho de Melo
  2019-09-22 10:52 ` [tip: perf/urgent] perf probe: Skip same probe address for a given line tip-bot2 for Masami Hiramatsu
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-09-20 18:26 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Wang Nan, Jiri Olsa, Namhyung Kim, linux-kernel

Em Thu, Sep 19, 2019 at 12:41:10PM +0900, Masami Hiramatsu escreveu:
> Fix to skip making a same probe address on given line.
> 
> Since dwarf line info contains several entries for one line
> with different column, perf probe will make a different
> probe on same address if user specifies a probe point by
> "function:line" or "file:line".
> 
> e.g.
>  $ perf probe -D kernel_read:8
>  p:probe/kernel_read_L8 kernel_read+39
>  p:probe/kernel_read_L8_1 kernel_read+39
> 
> This skips such duplicated probe address.

Thanks, applied to perf/urgent.

- Arnaldo
 
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
>  tools/perf/util/probe-finder.c |   19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> index 025fc4491993..02ca95deaf2c 100644
> --- a/tools/perf/util/probe-finder.c
> +++ b/tools/perf/util/probe-finder.c
> @@ -1244,6 +1244,17 @@ static int expand_probe_args(Dwarf_Die *sc_die, struct probe_finder *pf,
>  	return n;
>  }
>  
> +static bool trace_event_finder_overlap(struct trace_event_finder *tf)
> +{
> +	int i;
> +
> +	for (i = 0; i < tf->ntevs; i++) {
> +		if (tf->pf.addr == tf->tevs[i].point.address)
> +			return true;
> +	}
> +	return false;
> +}
> +
>  /* Add a found probe point into trace event list */
>  static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
>  {
> @@ -1254,6 +1265,14 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
>  	struct perf_probe_arg *args = NULL;
>  	int ret, i;
>  
> +	/*
> +	 * For some reason (e.g. different column assigned to same address)
> +	 * This callback can be called with the address which already passed.
> +	 * Ignore it first.
> +	 */
> +	if (trace_event_finder_overlap(tf))
> +		return 0;
> +
>  	/* Check number of tevs */
>  	if (tf->ntevs == tf->max_tevs) {
>  		pr_warning("Too many( > %d) probe point found.\n",

-- 

- Arnaldo

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

* [tip: perf/urgent] perf probe: Skip same probe address for a given line
  2019-09-19  3:41 [PATCH] perf/probe: Skip same probe address Masami Hiramatsu
  2019-09-20 18:26 ` Arnaldo Carvalho de Melo
@ 2019-09-22 10:52 ` tip-bot2 for Masami Hiramatsu
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Masami Hiramatsu @ 2019-09-22 10:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Masami Hiramatsu, Arnaldo Carvalho de Melo, Jiri Olsa,
	Namhyung Kim, Wang Nan, Ingo Molnar, Borislav Petkov,
	linux-kernel

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     1a375ae7659ab740d4c885ea98c1659b8a6e2071
Gitweb:        https://git.kernel.org/tip/1a375ae7659ab740d4c885ea98c1659b8a6e2071
Author:        Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate:    Thu, 19 Sep 2019 12:41:10 +09:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Fri, 20 Sep 2019 15:22:00 -03:00

perf probe: Skip same probe address for a given line

Fix to skip making a same probe address on given line.

Since a DWARF line info contains several entries for one line with
different column, perf probe will make a different probe on same address
if user specifies a probe point by "function:line" or "file:line".

e.g.
 $ perf probe -D kernel_read:8
 p:probe/kernel_read_L8 kernel_read+39
 p:probe/kernel_read_L8_1 kernel_read+39

This skips such duplicated probe addresses.

Committer testing:

  # uname -a
  Linux quaco 5.3.0+ #2 SMP Thu Sep 19 16:13:22 -03 2019 x86_64 x86_64 x86_64 GNU/Linux
  #

Before:

  # perf probe -D kernel_read:8
  p:probe/kernel_read _text+3115191
  p:probe/kernel_read_1 _text+3115191
  #

After:

  # perf probe -D kernel_read:8
  p:probe/kernel_read _text+3115191
  #

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lore.kernel.org/lkml/156886447061.10772.4261569305869149178.stgit@devnote2
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-finder.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 505905f..cd9f95e 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1245,6 +1245,17 @@ static int expand_probe_args(Dwarf_Die *sc_die, struct probe_finder *pf,
 	return n;
 }
 
+static bool trace_event_finder_overlap(struct trace_event_finder *tf)
+{
+	int i;
+
+	for (i = 0; i < tf->ntevs; i++) {
+		if (tf->pf.addr == tf->tevs[i].point.address)
+			return true;
+	}
+	return false;
+}
+
 /* Add a found probe point into trace event list */
 static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
 {
@@ -1255,6 +1266,14 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
 	struct perf_probe_arg *args = NULL;
 	int ret, i;
 
+	/*
+	 * For some reason (e.g. different column assigned to same address)
+	 * This callback can be called with the address which already passed.
+	 * Ignore it first.
+	 */
+	if (trace_event_finder_overlap(tf))
+		return 0;
+
 	/* Check number of tevs */
 	if (tf->ntevs == tf->max_tevs) {
 		pr_warning("Too many( > %d) probe point found.\n",

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

end of thread, other threads:[~2019-09-22 10:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-19  3:41 [PATCH] perf/probe: Skip same probe address Masami Hiramatsu
2019-09-20 18:26 ` Arnaldo Carvalho de Melo
2019-09-22 10:52 ` [tip: perf/urgent] perf probe: Skip same probe address for a given line tip-bot2 for Masami Hiramatsu

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