Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1557434imm; Wed, 13 Jun 2018 23:26:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL1icaUNzfak/qtKuyn44ritab57KhdbniAhJLXbxFeGZavomnp+TJpSBdVAmXa+LFUfYOJ X-Received: by 2002:a62:3bd2:: with SMTP id w79-v6mr8127787pfj.129.1528957585359; Wed, 13 Jun 2018 23:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528957585; cv=none; d=google.com; s=arc-20160816; b=jkp6lMMIODVzKSaOxPi/FgHsnd+W4WhNNKpdZt2LoLnTQq3mNSBLeTPtBBE4ttJ6ad E26wNElwqCRI5fMktNbLnMa2vo1SBUV58Nj0mk/gaaW7EJ9FkQcdZnR70PAwE+5TeOl0 inkMn/wqHJvUlP6x9KxxKDXUj+h3kSupc1fpDynoLkwZozeywcgtCcasUux9JNdmmT8L xVw/r7Xxv4pF6E+ZHZH0PXVmQlSVb5QT22PfheN25BhJYwDX/U3m+aH/Dfa4UIetri1s 9jQkzdGqm6WtoDm6Z4gVjQ11tZ4ugF4gTKRbsSFbsZG/uuKzbydz/UrHzVkBl6++hphe KRTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=2gqvSSX37LGyr+GjrjUEtXtXwIwBnROe8QJahJ58Gow=; b=PqpYAW3tGVGuoJAXdcQjTHs/Gvid8BhHm9WNXbLl/BxdAZ4gneiXP0L5ecvrlDNwC/ XNn9BhT5fSxXV/F1k9wgJEJiviDhZDMPhvSYnoX69xvW80V5YjZztKW6Ov9YZzT3AAmZ 77ZQD4n3P0kG4DrWh5wiBiVRGDe8C/Ege5xODAs3TFuJDIyuzYqzNvMW1xpoVGaI2maa 4QVy6skbeEU/S144/b/LNvLPd+R+aJ2ikJt939wnoe9BKLDDQYheAJl9p8ltWxOKjHJh 1trfaf3iUnonItOLN9gr8gamjCg6ZT4Y2uFhFQrgc8QmAPP32ViHQgOElFvP4R4brtBZ MJQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12-v6si3810311pgn.171.2018.06.13.23.26.11; Wed, 13 Jun 2018 23:26:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754619AbeFNGYV (ORCPT + 99 others); Thu, 14 Jun 2018 02:24:21 -0400 Received: from terminus.zytor.com ([198.137.202.136]:49837 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752681AbeFNGYT (ORCPT ); Thu, 14 Jun 2018 02:24:19 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5E6Nove763905 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 13 Jun 2018 23:23:51 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5E6No5b763902; Wed, 13 Jun 2018 23:23:50 -0700 Date: Wed, 13 Jun 2018 23:23:50 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Jiri Olsa Message-ID: Cc: linux-kernel@vger.kernel.org, acme@redhat.com, namhyung@kernel.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, tglx@linutronix.de, frederic@kernel.org, peterz@infradead.org, dsahern@gmail.com, eranian@google.com, hpa@zytor.com, milian.wolff@kdab.com, mingo@kernel.org, andi@firstfloor.org Reply-To: jolsa@kernel.org, tglx@linutronix.de, alexander.shishkin@linux.intel.com, acme@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, milian.wolff@kdab.com, mingo@kernel.org, andi@firstfloor.org, frederic@kernel.org, peterz@infradead.org, dsahern@gmail.com, eranian@google.com, hpa@zytor.com In-Reply-To: <20180606221513.11302-8-jolsa@kernel.org> References: <20180606221513.11302-8-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf stat: Add event parsing error handling to add_default_attributes Git-Commit-ID: a5cfa6217c94a1f1cfad4481fc14f5fc399abde3 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 X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a5cfa6217c94a1f1cfad4481fc14f5fc399abde3 Gitweb: https://git.kernel.org/tip/a5cfa6217c94a1f1cfad4481fc14f5fc399abde3 Author: Jiri Olsa AuthorDate: Thu, 7 Jun 2018 00:15:10 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 7 Jun 2018 16:03:21 -0300 perf stat: Add event parsing error handling to add_default_attributes Add missing error handling for parse_events calls in add_default_attributes functions. The error handler displays error details, like for transactions (-T): Before: $ perf stat -T Cannot set up transaction events After: $ perf stat -T Cannot set up transaction events event syntax error: '..cycles,cpu/cycles-t/,cpu/tx-start/,cpu/el-start/,cpu/cycles-ct/}' \___ unknown term Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: David Ahern Cc: Frederic Weisbecker Cc: Milian Wolff Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180606221513.11302-8-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 3fc1f5286d50..22547a490e1f 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2442,14 +2442,13 @@ static int add_default_attributes(void) (PERF_COUNT_HW_CACHE_OP_PREFETCH << 8) | (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) }, }; + struct parse_events_error errinfo; /* Set attrs if no event is selected and !null_run: */ if (null_run) return 0; if (transaction_run) { - struct parse_events_error errinfo; - if (pmu_have_event("cpu", "cycles-ct") && pmu_have_event("cpu", "el-start")) err = parse_events(evsel_list, transaction_attrs, @@ -2460,6 +2459,7 @@ static int add_default_attributes(void) &errinfo); if (err) { fprintf(stderr, "Cannot set up transaction events\n"); + parse_events_print_error(&errinfo, transaction_attrs); return -1; } return 0; @@ -2485,10 +2485,11 @@ static int add_default_attributes(void) pmu_have_event("msr", "smi")) { if (!force_metric_only) metric_only = true; - err = parse_events(evsel_list, smi_cost_attrs, NULL); + err = parse_events(evsel_list, smi_cost_attrs, &errinfo); } else { fprintf(stderr, "To measure SMI cost, it needs " "msr/aperf/, msr/smi/ and cpu/cycles/ support\n"); + parse_events_print_error(&errinfo, smi_cost_attrs); return -1; } if (err) { @@ -2523,12 +2524,13 @@ static int add_default_attributes(void) if (topdown_attrs[0] && str) { if (warn) arch_topdown_group_warn(); - err = parse_events(evsel_list, str, NULL); + err = parse_events(evsel_list, str, &errinfo); if (err) { fprintf(stderr, "Cannot set up top down events %s: %d\n", str, err); free(str); + parse_events_print_error(&errinfo, str); return -1; } } else {