From nobody Tue Feb 10 06:04:58 2026 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 48780137928; Fri, 29 Mar 2024 19:12:51 +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=1711739573; cv=none; b=lbmDiA5fG3mq8sWVFJdoYpkpF4tGRljWxStjDMwD3BnjiEv4TvpstunN5m0LgF+hEC8PeQrI4ilrjudyuJU4GV7MN7QASivClGMF0ll497b7u4dpkc0KfR40wg14lvN6jKOWJczdt670BwlwIdPnV3UCtAe5l152egYUCmtk6TE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711739573; c=relaxed/simple; bh=J9fUAQZWkixjtehQmnGr1yigtsctKtXiiA3rek8znyk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dNachbhVhqG+wfK/EJBGIAXC3DKWpr5Z4F2o+7Iix4gGHdUSvgfmWN4v07daEyaXv6oj+Tg3NZeHf3GY0aaaH8ndNojeBTRR/bkXKUCHCaxYJKUOm1oWuZBLd5k2U29/EhmyaXajo6YTHVFuvQxd0+Vt0qQkiA+uAzgNf7J8WMQ= 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=ICirVCke; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ICirVCke" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711739571; x=1743275571; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J9fUAQZWkixjtehQmnGr1yigtsctKtXiiA3rek8znyk=; b=ICirVCkerIR0Bv5c1P0bixoJTuEBek9r6PYNsJGZtH+jMksZH4l/7Dw2 uh7QMkNfastdbzsbEruTHQe81XMNiXHmo4c/up1wBN8hcKvwiEQjGCi7n jtqvWhZNX5tpotQ9uozQXDpKdXGsoIx3k6FzuW0Q+AwB3Lc2/MpQNkwYX pMreffM45X7JNXDUsDPahwHEAJspBhMf4J/IdJxSIsVvDW1uj7t+Fa2d2 Dc44J9W8qddxrplZvnYSLHj7OR4Ng2Z5PHJNcnX4kXaGn0MeuNH1YXHwq iFECFos/ip+q387XToaURWA9tmhPOTdvnzv61kTAR2NquKoTJUO77wsHt A==; X-CSE-ConnectionGUID: D4cJGdG5QbmUKKrjGc1/jA== X-CSE-MsgGUID: OEmQoRIxTletT2avIY3O0w== X-IronPort-AV: E=McAfee;i="6600,9927,11028"; a="7531732" X-IronPort-AV: E=Sophos;i="6.07,165,1708416000"; d="scan'208";a="7531732" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2024 12:12:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,165,1708416000"; d="scan'208";a="54506862" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by orviesa001.jf.intel.com with ESMTP; 29 Mar 2024 12:12:46 -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 v6 4/5] perf stat: Add retire latency print functions to print out at the very end of print out Date: Fri, 29 Mar 2024 15:12:23 -0400 Message-ID: <20240329191224.1046866-5-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329191224.1046866-1-weilin.wang@intel.com> References: <20240329191224.1046866-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Weilin Wang Add print out functions so that users could read retire latency values. Example output: In this simple example, there is no MEM_INST_RETIRED.STLB_HIT_STORES sample. Therefore, the MEM_INST_RETIRED.STLB_HIT_STORES:p retire_latency value, cou= nt and sum are all 0. Performance counter stats for 'system wide': 181,047,168 cpu_core/TOPDOWN.SLOTS/ # 0.6 % tma_= dtlb_store 3,195,608 cpu_core/topdown-retiring/ 40,156,649 cpu_core/topdown-mem-bound/ 3,550,925 cpu_core/topdown-bad-spec/ 117,571,818 cpu_core/topdown-fe-bound/ 57,118,087 cpu_core/topdown-be-bound/ 69,179 cpu_core/EXE_ACTIVITY.BOUND_ON_STORES/ 4,582 cpu_core/MEM_INST_RETIRED.STLB_HIT_STORES/ 30,183,104 cpu_core/CPU_CLK_UNHALTED.DISTRIBUTED/ 30,556,790 cpu_core/CPU_CLK_UNHALTED.THREAD/ 168,486 cpu_core/DTLB_STORE_MISSES.WALK_ACTIVE/ 0.00 MEM_INST_RETIRED.STLB_HIT_STORES:p 0 0 1.003105924 seconds time elapsed Signed-off-by: Weilin Wang Reviewed-by: Ian Rogers --- 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..6c043d9c9f81 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" =20 #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 =20 static int aggr_header_lens[] =3D { [AGGR_CORE] =3D 18, @@ -426,6 +428,67 @@ static void print_metric_std(struct perf_stat_config *= config, fprintf(out, " %-*s", METRIC_LEN - n - 1, unit); } =20 +static void print_retire_lat_std(struct perf_stat_config *config, + struct outstate *os) +{ + FILE *out =3D os->fh; + bool newline =3D os->newline; + struct tpebs_retire_lat *t; + struct list_head *retire_lats =3D &config->tpebs_results; + + list_for_each_entry(t, retire_lats, event.nd) { + if (newline) + do_new_line_std(config, os); + fprintf(out, "%'*.2f %-*s", COUNTS_LEN, t->val, EVNAME_LEN, t->event.nam= e); + 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 =3D os->fh; + struct tpebs_retire_lat *t; + struct list_head *retire_lats =3D &config->tpebs_results; + const char *sep =3D 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 =3D os->fh; + struct tpebs_retire_lat *t; + struct list_head *retire_lats =3D &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 =3D ctx; @@ -1609,6 +1672,8 @@ void evlist__print_counters(struct evlist *evlist, st= ruct perf_stat_config *conf break; } =20 + print_retire_lat(config, &os); + print_footer(config); =20 fflush(config->output); --=20 2.43.0