Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753430AbbFLIwL (ORCPT ); Fri, 12 Jun 2015 04:52:11 -0400 Received: from terminus.zytor.com ([198.137.202.10]:34072 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753116AbbFLIwC (ORCPT ); Fri, 12 Jun 2015 04:52:02 -0400 Date: Fri, 12 Jun 2015 01:51:35 -0700 From: tip-bot for Kan Liang Message-ID: Cc: linux-kernel@vger.kernel.org, andi@firstfloor.org, acme@redhat.com, tglx@linutronix.de, kan.liang@intel.com, hpa@zytor.com, mingo@kernel.org Reply-To: tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, kan.liang@intel.com, linux-kernel@vger.kernel.org, acme@redhat.com, andi@firstfloor.org In-Reply-To: <1434004360-8570-1-git-send-email-kan.liang@intel.com> References: <1434004360-8570-1-git-send-email-kan.liang@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf stat: Error out unsupported group leader immediately Git-Commit-ID: cb5ef60067c11cc8887122f6f168c21941c5d624 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2458 Lines: 65 Commit-ID: cb5ef60067c11cc8887122f6f168c21941c5d624 Gitweb: http://git.kernel.org/tip/cb5ef60067c11cc8887122f6f168c21941c5d624 Author: Kan Liang AuthorDate: Thu, 11 Jun 2015 02:32:40 -0400 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 11 Jun 2015 11:07:40 -0300 perf stat: Error out unsupported group leader immediately 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 Tested-by: Arnaldo Carvalho de Melo Cc: Andi Kleen Link: http://lkml.kernel.org/r/1434004360-8570-1-git-send-email-kan.liang@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- 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, -- 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/