Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2345833lqz; Tue, 2 Apr 2024 14:46:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUMyB5Xd+lJGHTFcVcTRhKsEV03CQHDkhWlfsSVclqPFcjGQMfh8lyopytPGP/BPJFB66UdaN2+15up4HeQhnBT7Ztn4OCxkN65VIFMBw== X-Google-Smtp-Source: AGHT+IHN/O26ePnmQKwLZF2c9dz/rC077flwmcPi1ObW4dsxd0m8QP9sYIr5R8/AW1UfFs1iwT6/ X-Received: by 2002:a05:6358:2489:b0:183:c2e4:a981 with SMTP id m9-20020a056358248900b00183c2e4a981mr7468593rwc.31.1712094409344; Tue, 02 Apr 2024 14:46:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712094409; cv=pass; d=google.com; s=arc-20160816; b=hk44CMCHbgcsVaQxgE507/OdJsQUPak+oTFpV3DWUOXjHr7cnEfV21enUU1gkBPBf9 JUvONWEy5E56Xi7sfG0HzEmgfZrBxQqM0WZgsweonBOveEw9tC7Nuw1YH/7E/qyJSToh u55sssunSG+xojTnFrHYSFA3g6QggiE0rtybgXr430qTjCA8dxMQDsYMWE2MdUUvRJsn w5l0yB6Mvwmga1cDx05yGEXh/wlXk+K0l1bTgPya1/p4aZ7HOUjxZhMXKo8yHmizhjKH mRZJlZTLDt0KTiMNysDVkWyfUzD/3i1hvk+32b8VYgRu4qgbfCW/Py1cm8/nS7c9LKk7 ZTFg== 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=YPYr09NluAzrciL8V+X197GsGxVZ2kyx0MfzUlR1GqY=; fh=7D8bWqELNqJM6KF7zbibUOya8038rGAdDMFXsJMRu8c=; b=1KfPnd7K/UuhvXj931ZfohaQqu7BwatQMFWzZiQvwXiRx8kEMRRBpGMoSUSpRCPnOE FDi0oHGuuPNqxlH7MU5rAdL6qcS0pom2ovlcnuF0N9ZOtk4A3Ofhgc/Yk9A557JkO+Ly 6fT4EgPJMePuQpVvApqb1ltnyzg6JpJf8L7pD/uhqgW7o1oPNGWQOHelk2cweVQHrcGF WV629X7KLNLRCE52kEUV1TBMvfVRtrl+nRLtfCxW31KiVEhwStkYFovI95yAypn6LXtm tZMsoS+JE51sGHpJsbXjz4I3GV+xVP5rHVppwy6Wt/4Xaa4N0z2K87RIgl0cVXR2mkHJ 6pXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="mhGe2/Bd"; 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-128747-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128747-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h20-20020a631214000000b005f3c8f1f441si2944936pgl.640.2024.04.02.14.46.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 14:46:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128747-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="mhGe2/Bd"; 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-128747-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128747-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E7267289494 for ; Tue, 2 Apr 2024 21:46:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E381415ECF2; Tue, 2 Apr 2024 21:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mhGe2/Bd" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 752F715E808; Tue, 2 Apr 2024 21:46:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712094376; cv=none; b=o8I6ri3210jzHFXzsM8Vdpmpth8hMNGRbX3j+isd0oi3dF7ALkvwtUJwG8H2ejWqcmVfA43wwE9HTkKpcPS97RC9EDWU1LhSBi051v+17WBS1TbOpOF3qK1AH1MquDnq+N9EdHBOyebJInst7KaS+73E+OP/JJMRYqzFfTqC3Is= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712094376; c=relaxed/simple; bh=gbaHPOtoi6t4Dnwpo4nW/r8IVCih6GDqcft3zBeCGJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WOzXhRht72ToNT8EeF7AniR3AGcHInrkllhGm7LORHFexHC3E4kqEjCwzooi8HqVZvmXLlTBE7tNv58GQnM1D7gBWBNX23eUNHkO6fF/lsKiKiGsvZKFfoMeeLApp//xxZ2VA3gdbJRa5RkiqR6H9TBymTkmq0gKt2ak8HVaS2o= 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=mhGe2/Bd; arc=none smtp.client-ip=192.198.163.9 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=1712094374; x=1743630374; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gbaHPOtoi6t4Dnwpo4nW/r8IVCih6GDqcft3zBeCGJM=; b=mhGe2/BdRi7+/n7HXumm7fuP82P5+9Dv29MxLE727RweIPFAfUBt8eVq HS5cQF4OS0lMTmPEdhVWr9BkO+TYnxnQr8/H+DBB8r7DED5n8H4YrJGK7 r/aLmhsZD60QFBvnUrDHzTr8eqOFXlIfB8PFsSbaRC11RBBbIsz3qCzaF RUbnuyhf+2axnlIaikJlvCZSRV3zrGlsnN6sPc9gfVEqDePD5Wt/Ud63J VO9J2kiGEdid3ezdMyahemFioNF2mlB2zcPsaPZs9zXicnyz7JKNY9QjY 6SYNGiUSb8ZUm6GUBLgFKltZQ57JkrpKKDpaRJHX8dq5HCDf1E5Y2KXyi w==; X-CSE-ConnectionGUID: E7BemyLjQEuTZjuh2obyhQ== X-CSE-MsgGUID: orVKMnzfSb+gxf0AO2If6w== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="18020026" X-IronPort-AV: E=Sophos;i="6.07,176,1708416000"; d="scan'208";a="18020026" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 14:45:05 -0700 X-CSE-ConnectionGUID: rLph5BO9R7SZiK4ni/tutw== X-CSE-MsgGUID: TVBfzDEITvCO8NU0JsnqMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,176,1708416000"; d="scan'208";a="22849091" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa004.fm.intel.com with ESMTP; 02 Apr 2024 14:45:04 -0700 From: weilin.wang@intel.com To: weilin.wang@intel.com, Namhyung Kim , Ian Rogers , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , 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 v7 5/6] perf stat: Add retire latency print functions to print out at the very end of print out Date: Tue, 2 Apr 2024 17:44:35 -0400 Message-ID: <20240402214436.1409476-6-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240402214436.1409476-1-weilin.wang@intel.com> References: <20240402214436.1409476-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. Example output: Performance counter stats for 'system wide': 25,717 MEM_INST_RETIRED.SPLIT_STORES # 2.2 % tma_split_stores 28,365,080 CPU_CLK_UNHALTED.THREAD 24.00 MEM_INST_RETIRED.SPLIT_STORES:p # 96 4 2.054365083 seconds time elapsed This output of retire latency data is in format: # . Signed-off-by: Weilin Wang Reviewed-by: Ian Rogers --- tools/perf/util/stat-display.c | 69 ++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index bfc1d705f437..c32d484b53a9 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,71 @@ 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, event.nd) { + if (newline) + do_new_line_std(config, os); + fprintf(out, "%'*.2f ", COUNTS_LEN, t->val); + /* For print alignment */ + fprintf(out, "%-*s ", config->unit_width, ""); + fprintf(out, "%-*s", EVNAME_LEN, t->event.name); + fprintf(out, " # "); + fprintf(out, "%*d %*ld\n", RETIRE_LEN, t->sum, + RETIRE_LEN, t->count); + } +} + +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, event.nd) { + fprintf(out, "%f%s%s%s%s%ld%s%d\n", t->val, sep, sep, t->event.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, event.nd) { + fprintf(out, "\"retire_latency-value\" : \"%f\", ", t->val); + fprintf(out, "\"event-name\" : \"%s\"", t->event.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 +1676,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