Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1401274lql; Tue, 12 Mar 2024 16:50:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVPbOEJJXJD/RxmdU5Ase67pT6k4Phe0nxIRa6D4i3EkxB3VJjjkLKXlEvdDj676tI8mYDDsznA0y5gQgBFBqMWbt/XIOlXoG+Lbkn2xw== X-Google-Smtp-Source: AGHT+IGKk2MRCvtki9I03woBzB2qVf3EzzpVST/53F28oqMwWHV0O6ZukmJXMCAfLKso610rY/Jx X-Received: by 2002:a05:6512:67:b0:513:3d26:7cc6 with SMTP id i7-20020a056512006700b005133d267cc6mr5714268lfo.15.1710287431793; Tue, 12 Mar 2024 16:50:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710287431; cv=pass; d=google.com; s=arc-20160816; b=bWArb/75V7YGLW5OKmQvdD+rEAOrZubJ4RZR0kNfmlYLMu0nW9UTOGitPxXAqNrvZk ff7NI5+mh1cmUSJ+O5AlxSyAjzoM42kVG0HJLOQjtKzCfbbhQYnXwCK6TytIoDk3IsjR zHlEvGXhOeY/iBaodCl5tbLcC7PrGihJ125GBx9rNUd84v8WZ+VjCtGLrazScLv1PowM t9KoFWB6qXSnhjiSBiUn8qHmsjizjwURa+sSqj3b90xyonKEsVVhSsJEr/frazgAoo4q ZL9g+9QNl3J4g0ArPYniMomNnywL5uoExfjG3WpGpSpGcA9XxKMreWJs4Jcl7Y45Lmb5 k/LQ== 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=r9pj1tqz2jt8SX286bujLJ7c9ezNvrxOXNbBmP1b4vo=; fh=7D8bWqELNqJM6KF7zbibUOya8038rGAdDMFXsJMRu8c=; b=Kp6TVy0kAvJN4QfoJdTVy9mNmxG3Xd6TMUydc4rjmrGbmFFkKibCm/+Id5ac+htI83 zgRllhRruhNYIxYgFLaVbxSwPz5LQEK/XUYAvSXsXHUwugqI500fDeY0BvqEy6HZp8Fr cItGo6eb7xxhAjNetI63DjhTXxLypNeyKOm5fXfR/s6eof/hW99QYpM197F9kZYJwecT 8bo8p3SwZY/DYB29pWXNxbhbvnp41a1/EN91A8dDQLtElHoubS0IM9IqXgFgJYMoj/cP 8rgjSd/1+LBWogerUQJeK9mGQhuOU8vD53K2QAtTHpkK5RFAkK1FnqLxHKFiTcGtprbf qe3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XiGLdyfm; 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-100935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100935-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id sh35-20020a1709076ea300b00a46441bb584si1103204ejc.953.2024.03.12.16.50.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 16:50:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XiGLdyfm; 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-100935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100935-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3E1791F2273D for ; Tue, 12 Mar 2024 23:50:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17AFC548E4; Tue, 12 Mar 2024 23:49:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XiGLdyfm" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 9883B4E1CE; Tue, 12 Mar 2024 23:49:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710287379; cv=none; b=qpeeBkIO/vqkkp1xTGI/wu5ma3bmEkhFB3H6zJL2a9Jxgp9mR8fzR0arSdNxcV5hjv7eHOQn8A/Iyi/IYFlopfCsr7u9kK2RG4m70j61zCgM+rZodKI9bqv2YC+PBeeY9mO6IdVunQP7p0xv2nU5Q4qI1jsfPO8u25rmHtUSNME= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710287379; c=relaxed/simple; bh=0d/u/no/x+wp+SNvaH+utaXdMsho7RPuqxHeLb+ykRk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ArB2fw/R00pS2Atlf8hkuqjNtll1ZZjFp38p4OBzmj9EG2MJyAIbTkZd2esIkQTWbJvvSGeW33AjA6fPjzV4yla3A1bLVAQ5XhqD/m/Fw8Reb0AQaWV/uHQikYGu0ZCx+2uduT9/BvDMwIDlIsrXKT7ZaHNcW4Y+wZxR/D12E2A= 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=XiGLdyfm; arc=none smtp.client-ip=198.175.65.14 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=1710287378; x=1741823378; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0d/u/no/x+wp+SNvaH+utaXdMsho7RPuqxHeLb+ykRk=; b=XiGLdyfm7DFxSJCzpX6/Bn8tt1BS7tenIPFo29LTk1RSzJnt4PEDU0aK r9HDzb6QE5dJHB/iHpn18WuOJ7jnlAMSyVe6KhbET+/mUlDsjY8mO+tNa s1VcCVAWruElaLYQOTDv49ZKNtl2tf/IoIU3FFyEkro9/g5daRdDIvQCc 2Qp4F9i1cJM1oOG+wVs4BN5UmbZKBioalNF6i6cWwXVitQPtoSJ66F3+6 UdfXCDTy6fTRpiI8CsZ6qHsviJ/sc1JBYsbxZpwt2BnxJYjw5m2AEw//B N62pVqgoP0un8/yKnmBZY29/F877xUgy8Q3x0Q22rlq086wWm/G5KBpAc A==; X-IronPort-AV: E=McAfee;i="6600,9927,11011"; a="8847709" X-IronPort-AV: E=Sophos;i="6.07,119,1708416000"; d="scan'208";a="8847709" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2024 16:49:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,119,1708416000"; d="scan'208";a="42715692" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa001.fm.intel.com with ESMTP; 12 Mar 2024 16:49:35 -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 v4 5/6] perf stat: Add retire latency print functions to print out at the very end of print out Date: Tue, 12 Mar 2024 19:49:20 -0400 Message-ID: <20240312234921.812685-6-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240312234921.812685-1-weilin.wang@intel.com> References: <20240312234921.812685-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: 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, count 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 --- 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