Message ID | 20240131063048.492010-2-irogers@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-45837-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1707799dyb; Tue, 30 Jan 2024 22:41:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFM8iiyatsn/ao8PPEAZJ8JafzdVBrrykBarVz1r9O/6JrtBXicK5VY6k87QKEw9sFLEbga X-Received: by 2002:a17:906:4154:b0:a36:70ce:31ba with SMTP id l20-20020a170906415400b00a3670ce31bamr422575ejk.5.1706683318553; Tue, 30 Jan 2024 22:41:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706683318; cv=pass; d=google.com; s=arc-20160816; b=Y6wz4Pll9k2ufM1JV7LQ5cr8NwVy3de0PAar2AhLqf5AoVBkotmHL3Qj1wuNvGJLJR UrhMmqgyfKLX0u1WlKVnqj9qJT0zps09who6FNUKcasZnVWQGMgnm/gotb2J7Sulu/Vu xrABtHFPRRbDWJdCz7kn4OZUXE0A3XYDgpM6MAFyfdCSNw+M8Riv4vZqkz8XSkOYArvB YsBx/ag1pLO8tb72KJu1KRExLW5jJ78Lewm+5Az4ese6zj9ITd8F5JAS07OyrMuvHpQO rSjlmoO44N9E5y3M+yI8svFOMAaiX4N7xlLtNMeIrySL40cIETrFuZeeVqdePxzq0SdB t9JA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=G1xH5pJjJI+heTB8iMmEvxa0X+0fNgErrr9gRIyth2g=; fh=Bb9GT1Fp1iBSZ3Po0YmCA3XjCUI3vgOx+eK2EHEr+po=; b=RUI6tIgt9M0MXhback9Xq0xVUsUWkwX0H7B7q9rjo07LJdyXv6WFDRzcBljjRk7r7S b2ZAwdhZtlMUrGJRWQqX0LD7WyQ7Um0CjcdfYUxNuQAagDesmE/tAusyyT3u4ZKRQa5r LSqfix87elon/bkzBrDCdsmeDX02VGkhoio2ntPI7oFdL155UNUprA9t76Zy4c1RurjO MbcTiP85uiOnDAf+t9Q4T421EjtVceZXh0/naO69cU/z1rxxKTS3LwSpkPluVz1FRyTj zFiggW5CZMw8vhPdB2cWDRTafpdEMPdKZ1u6inTstXbi9fi+9oBtp2JK4P1+umg3INyX 3hVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=z+cNMApf; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-45837-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45837-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCXqkUK7uCMWYNQEA/0b+FeBOGG6cqWBugj0rdaEw3if5pYDmIm/OVQywrSatobQtIm8yHpjXtqYaNFSCer6CQmYXC7Jdg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h13-20020a17090619cd00b00a35e32fd8a6si2158170ejd.237.2024.01.30.22.41.58 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 22:41:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45837-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=z+cNMApf; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-45837-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45837-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 05FBD1F29A59 for <ouuuleilei@gmail.com>; Wed, 31 Jan 2024 06:31:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B34EC45013; Wed, 31 Jan 2024 06:31:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="z+cNMApf" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D3CB4E1C7 for <linux-kernel@vger.kernel.org>; Wed, 31 Jan 2024 06:31:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706682666; cv=none; b=cgyJQ5bM2Jk+xGN1f5uXYjc0GHKvZMlV5OJXY0M1y5ArXztX0IpWAiAOyzegGjP5X01Y/jZ1VJUx2rdXS921Q/COKIB94eZmEKTSrF0cXdq8p2eGlXFTVmDL21y9q5teYNPpRofn1F4AE3wJTmEpXKCPynHubptafAdgEVNEkbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706682666; c=relaxed/simple; bh=ukGaeKDWoBnc0AIrKBff3Y2VDwj+LfqCpXcFKMzADh0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=mZn2gzZ4lVBTsqZ9Y604z11BQZPVsvd5qhCv4dHza/9Si2RCp036Q5j4Ozaby66SfJ8deiOtfezeiUo3S9Uebqbg3DLziCE+OELzMQ4uftqV9AeLM083lfSCJ+sAJHX+hCtNeGOPwUZvh+LK2rPFp///cu3HcAQLVElhPswWJLU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=z+cNMApf; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dbf618042daso7310337276.0 for <linux-kernel@vger.kernel.org>; Tue, 30 Jan 2024 22:31:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706682663; x=1707287463; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=G1xH5pJjJI+heTB8iMmEvxa0X+0fNgErrr9gRIyth2g=; b=z+cNMApfdnCiyR2tpp+pXabq1/2OzeBTR65q/VwEAJztm54xYjWQHxqxraGkSQM28l b4NS1swQgiZkmLJKpEJGdDWE1q/2/zJ4Q1XLLF8Y08JPM3JO8AXgpwmcR+DMdwBvHL5C VkPEdvUD4sXHO2JYAwhqTwEBdDppZK28KRmGaat73fUa8HHHvk44I/v2hk+1AkdV91bg Lm3Bvhg2B3o4BQVSkvTpI8bxXXTSRGm8yXzQ6DSmjst6NJ9DP+M5yEwXyroRD9rnOHSE FYS5TiztIV+elSKP3Qije8UtHth6BqV/VoFV6zPbv48Xx0cccBtco3LtIco5JmLQtkAh nshw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706682663; x=1707287463; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=G1xH5pJjJI+heTB8iMmEvxa0X+0fNgErrr9gRIyth2g=; b=RPec7CX1+IOYCuulv46M5Gk46cf2Y4GgGh0xORyb1TaiXI5I6RfDIeFG1OnKhLQLTy bSdpdUtvDIszBzT/UlHdWr1+f+CM+zKiF1+WPHlieJOM2Y1tQJRCMaHQyQgrDH63wsua 53wzDyjf06mN4rmAsWF4N0oshgzNiVdBvvaeOu/dubwWCqI67QfhRee0EH8N+0qICemt 8UO5krIMKanB+fcW5YkAoTd8ErzLx6P59KA3Aq/5xVGpFwblnWCzjmz4LfIJnUWusDJz PIRHPAu9KLUqlf0EHGrh3enBm7nmhsw8mKQtiGmDWE1o2RTFxcFzUT9L4MC2a0LL5D4a BeBg== X-Gm-Message-State: AOJu0Ywxb91yu1n0Zgd96ZmN88XXpzKxQjMYw5erhKRjvVLHfKS7hMVW 50BISUmZ9Mc5ckfIgSpOdI1vyoUi0DVq2drNYGgq3kS7yJ5TzNsRhaT2CxUMqPXlfZLi0hSrPFc oP5aPSA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:d0ab:43c6:7969:62ab]) (user=irogers job=sendgmr) by 2002:a05:6902:1188:b0:dbe:d0a9:2be8 with SMTP id m8-20020a056902118800b00dbed0a92be8mr36777ybu.0.1706682663552; Tue, 30 Jan 2024 22:31:03 -0800 (PST) Date: Tue, 30 Jan 2024 22:30:47 -0800 In-Reply-To: <20240131063048.492010-1-irogers@google.com> Message-Id: <20240131063048.492010-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 References: <20240131063048.492010-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Subject: [PATCH v1 2/2] perf parse-events: Improve error location of terms cloned from an event From: Ian Rogers <irogers@google.com> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, Kan Liang <kan.liang@linux.intel.com>, James Clark <james.clark@arm.com>, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, tchen168@asu.edu, Michael Petlan <mpetlan@redhat.com> Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789587167580726124 X-GMAIL-MSGID: 1789587167580726124 |
Series |
[v1,1/2] perf tsc: Add missing newlines to debug statements
|
|
Commit Message
Ian Rogers
Jan. 31, 2024, 6:30 a.m. UTC
A PMU event/alias will have a set of format terms that replace it when
an event is parsed. The location of the terms is their position when
parsed for the event/alias either from sysfs or json. This location is
of little use when an event fails to parse as the error will be given
in terms of the location in the string of events parsed not the json
or sysfs string. Fix this by making the cloned terms location that of
the event/alias.
If a cloned term from an event/alias is invalid the bad format is hard
to determine from the error string. Add the name of the bad format
into the error string.
Signed-off-by: Ian Rogers <irogers@google.com>
---
These fixes were inspired by the poor error output in:
https://lore.kernel.org/linux-perf-users/alpine.LRH.2.20.2401300733310.11354@Diego/
---
tools/perf/util/pmu.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Comments
On 31/01/2024 06:30, Ian Rogers wrote: > A PMU event/alias will have a set of format terms that replace it when > an event is parsed. The location of the terms is their position when > parsed for the event/alias either from sysfs or json. This location is > of little use when an event fails to parse as the error will be given > in terms of the location in the string of events parsed not the json > or sysfs string. Fix this by making the cloned terms location that of > the event/alias. > > If a cloned term from an event/alias is invalid the bad format is hard > to determine from the error string. Add the name of the bad format > into the error string. > > Signed-off-by: Ian Rogers <irogers@google.com> > --- > These fixes were inspired by the poor error output in: > https://lore.kernel.org/linux-perf-users/alpine.LRH.2.20.2401300733310.11354@Diego/ > --- > tools/perf/util/pmu.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c > index 355f813f960d..437386dedd5c 100644 > --- a/tools/perf/util/pmu.c > +++ b/tools/perf/util/pmu.c > @@ -657,7 +657,7 @@ static int pmu_aliases_parse(struct perf_pmu *pmu) > return 0; > } > > -static int pmu_alias_terms(struct perf_pmu_alias *alias, struct list_head *terms) > +static int pmu_alias_terms(struct perf_pmu_alias *alias, int err_loc, struct list_head *terms) > { > struct parse_events_term *term, *cloned; > struct parse_events_terms clone_terms; > @@ -675,6 +675,7 @@ static int pmu_alias_terms(struct perf_pmu_alias *alias, struct list_head *terms > * which we don't want for implicit terms in aliases. > */ > cloned->weak = true; > + cloned->err_term = cloned->err_val = err_loc; > list_add_tail(&cloned->list, &clone_terms.terms); > } > list_splice_init(&clone_terms.terms, terms); > @@ -1363,8 +1364,8 @@ static int pmu_config_term(const struct perf_pmu *pmu, > > parse_events_error__handle(err, term->err_val, > asprintf(&err_str, > - "value too big for format, maximum is %llu", > - (unsigned long long)max_val) < 0 > + "value too big for format (%s), maximum is %llu", > + format->name, (unsigned long long)max_val) < 0 > ? strdup("value too big for format") > : err_str, > NULL); Hi Ian, I went to test this, but since b30d4f0b6954 ("perf parse-events: Additional error reporting") I don't get this size error message anymore, just a "bad event/PMU not found" type error. I'm not sure if this is something Arm specific, or you're seeing the same thing? Before b30d4f0b6954: $ perf record -e bus_access_rd/long=2 event syntax error: '..ss_rd/long=2/' \___ value too big for format, maximum is 1 Initial error: event syntax error: 'bus_access_rd/long=2/' \___ Cannot find PMU `bus_access_rd'. Missing kernel support? Run 'perf list' for a list of valid events Usage: perf record [<options>] [<command>] or: perf record [<options>] -- <command> [<options>] -e, --event <event> event selector. use 'perf list' to list available events After b30d4f0b6954: $ perf record -e bus_access_rd/long=2 event syntax error: '..ss_rd/long=2/' \___ Bad event or PMU Unabled to find PMU or event on a PMU of 'bus_access_rd' Initial error: event syntax error: 'bus_access_rd/long=2/' \___ Cannot find PMU `bus_access_rd'. Missing kernel support? Run 'perf list' for a list of valid events Usage: perf record [<options>] [<command>] or: perf record [<options>] -- <command> [<options>] -e, --event <event> event selector. use 'perf list' to list available events
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 355f813f960d..437386dedd5c 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -657,7 +657,7 @@ static int pmu_aliases_parse(struct perf_pmu *pmu) return 0; } -static int pmu_alias_terms(struct perf_pmu_alias *alias, struct list_head *terms) +static int pmu_alias_terms(struct perf_pmu_alias *alias, int err_loc, struct list_head *terms) { struct parse_events_term *term, *cloned; struct parse_events_terms clone_terms; @@ -675,6 +675,7 @@ static int pmu_alias_terms(struct perf_pmu_alias *alias, struct list_head *terms * which we don't want for implicit terms in aliases. */ cloned->weak = true; + cloned->err_term = cloned->err_val = err_loc; list_add_tail(&cloned->list, &clone_terms.terms); } list_splice_init(&clone_terms.terms, terms); @@ -1363,8 +1364,8 @@ static int pmu_config_term(const struct perf_pmu *pmu, parse_events_error__handle(err, term->err_val, asprintf(&err_str, - "value too big for format, maximum is %llu", - (unsigned long long)max_val) < 0 + "value too big for format (%s), maximum is %llu", + format->name, (unsigned long long)max_val) < 0 ? strdup("value too big for format") : err_str, NULL); @@ -1518,7 +1519,7 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct parse_events_terms *head_ alias = pmu_find_alias(pmu, term); if (!alias) continue; - ret = pmu_alias_terms(alias, &term->list); + ret = pmu_alias_terms(alias, term->err_term, &term->list); if (ret) { parse_events_error__handle(err, term->err_term, strdup("Failure to duplicate terms"),