Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp622634lqg; Fri, 1 Mar 2024 16:12:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV5LJpWPlm1ZA87PyVmWhs2a9qJhAF2oRTKHj1BveCwu9VKzC2eq35N4z80Zo7GDMZHYTKCNOObkSTpfym7FQv8UZL1d/ZPmjU8+C3kDQ== X-Google-Smtp-Source: AGHT+IHnFZX19pzjUFZUyUrXd96AIiJRZ57LrT2QRONucNOzIHbeSi/56s4XNKQwtNX62EPOXTBC X-Received: by 2002:a05:6359:420c:b0:17b:8706:fd39 with SMTP id kn12-20020a056359420c00b0017b8706fd39mr3818745rwb.10.1709338361948; Fri, 01 Mar 2024 16:12:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709338361; cv=pass; d=google.com; s=arc-20160816; b=pKY//FnbA6unfTHSvLEsdD2+gxMYQGJbDzwRyxmogE/nCRJphnwACdDM1ZFX1Y2Jnm IcN1s5/xXr8WFpPr90IbxDIDCSy86RzfyIk2V0LtRgqLhhLVqKSa44XrmxugZfoSqw3L q9j1uew036sGiPVHQ59gsTFVZoxXhES4n3h/yk9JNQ1O2YyQ9it/iwl8Ysycsrr03x0f aDH7oTP5b/wEP3sO6FLEBTLr0r4iPSSuwwv7jzKKDMrECbSIfNQe2IeqxVVb8d2WNgWH piJdaLeSr/8INbAAIxKT989HWrqFUPwYndFAOkPCPiqBeBiAuKJ9QkXSkUmjprkzZCG/ GVBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=C0dPVSA3BFAWZ9/NlpbugwUPBCtkLnDPiyZQTGQMTI0=; fh=D8N1uhCLBRzbbRgEj9aMJ2/kVuNqnMf8W9VxSJOfqPA=; b=ja40Ppd2pbvz6+7aerIRzv2A4pmpldXSpYnkfczLzOJtuwF0gapPklssrBp6kteC5p rY1IFFYVgTP0iWobS4GyZ2BF0mru1K3HJz0UJTxURsF8RYoMqDCDK/Az8+DaBrJuNo1u Ao/LxaRDX7jnouy/GhgZD+qIk/dBqZZPv5Yg6AhXLTIqReQDoVQLTP1d00aLDSw0qdK5 JX1fkQhSwrjwmePxjs21r/ASy+pZP8p5Kp/GdJAmoInsNzjH1ajwNxiF8Ahc24RIEwlQ 0Z45NoNZZjCIl6YQp4Sg6V7q4kMLCFWvODVEwyx5Ad4kcTngbFPpRw/j8FBujGHpb9XW GqRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dq7AEa3g; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-89254-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89254-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ks15-20020a056214310f00b00686a0c905e1si4535104qvb.463.2024.03.01.16.12.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 16:12:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89254-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dq7AEa3g; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-89254-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89254-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A965E1C21CF2 for ; Sat, 2 Mar 2024 00:12:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C9E5F4E7; Sat, 2 Mar 2024 00:11:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dq7AEa3g" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B32FE1842; Sat, 2 Mar 2024 00:11:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338313; cv=none; b=h64jz/woae8Pkx6JgnxBnE6qXglKoR6swMGaxR/+QogMxX2NebvqHRw2cpd5JnhUA2J2lZhNqF97mXTV4DNimZ6i2Aej/OoXKHBMatgDhmW4kIS4yHeVX7HKPzDaVvd0RJeR0H4yA3X9tUFylNynuOjrzKmJhohMaEwnDmfwAdo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709338313; c=relaxed/simple; bh=SQctvRJ39Y6FTztBS6nvv5clzEQieh9m50qo+ZNGlrY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dVn18tRGAymUdI8szpxQQowKT+wLxnn1AUUdxgLk0OyydtuKj9wM5PG29Y2FZcoiYoLjCDDWi8k1k88euIQF9JtNl/8LHbPBvoI97yZs4w+In6nOpwU6iOzTwoliPS3cdJPXa872OLtE85cmboMFAFK2r1AECzGjwTA8lgI1n+E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dq7AEa3g; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709338311; x=1740874311; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SQctvRJ39Y6FTztBS6nvv5clzEQieh9m50qo+ZNGlrY=; b=dq7AEa3gfmvutYSsp45miotp0eyZQkAxT0gDcO0FqHKMbptJ/aq5MrCc VHMBVxTYkNJjrgl+Cf5/8LJkm1MScH4SaOdQeB1wCiuZC08LpaIHh8iuD fAw0M37p3gYtGzOagebDGlzVP69bfPR/qcnesEK9oJ9WZ7QIGPqapVLCr zr/EzNAeod42uygid0hqdef3SFc0nhpOnm/PUVH4vL1FZQz29sCAmlxa4 imieaW86HCGvWExuy9O5pk7mOaWNZflp47OUlUvMDdshB6+jONcPmWYe3 xk2t3Wonvy6BgSskW8TK8mCb0hiReSDi3fGZCiAPBn9uswt6vlWzkgsZK w==; X-IronPort-AV: E=McAfee;i="6600,9927,11000"; a="4476158" X-IronPort-AV: E=Sophos;i="6.06,197,1705392000"; d="scan'208";a="4476158" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 16:11:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,197,1705392000"; d="scan'208";a="13054650" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by orviesa005.jf.intel.com with ESMTP; 01 Mar 2024 16:11:46 -0800 From: weilin.wang@intel.com To: weilin.wang@intel.com, Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers Subject: [RFC PATCH v3 5/6] perf stat: Add retire latency print functions to print out at the very end of print out Date: Fri, 1 Mar 2024 19:11:37 -0500 Message-ID: <20240302001139.604829-6-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240302001139.604829-1-weilin.wang@intel.com> References: <20240302001139.604829-1-weilin.wang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Weilin Wang Add print out functions so that users could read retire latency values. Signed-off-by: Weilin Wang --- tools/perf/util/stat-display.c | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index bfc1d705f437..e2996ba67bfe 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -21,6 +21,7 @@ #include "iostat.h" #include "pmu.h" #include "pmus.h" +#include "metricgroup.h" #define CNTR_NOT_SUPPORTED "" #define CNTR_NOT_COUNTED "" @@ -34,6 +35,7 @@ #define COMM_LEN 16 #define PID_LEN 7 #define CPUS_LEN 4 +#define RETIRE_LEN 8 static int aggr_header_lens[] = { [AGGR_CORE] = 18, @@ -426,6 +428,67 @@ static void print_metric_std(struct perf_stat_config *config, fprintf(out, " %-*s", METRIC_LEN - n - 1, unit); } +static void print_retire_lat_std(struct perf_stat_config *config, + struct outstate *os) +{ + FILE *out = os->fh; + bool newline = os->newline; + struct tpebs_retire_lat *t; + struct list_head *retire_lats = &config->tpebs_results; + + list_for_each_entry(t, retire_lats, nd) { + if (newline) + do_new_line_std(config, os); + fprintf(out, "%'*.2f %-*s", COUNTS_LEN, t->val, EVNAME_LEN, t->name); + fprintf(out, "%*ld %*d\n", RETIRE_LEN, t->count, + RETIRE_LEN, t->sum); + } +} + +static void print_retire_lat_csv(struct perf_stat_config *config, + struct outstate *os) +{ + FILE *out = os->fh; + struct tpebs_retire_lat *t; + struct list_head *retire_lats = &config->tpebs_results; + const char *sep = config->csv_sep; + + list_for_each_entry(t, retire_lats, nd) { + fprintf(out, "%f%s%s%s%s%ld%s%d\n", t->val, sep, sep, t->name, sep, + t->count, sep, t->sum); + } +} + +static void print_retire_lat_json(struct perf_stat_config *config, + struct outstate *os) +{ + FILE *out = os->fh; + struct tpebs_retire_lat *t; + struct list_head *retire_lats = &config->tpebs_results; + + fprintf(out, "{"); + list_for_each_entry(t, retire_lats, nd) { + fprintf(out, "\"retire_latency-value\" : \"%f\", ", t->val); + fprintf(out, "\"event-name\" : \"%s\"", t->name); + fprintf(out, "\"sample-counts\" : \"%ld\"", t->count); + fprintf(out, "\"retire_latency-sum\" : \"%d\"", t->sum); + } + fprintf(out, "}"); +} + +static void print_retire_lat(struct perf_stat_config *config, + struct outstate *os) +{ + if (!&config->tpebs_results) + return; + if (config->json_output) + print_retire_lat_json(config, os); + else if (config->csv_output) + print_retire_lat_csv(config, os); + else + print_retire_lat_std(config, os); +} + static void new_line_csv(struct perf_stat_config *config, void *ctx) { struct outstate *os = ctx; @@ -1609,6 +1672,8 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *conf break; } + print_retire_lat(config, &os); + print_footer(config); fflush(config->output); -- 2.43.0