Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1395718imm; Wed, 6 Jun 2018 15:33:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJONdIleumjM+Hp9U3zZYnH8Kz7SnTUapZISSHtDdB8hVLc05eZoz2/lDL9XX60dMu1AKP5 X-Received: by 2002:a63:6096:: with SMTP id u144-v6mr3981422pgb.433.1528324396609; Wed, 06 Jun 2018 15:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528324396; cv=none; d=google.com; s=arc-20160816; b=PpDpNwyWsYsiEJOGDuIYCDcVWRQWTmzjNLXpVVCiAnuR8qG1NIhYs6lwPFnTM+Z8Hk DmP1VLfW/FHOVF7q4FTtbZ9lTI+m9xec2WwfhPEoHPZFpHSFvYZHEbXWthbZh72+OuYF XTaOlBqGbGpU6guPL2nJOVe5LueYJmzbb15wXZ2aQMM7bt0pBRwW9oO5ABMCGIctDX6B ptE7AHtnehU0KaYRjdTE/HMi05YKROTqIg+GQm9EC4Bt/7+zkzATuUGis6IOFqkcUMRV 4pthcCqZpNNYker2iBUieZtgfc4tzUg3LY+lTUAKK8PAC81+s4H6d5mrrkiVxyYIKHv4 grIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=djBEZTIyCCcGKFAPEQmYQHotDVxe2SBliWMyaYGcEXw=; b=eS4Dq87FAEG5WO5Zve8a1pBQ1rm+Xiymb0RJVBCpHIQawnD1Z3A7VT9cuTZ5dbh9Aj 45BqH8JfStPY2OHXver7nPB/xHXlV/KoA04BUSZIfgYBrucPYWKXLc5W8ur/ojdRq2d/ rI9+lp7x/1cC1my5jSWiUWFe01ewOErOe7Y6bXa5MhkNPn5EPL7dQ+WTzxgrMRorPgGU hEj5XDbqRZ6SU5v/47N88/nWQCAret+5Ggg4xGBwBY5vciOg1qIKtPFaP5XYHSMIPtYi cqOtEQGMSMgoaz8o7ob/N6pP5allMEsc5rQ6hfBCPxfOCU5UAh/AZ6+NzXg3Z1tQfJlg D8MQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1-v6si41712133pgp.10.2018.06.06.15.33.02; Wed, 06 Jun 2018 15:33:16 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752946AbeFFWPp (ORCPT + 99 others); Wed, 6 Jun 2018 18:15:45 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55888 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752571AbeFFWPi (ORCPT ); Wed, 6 Jun 2018 18:15:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F5368151D42; Wed, 6 Jun 2018 22:15:37 +0000 (UTC) Received: from krava.redhat.com (ovpn-204-89.brq.redhat.com [10.40.204.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id B08A72026DEF; Wed, 6 Jun 2018 22:15:35 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo , Peter Zijlstra Cc: lkml , Ingo Molnar , Namhyung Kim , David Ahern , Alexander Shishkin , Stephane Eranian , Milian Wolff , Andi Kleen , Frederic Weisbecker Subject: [PATCH 07/10] perf stat: Add event parsing error handling to add_default_attributes Date: Thu, 7 Jun 2018 00:15:10 +0200 Message-Id: <20180606221513.11302-8-jolsa@kernel.org> In-Reply-To: <20180606221513.11302-1-jolsa@kernel.org> References: <20180606221513.11302-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 06 Jun 2018 22:15:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 06 Jun 2018 22:15:37 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@kernel.org' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding 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 Link: http://lkml.kernel.org/n/tip-hmctifkfiaij47xb9en1hlcf@git.kernel.org Signed-off-by: Jiri Olsa --- 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 a8f93885763a..cc3dd85d5a60 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2451,14 +2451,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, @@ -2469,6 +2468,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; @@ -2494,10 +2494,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) { @@ -2532,12 +2533,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 { -- 2.13.6