Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp266027ybg; Tue, 28 Jul 2020 05:38:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOahtgY4ad8fCk/ramp4UtaicNIDihIsbBlOYg+gj9mRBji/wCsFGXvxR63UQU84sH8bMe X-Received: by 2002:a17:907:2489:: with SMTP id zg9mr24754917ejb.48.1595939894420; Tue, 28 Jul 2020 05:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595939894; cv=none; d=google.com; s=arc-20160816; b=JYoj3379YfmlSbJx5YcMwTZmpsKiNB1tCcKg9eTsj9ps5oN/Ph8pJOKWoF+woD9x99 zv3s+6LiHz/CwSg0ugEfdIv8eIq5y8trKDgr2XiiY9qSC6fimRXQkvx8GOHMYTSKvaeX Qx5p2AlgvMz3hEpsRKgMksKEOS/mTDd0db/rOxu5Xsh/7Ko4nF8DaFNTyaF32aKtKlqu 4OM3/TMvaxdLP8C6xktrgat2QeTLdKZrcBSuBMTNycruceE56uXkLfxnAkDPjulz/ipS F3Y82QmA62jaiTSEcvJG5TJORPZjyCgDIwY50elZK0GS4VRLtydVUXHYEPrPq+CCgvaG I8wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=tiXZ2MUk80ipZE2Gc5vBBO98VwxX8X6QSCLgKIaGAMg=; b=GoxiMhcNGsKRuzH+JOZAAIht9WrPgJ1j79RVQWjpL47SxFDh02bUonnBgtF7Pz1DHx Ne1p/wamQeuNJDiqf7UcivCAlQ/gS7OSdmGBg1i1HbR+3XHOC9JAYpy284w6+1AE3lCB MFBAYb4rcMOowKW0iTvi6cD+zgmt9BiceWHIfmzHXft1TKSlML9BglDS91yKO3TYjqNO szDeUA04jqZZoie42c13vDyCSn9yIA3wCIqCj5ouQA5i9X7AqCU6vuzjvwnwtcn4FT07 cZYCows+UIAzOa850DZFnqQUF7mFR8XYKFEucL/5mjiZsewgNP7CBFnOxQmo8Ith3tTm 4duw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Notg73rB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k27si7257877ejb.408.2020.07.28.05.37.52; Tue, 28 Jul 2020 05:38:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Notg73rB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729583AbgG1MhI (ORCPT + 99 others); Tue, 28 Jul 2020 08:37:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:52484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729334AbgG1MhH (ORCPT ); Tue, 28 Jul 2020 08:37:07 -0400 Received: from quaco.ghostprotocols.net (179.176.1.55.dynamic.adsl.gvt.net.br [179.176.1.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B197A20759; Tue, 28 Jul 2020 12:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595939827; bh=5TPhzH5vO99n2PNcTutP3rvbIJuX0RRXUhLLe7DOHI0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Notg73rBoii6IUqtxUD5qZwUqggHruDOBYmKXcC/on+ISeZOl7YtjJLOvfNtgqBmb QFq/wiK0T42FzhBP2CIfukU9KkVJCpKBfK87RiqpUpfdU4YQxVfb9bw7Tde/w8ZTN1 D6ElooFvYrnZOkusacU+tLoj9/q+8cFECYSb0Vd4= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 5B279404B1; Tue, 28 Jul 2020 09:37:04 -0300 (-03) Date: Tue, 28 Jul 2020 09:37:04 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Jiri Olsa , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Andi Kleen , Kajol Jain , John Garry , "Paul A. Clarke" , Stephane Eranian Subject: Re: [PATCH 17/19] perf metric: Add metric group test Message-ID: <20200728123704.GX40195@kernel.org> References: <20200719181320.785305-1-jolsa@kernel.org> <20200719181320.785305-18-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sun, Jul 19, 2020 at 03:41:14PM -0700, Ian Rogers escreveu: > On Sun, Jul 19, 2020 at 11:14 AM Jiri Olsa wrote: > > > > Adding test for metric group plus compute_metric_group > > function to get metrics values within the group. > > > > Signed-off-by: Jiri Olsa > > Acked-by: Ian Rogers Thanks, applied. - Arnaldo > Thanks, > Ian > > > --- > > tools/perf/tests/parse-metric.c | 48 +++++++++++++++++++++++++++++++-- > > 1 file changed, 46 insertions(+), 2 deletions(-) > > > > diff --git a/tools/perf/tests/parse-metric.c b/tools/perf/tests/parse-metric.c > > index 5ac32f80f8ea..f2ba5b2c5557 100644 > > --- a/tools/perf/tests/parse-metric.c > > +++ b/tools/perf/tests/parse-metric.c > > @@ -18,6 +18,7 @@ static struct pmu_event pme_test[] = { > > { > > .metric_expr = "inst_retired.any / cpu_clk_unhalted.thread", > > .metric_name = "IPC", > > + .metric_group = "group1", > > }, > > { > > .metric_expr = "idq_uops_not_delivered.core / (4 * (( ( cpu_clk_unhalted.thread / 2 ) * " > > @@ -35,6 +36,7 @@ static struct pmu_event pme_test[] = { > > { > > .metric_expr = "(dcache_miss_cpi + icache_miss_cycles)", > > .metric_name = "cache_miss_cycles", > > + .metric_group = "group1", > > }, > > { > > .metric_expr = "l2_rqsts.demand_data_rd_hit + l2_rqsts.pf_hit + l2_rqsts.rfo_hit", > > @@ -127,7 +129,9 @@ static double compute_single(struct rblist *metric_events, struct evlist *evlist > > return 0.; > > } > > > > -static int compute_metric(const char *name, struct value *vals, double *ratio) > > +static int __compute_metric(const char *name, struct value *vals, > > + const char *name1, double *ratio1, > > + const char *name2, double *ratio2) > > { > > struct rblist metric_events = { > > .nr_entries = 0, > > @@ -166,7 +170,10 @@ static int compute_metric(const char *name, struct value *vals, double *ratio) > > load_runtime_stat(&st, evlist, vals); > > > > /* And execute the metric */ > > - *ratio = compute_single(&metric_events, evlist, &st, name); > > + if (name1 && ratio1) > > + *ratio1 = compute_single(&metric_events, evlist, &st, name1); > > + if (name2 && ratio2) > > + *ratio2 = compute_single(&metric_events, evlist, &st, name2); > > > > /* ... clenup. */ > > metricgroup__rblist_exit(&metric_events); > > @@ -177,6 +184,18 @@ static int compute_metric(const char *name, struct value *vals, double *ratio) > > return 0; > > } > > > > +static int compute_metric(const char *name, struct value *vals, double *ratio) > > +{ > > + return __compute_metric(name, vals, name, ratio, NULL, NULL); > > +} > > + > > +static int compute_metric_group(const char *name, struct value *vals, > > + const char *name1, double *ratio1, > > + const char *name2, double *ratio2) > > +{ > > + return __compute_metric(name, vals, name1, ratio1, name2, ratio2); > > +} > > + > > static int test_ipc(void) > > { > > double ratio; > > @@ -297,6 +316,30 @@ static int test_recursion_fail(void) > > return 0; > > } > > > > +static int test_metric_group(void) > > +{ > > + double ratio1, ratio2; > > + struct value vals[] = { > > + { .event = "cpu_clk_unhalted.thread", .val = 200 }, > > + { .event = "l1d-loads-misses", .val = 300 }, > > + { .event = "l1i-loads-misses", .val = 200 }, > > + { .event = "inst_retired.any", .val = 400 }, > > + { 0 }, > > + }; > > + > > + TEST_ASSERT_VAL("failed to find recursion", > > + compute_metric_group("group1", vals, > > + "IPC", &ratio1, > > + "cache_miss_cycles", &ratio2) == 0); > > + > > + TEST_ASSERT_VAL("group IPC failed, wrong ratio", > > + ratio1 == 2.0); > > + > > + TEST_ASSERT_VAL("group cache_miss_cycles failed, wrong ratio", > > + ratio2 == 1.25); > > + return 0; > > +} > > + > > int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unused) > > { > > TEST_ASSERT_VAL("IPC failed", test_ipc() == 0); > > @@ -304,5 +347,6 @@ int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unu > > TEST_ASSERT_VAL("cache_miss_cycles failed", test_cache_miss_cycles() == 0); > > TEST_ASSERT_VAL("DCache_L2 failed", test_dcache_l2() == 0); > > TEST_ASSERT_VAL("recursion fail failed", test_recursion_fail() == 0); > > + TEST_ASSERT_VAL("test metric group", test_metric_group() == 0); > > return 0; > > } > > -- > > 2.25.4 > > -- - Arnaldo