Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp839698ybt; Fri, 26 Jun 2020 12:50:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywESwc2U5LZjHo3De5gRrgn3ArSO6sWa4D7RlNV5xZcC48DK560wvdYRD1mnsOPZ7VUhsY X-Received: by 2002:aa7:dd10:: with SMTP id i16mr2423310edv.227.1593201011648; Fri, 26 Jun 2020 12:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593201011; cv=none; d=google.com; s=arc-20160816; b=EDwf5dJbJTzDyImNOvdI/Ojc7BV3tZu/U+dxtjV1O3pBO5mludDTp1L4FYzlb2B+Cd +jakCytCiWXVzDjNl8FApctAvpElf5Le0rCsrII0iEACH9v6J9JcZsO+CyLrTaSxvtrQ h956Vs6Q0uAejqWOBDREjWbw6pieczASt+ephNZkQHN/vTNPBzzn5zEJW768tG7O+lXM soybaOs7PxjNRkvCr6eG1F0sLp/WM3jq4rq9QLLYjY80bob6tHTycnr46R3ie/txe/xf ixGzXKamNJc4pPrvfjJ8TuHAXnzQMjSLloB78Mk/sxxZujM8vjzBEM97BwjlVDiM/U6A hGiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ii0++glJA/JfE6XC7OlAIuZ4PnzNMCb4VDpk4WQyZ3E=; b=KIusbKQ8syqjh2JFm8TRayqUfJRoDHNfXr0n25k0FYQ6QZyJwjxh56ZHRiyaYCED/L ko4icEn+1BBsPOfgRpzaU8WCIx99Q/KzQKqgVhtGBtrjv0WCC5QBi1dEMFmYva/OXXB1 /gkhIb7jCz1Cc5Sl9SHU3rTrXHtwvHkFnDs19wiS6QE+0n+gWjaI51fSBNhHz9ZFNyQ3 18OTiCiyufajSbBkvb8Le13K2loT2HPh4onvMCaqanLspR43W1TseDMI/JA5DjMUWuTk U/YgSlLVbSssKUM51s41f+RlquxvYKSGp28WTD7ITILTCO3iz/Vvfpo8Gumn2/gPAXfS 6Ptw== ARC-Authentication-Results: i=1; mx.google.com; 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 ga5si5579512ejb.567.2020.06.26.12.49.48; Fri, 26 Jun 2020 12:50:11 -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; 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 S1726070AbgFZTsN convert rfc822-to-8bit (ORCPT + 99 others); Fri, 26 Jun 2020 15:48:13 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:56416 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726008AbgFZTsK (ORCPT ); Fri, 26 Jun 2020 15:48:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-p4_fu2RmP5uNjgUmfC5CxQ-1; Fri, 26 Jun 2020 15:48:03 -0400 X-MC-Unique: p4_fu2RmP5uNjgUmfC5CxQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB836107ACF2; Fri, 26 Jun 2020 19:48:01 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.193.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 143F35BAD2; Fri, 26 Jun 2020 19:47:58 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Andi Kleen , Kajol Jain , John Garry , "Paul A. Clarke" , Stephane Eranian , Ian Rogers Subject: [PATCH 10/10] perf tests: Add cache_miss_cycles to metric parse test Date: Fri, 26 Jun 2020 21:47:20 +0200 Message-Id: <20200626194720.2915044-11-jolsa@kernel.org> In-Reply-To: <20200626194720.2915044-1-jolsa@kernel.org> References: <20200626194720.2915044-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding test that compute metric with other metrics in it. cache_miss_cycles = metric:dcache_miss_cpi + metric:icache_miss_cycles Signed-off-by: Jiri Olsa --- tools/perf/tests/parse-metric.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/perf/tests/parse-metric.c b/tools/perf/tests/parse-metric.c index 8c48251425e1..feb97f7c90c8 100644 --- a/tools/perf/tests/parse-metric.c +++ b/tools/perf/tests/parse-metric.c @@ -11,6 +11,8 @@ #include "debug.h" #include "expr.h" #include "stat.h" +#include +#include static struct pmu_event pme_test[] = { { @@ -22,6 +24,18 @@ static struct pmu_event pme_test[] = { "( 1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk ) )))", .metric_name = "Frontend_Bound_SMT", }, +{ + .metric_expr = "l1d\\-loads\\-misses / inst_retired.any", + .metric_name = "dcache_miss_cpi", +}, +{ + .metric_expr = "l1i\\-loads\\-misses / inst_retired.any", + .metric_name = "icache_miss_cycles", +}, +{ + .metric_expr = "(metric:dcache_miss_cpi + metric:icache_miss_cycles)", + .metric_name = "cache_miss_cycles", +}, }; static struct pmu_events_map map = { @@ -162,9 +176,28 @@ static int test_frontend(void) return 0; } +static int test_cache_miss_cycles(void) +{ + double ratio; + struct value vals[] = { + { .event = "l1d-loads-misses", .val = 300 }, + { .event = "l1i-loads-misses", .val = 200 }, + { .event = "inst_retired.any", .val = 400 }, + { 0 }, + }; + + TEST_ASSERT_VAL("failed to compute metric", + compute_metric("cache_miss_cycles", vals, &ratio) == 0); + + TEST_ASSERT_VAL("cache_miss_cycles failed, wrong ratio", + ratio == 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); TEST_ASSERT_VAL("frontend failed", test_frontend() == 0); + TEST_ASSERT_VAL("cache_miss_cycles failed", test_cache_miss_cycles() == 0); return 0; } -- 2.25.4