linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tools: Don't set cmdline_group_boundary if no evsel is collected
@ 2015-08-26  8:32 Wang Nan
  2015-08-27 11:25 ` Wangnan (F)
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Nan @ 2015-08-26  8:32 UTC (permalink / raw)
  To: acme
  Cc: linux-kernel, Wang Nan, Alexei Starovoitov, Masami Hiramatsu,
	Namhyung Kim, Zefan Li, pi3orama

If parse_events__scanner() collects no entry, perf_evlist__last(evlist)
is invalid. Then setting of cmdline_group_boundary touches invalid.

It could happend in currect BPF implementation. See [1]. Although it
can be fixed, for safety reason it whould be better to introduce this
check.

[1]: http://lkml.kernel.org/n/1436445342-1402-19-git-send-email-wangnan0@huawei.com

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index cce3e43..02609da 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1171,9 +1171,11 @@ int parse_events(struct perf_evlist *evlist, const char *str,
 
 		perf_evlist__splice_list_tail(evlist, &data.list, entries);
 		evlist->nr_groups += data.nr_groups;
-		last = perf_evlist__last(evlist);
-		last->cmdline_group_boundary = true;
 
+		if (entries > 0) {
+			last = perf_evlist__last(evlist);
+			last->cmdline_group_boundary = true;
+		}
 		return 0;
 	}
 
-- 
1.8.3.4


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

* Re: [PATCH] perf tools: Don't set cmdline_group_boundary if no evsel is collected
  2015-08-26  8:32 [PATCH] perf tools: Don't set cmdline_group_boundary if no evsel is collected Wang Nan
@ 2015-08-27 11:25 ` Wangnan (F)
  0 siblings, 0 replies; 2+ messages in thread
From: Wangnan (F) @ 2015-08-27 11:25 UTC (permalink / raw)
  To: acme
  Cc: linux-kernel, Alexei Starovoitov, Masami Hiramatsu, Namhyung Kim,
	Zefan Li, pi3orama



On 2015/8/26 16:32, Wang Nan wrote:
> If parse_events__scanner() collects no entry, perf_evlist__last(evlist)
> is invalid. Then setting of cmdline_group_boundary touches invalid.
>
> It could happend in currect BPF implementation. See [1]. Although it
> can be fixed, for safety reason it whould be better to introduce this
> check.
>
> [1]: http://lkml.kernel.org/n/1436445342-1402-19-git-send-email-wangnan0@huawei.com
>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Alexei Starovoitov <ast@plumgrid.com>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Zefan Li <lizefan@huawei.com>
> Cc: pi3orama@163.com
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>   tools/perf/util/parse-events.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index cce3e43..02609da 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -1171,9 +1171,11 @@ int parse_events(struct perf_evlist *evlist, const char *str,
>   
>   		perf_evlist__splice_list_tail(evlist, &data.list, entries);
>   		evlist->nr_groups += data.nr_groups;
> -		last = perf_evlist__last(evlist);
> -		last->cmdline_group_boundary = true;
>   
> +		if (entries > 0) {

Now I think chinking this before list splice should be better. Plase 
ignore this patch.

Thank you.

> +			last = perf_evlist__last(evlist);
> +			last->cmdline_group_boundary = true;
> +		}
>   		return 0;
>   	}
>   



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

end of thread, other threads:[~2015-08-27 11:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-26  8:32 [PATCH] perf tools: Don't set cmdline_group_boundary if no evsel is collected Wang Nan
2015-08-27 11:25 ` Wangnan (F)

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