Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1215112 > unrolled thread

[PATCH 02/32] perf tools: Don't set cmdline_group_boundary if no evsel is collected

Started byWang Nan <wangnan0@huawei.com>
First post2015-08-28 08:30 +0200
Last post2015-08-28 08:30 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 02/32] perf tools: Don't set cmdline_group_boundary if no evsel is collected Wang Nan <wangnan0@huawei.com> - 2015-08-28 08:30 +0200

#1215112 — [PATCH 02/32] perf tools: Don't set cmdline_group_boundary if no evsel is collected

FromWang Nan <wangnan0@huawei.com>
Date2015-08-28 08:30 +0200
Subject[PATCH 02/32] perf tools: Don't set cmdline_group_boundary if no evsel is collected
Message-ID<q2lkJ-3up-5@gated-at.bofh.it>
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.

Instead of checking number of entries, check data.list instead, so we
can add dummy evsel here.

[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 | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index d826e6f..14cd7e3 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1143,10 +1143,14 @@ int parse_events(struct perf_evlist *evlist, const char *str,
 		int entries = data.idx - evlist->nr_entries;
 		struct perf_evsel *last;
 
+		if (!list_empty(&data.list)) {
+			last = list_entry(data.list.prev,
+					  struct perf_evsel, node);
+			last->cmdline_group_boundary = true;
+		}
+
 		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;
 
 		return 0;
 	}
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web