public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] perf,tools: error out unsupported group leader immediately for perf stat
@ 2015-06-11  6:32 kan.liang
  2015-06-11 14:03 ` Arnaldo Carvalho de Melo
  2015-06-12  8:51 ` [tip:perf/core] perf stat: Error out unsupported group leader immediately tip-bot for Kan Liang
  0 siblings, 2 replies; 5+ messages in thread
From: kan.liang @ 2015-06-11  6:32 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, andi, Kan Liang

From: Kan Liang <kan.liang@intel.com>

perf stat ignores the unsupported event and continue to count supported
event. But if the unsupported event is group leader, perf tool will
crash. After applying this patch, the unsupported group leader will
error out immediately.

Without this patch:
$ perf stat -x, -e '{node-prefetch-refs,cycles}' --  sleep 1
perf: util/evsel.c:1009: get_group_fd: Assertion `!(fd == -1)' failed.
Aborted (core dumped)

With this patch:
$ perf stat -x, -e '{node-prefetch-refs,cycles}' --  sleep 1
Error:
The node-prefetch-refs event is not supported.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 tools/perf/builtin-stat.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index ff3d258..b24ecee 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -549,7 +549,10 @@ static int __run_perf_stat(int argc, const char **argv)
 					ui__warning("%s event is not supported by the kernel.\n",
 						    perf_evsel__name(counter));
 				counter->supported = false;
-				continue;
+
+				if ((counter->leader != counter) ||
+				    !(counter->leader->nr_members > 1))
+					continue;
 			}
 
 			perf_evsel__open_strerror(counter, &target,
-- 
1.8.3.1


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

end of thread, other threads:[~2015-06-12  8:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-11  6:32 [PATCH 1/1] perf,tools: error out unsupported group leader immediately for perf stat kan.liang
2015-06-11 14:03 ` Arnaldo Carvalho de Melo
2015-06-11 14:26   ` Liang, Kan
2015-06-11 14:29     ` Arnaldo Carvalho de Melo
2015-06-12  8:51 ` [tip:perf/core] perf stat: Error out unsupported group leader immediately tip-bot for Kan Liang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox