Received: by 2002:ab2:f03:0:b0:1ef:ffd0:ce49 with SMTP id i3csp39033lqf; Tue, 26 Mar 2024 13:36:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVmmL69nPnOOWLhdSNhyvSbYiDHVfLz6yyB4NUqSWO890RzlGrb/pOh1W+Fepd5y1dHA2f2Id+XggFskW5BuT0DVXGCcdms/Af5D02EYw== X-Google-Smtp-Source: AGHT+IFazdeUJLd0UEYi58cwsl8f0GS4ekqvaqmxUNiw+Avzbesh8sxFXojfArBxsfqtTkswGF92 X-Received: by 2002:a17:90a:d150:b0:29f:b8c9:2745 with SMTP id t16-20020a17090ad15000b0029fb8c92745mr3097617pjw.24.1711485383591; Tue, 26 Mar 2024 13:36:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711485383; cv=pass; d=google.com; s=arc-20160816; b=m4vdhBgmEUkaA+Cmd+j0MkhO5Fj8Dhp/iph/Li1z79uj9+LG2bQFP47T5X67svjI+7 aUj6gIZ7nS0yjMK2m6wbDdBQilzNEv8v1L4uB+dZbQKfHf+Ui4TPsFxjwUOD9qtbaHWi mKKGLTeUDhIoGHMDO2q2B6t7Z3ghB5qKjww+WzK4+f/YvF7AljjDcBhdbrTgT6ITofZH WFxBdsFY40v+2Otfe3wdbyOeQarq6Q/h6juirBRoGTFMVohvh8+wcNlc0ccwL1QT6bdE ChhSCTPp5uoLokSVlXxw86IhKJbo/tVPa/qI11vBm7/0qHHyo4tyLizFn62QgWXTuA7h lAEw== 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=FmrijDMa0XANOa7h8vxzxBGNtlGvkiYn9smYvLIpghs=; fh=7D8bWqELNqJM6KF7zbibUOya8038rGAdDMFXsJMRu8c=; b=ZciIbBuSTAElKARDsQFyK/o3MrH8hNCToEReWkoCy5nU1lV+wbuHI36BMrTZZvR2I/ FVEATW5YuDdpg2pvRgZaFoj2vQgrUPK4ct5czTxFq0jvclhGEUPWvL21K3ylUXJ/9KQD ZkN3Rn4s0CPQ04hxDiLV3mm08hbFgCDlkJSMv7DA4xjm4ff2X0TI8yJqK0YHtSFmA5D3 RQT28qh1Mfg7JVoe+JaGMZ0DOi4UzEWfJMrPmy1CplLDiuTrIbkPW7HNlTKIAedVB1Pi 6TgIsVzR5GQ5o2m6QoNNXXZGfhJOaux/ewgvFKcxFOGSLM/YgQNQsBEY0jiebmSn7jNT YWFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ONRqMkeO; 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-119921-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119921-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 i11-20020a17090a650b00b0029c798bd1f4si23773pjj.1.2024.03.26.13.36.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 13:36:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119921-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=ONRqMkeO; 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-119921-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119921-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 501E8340E0A for ; Tue, 26 Mar 2024 20:36:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8255C13FD6E; Tue, 26 Mar 2024 20:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ONRqMkeO" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 C94B213E8BE; Tue, 26 Mar 2024 20:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711484978; cv=none; b=UznJ4XgHZU1rozfIuACSj9oYzNsP/hIvEEOUfcX/JxKey3+pnq6nCzd/7BnfRT52+TEHQWquhRXeb/3iNdXoSx3F46TW4R2Wqp+cpQPSrpW+bLdDkNvi28fs79vhxzea3qIcvotjiaOGy45KPxahXdv0beZf02jd1gxkz3VEkvc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711484978; c=relaxed/simple; bh=J9fUAQZWkixjtehQmnGr1yigtsctKtXiiA3rek8znyk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ny+9etq4KPa2+cEl5vefAj03aeK/in3X2Emjntxp3zdPrR+PUIC9xhfpXvW69mF8vPsZ5+lyRPiJenbyB+HJPeDvuR9VtNY097kp1z56cpp5RWDvgHFVV3lzrRyfKOe4/lxn8CZhoW5kpM+XRRrI/Mlkdyk46Pli+r++a5nhmh0= 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=ONRqMkeO; arc=none smtp.client-ip=192.198.163.8 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=1711484976; x=1743020976; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J9fUAQZWkixjtehQmnGr1yigtsctKtXiiA3rek8znyk=; b=ONRqMkeOphZmtRu0cxH9CBw3PBNUs+H56a+fmn+t9gZ+r7PnIlb9wr9r xTlWqCQ9gE+3GmjUvB8zavjom42sVnV7IbRmWxiiWMU8kfgeMgq7NzbPH AUsLX1hzxKFWdVtT7EIhKrRAgm2aDHWpuuAFVnMBDzrgIj1xESb8IjNxy yzrVQzG8MyI7Zi2s3tcm9i5/x+36A1rJUSK57edhh8A1FOwieP7LOR90T 2RtMk4ZnJ7Efh+ixkAx+bwKcbAKe1LR9qgBmKZ3myCAECRj9v7UEv6ZiZ hOS7uxcbBVar/u9JpTNSojMPt4NZf5UqHfcVHXNU8GiTWSR8VF/MAnJOs w==; X-CSE-ConnectionGUID: cDa5Tc1QTLy7AbBnpnLXCA== X-CSE-MsgGUID: Nfw6t1/nTAKpuF67pAVdpQ== X-IronPort-AV: E=McAfee;i="6600,9927,11025"; a="24049100" X-IronPort-AV: E=Sophos;i="6.07,157,1708416000"; d="scan'208";a="24049100" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2024 13:29:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,157,1708416000"; d="scan'208";a="16163025" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa008.fm.intel.com with ESMTP; 26 Mar 2024 13:29:33 -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 v5 5/6] perf stat: Add retire latency print functions to print out at the very end of print out Date: Tue, 26 Mar 2024 16:28:58 -0400 Message-ID: <20240326202859.960577-6-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240326202859.960577-1-weilin.wang@intel.com> References: <20240326202859.960577-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 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" #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, event.nd) { + if (newline) + do_new_line_std(config, os); + fprintf(out, "%'*.2f %-*s", COUNTS_LEN, t->val, EVNAME_LEN, t->event.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, 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 +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