linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Andi Kleen <ak@linux.intel.com>,
	John Garry <john.garry@huawei.com>,
	Zhengjun Xing <zhengjun.xing@linux.intel.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH] perf metrics: Ensure at least 1 id per metric
Date: Sun, 19 Jun 2022 11:24:41 -0300	[thread overview]
Message-ID: <Yq8xqdUnAv428foN@kernel.org> (raw)
In-Reply-To: <20220618013957.999321-1-irogers@google.com>

Em Fri, Jun 17, 2022 at 06:39:57PM -0700, Ian Rogers escreveu:
> We may have no events for a metric evaluated to a constant. In such a
> case ensure a tool event is at least evaluated for metric parsing and
> displaying.

Thanks, applied.

- Arnaldo

 
> Fixes: 8586d2744ff3 ("perf metrics: Don't add all tool events for sharing")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/util/metricgroup.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index ee8fcfa115e5..8f7baeabc5cf 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -1372,6 +1372,7 @@ static int parse_ids(bool metric_no_merge, struct perf_pmu *fake_pmu,
>  
>  	*out_evlist = NULL;
>  	if (!metric_no_merge || hashmap__size(ids->ids) == 0) {
> +		bool added_event = false;
>  		int i;
>  		/*
>  		 * We may fail to share events between metrics because a tool
> @@ -1393,8 +1394,16 @@ static int parse_ids(bool metric_no_merge, struct perf_pmu *fake_pmu,
>  				if (!tmp)
>  					return -ENOMEM;
>  				ids__insert(ids->ids, tmp);
> +				added_event = true;
>  			}
>  		}
> +		if (!added_event && hashmap__size(ids->ids) == 0) {
> +			char *tmp = strdup("duration_time");
> +
> +			if (!tmp)
> +				return -ENOMEM;
> +			ids__insert(ids->ids, tmp);
> +		}
>  	}
>  	ret = metricgroup__build_event_string(&events, ids, modifier,
>  					      has_constraint);
> -- 
> 2.37.0.rc0.104.g0611611a94-goog

-- 

- Arnaldo

      reply	other threads:[~2022-06-19 14:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-18  1:39 [PATCH] perf metrics: Ensure at least 1 id per metric Ian Rogers
2022-06-19 14:24 ` Arnaldo Carvalho de Melo [this message]

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=Yq8xqdUnAv428foN@kernel.org \
    --to=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=john.garry@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=zhengjun.xing@linux.intel.com \
    /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).