linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Kan Liang <kan.liang@intel.com>,
	Andi Kleen <andi@firstfloor.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 4/7] perf stat: Error out unsupported group leader immediately
Date: Thu, 11 Jun 2015 23:15:40 -0300	[thread overview]
Message-ID: <1434075343-4173-5-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1434075343-4173-1-git-send-email-acme@kernel.org>

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.

Commiter note: Here I got a different output, but no core dump:

  [acme@zoo linux]$ perf stat -x, -e '{node-prefetch-refs,cycles}' -- sleep 1
  Error:
  The sys_perf_event_open() syscall returned with 22 (Invalid argument)
  for event (node-prefetch-refs).
  /bin/dmesg may provide additional information.
  No CONFIG_PERF_EVENTS=y kernel support configured?

Signed-off-by: Kan Liang <kan.liang@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Link: http://lkml.kernel.org/r/1434004360-8570-1-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.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 ff3d25803400..b24ecee95fec 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,
-- 
2.1.0


  parent reply	other threads:[~2015-06-12  2:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12  2:15 [GIT PULL 0/7] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-06-12  2:15 ` [PATCH 1/7] perf tools: Avoid possible race condition in copyfile() Arnaldo Carvalho de Melo
2015-06-12  2:15 ` [PATCH 2/7] perf record: Amend option summaries Arnaldo Carvalho de Melo
2015-06-12  2:15 ` [PATCH 3/7] perf evsel: Display 0x for hex values when printing the attribute Arnaldo Carvalho de Melo
2015-06-12  2:15 ` Arnaldo Carvalho de Melo [this message]
2015-06-12  2:15 ` [PATCH 5/7] perf tools: Fix build failure on 32-bit arch Arnaldo Carvalho de Melo
2015-06-12  2:15 ` [PATCH 6/7] trace: Beautify perf_event_open syscall Arnaldo Carvalho de Melo
2015-06-12  2:15 ` [PATCH 7/7] perf tools: Update MANIFEST per files removed from kernel Arnaldo Carvalho de Melo
2015-06-12  8:09 ` [GIT PULL 0/7] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434075343-4173-5-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=andi@firstfloor.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).