Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2201450rdb; Tue, 20 Feb 2024 23:22:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXePPVKOLn9JeK01bvGv4h7I9Zves099YSMPqgyVN3d2Sm+F0nMY8miXCrGMXHPGBSpi0CANfPS2BLFgsgZx3rjnF8FLVC0GE2UiytutQ== X-Google-Smtp-Source: AGHT+IEP/3ebI0ZN3/If+1KXqK00DSIyqVYhbhM4RoXyaFkHvy+Ydjkl+GqEpL6c3rdTdUC2Gzet X-Received: by 2002:a05:620a:1489:b0:787:6f29:2f43 with SMTP id w9-20020a05620a148900b007876f292f43mr6650770qkj.0.1708500170564; Tue, 20 Feb 2024 23:22:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708500170; cv=pass; d=google.com; s=arc-20160816; b=LaxvBw489h3GVSeaS3RspKhr+SLa2xiFnMTgegvNryS/14YtITIJrfhK2XycGNGJ5J UXByXTYBRBEQNGau2/ySpdt0dx2R0n93cXWz5jo5/MytXL6s88VB3eGyZiYinNcC7GRk /VDKG7PZI+uVwEkI02RFgur123FovVe3h0JHEpA0BspyEaB2Axs7oJ5SZBMerlNKP/5e eLZI2RGxMfgTpE7weD1erCIxtz7XAF53KnoIcuT5AnGyrI0+3BbyLlqgJFo9ygsvnXx6 jghSiOcGjTkI57083f8UVoMSbiGffWjfY3QApKq3Niym/rNR0Hk1Q1CiQvVGYWlr3aSi 9ZGw== 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=kiNe4FYJxLW+YVishQYnyKSwmnD7Cafm60SAleWvoJc=; fh=D8N1uhCLBRzbbRgEj9aMJ2/kVuNqnMf8W9VxSJOfqPA=; b=fPVPCqiCcYOStHv6TIfzPOx6SZcWylCrF7ijyg3/+O1KGPG9uaeuV1AcolvB7WXS8x kkCW2f+clqlUJ2lB/M9hGbKB6M8ql8w9AWYTsdKIJItHiBkRUeUesEuCPjTnPPi5IKG1 j9YxWBVd7WwRIqmQQ4Ff9FaMqC+CaaO59WZ6WZZt8BJgQY0Lsbu0c1lV3lrXLDAgpxz+ 0H1+entt9vykl5waKmv7G6VnxMmd+g24+9Ez4xULri40V6ppHVpLV4PwDZcl41BshAIP mioMPSRuZFIn3EvOG5wsYFnX/dEytT0Jupo7yY5j8tDJu6hZ0C9Laxvhg0C4S4TzDYlH 6qqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="K6yy5xf/"; 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-74215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74215-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y21-20020a05620a44d500b00785d85d41b8si11657638qkp.110.2024.02.20.23.22.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 23:22:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="K6yy5xf/"; 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-74215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74215-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 5519A1C229DA for ; Wed, 21 Feb 2024 07:22:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A857B3C6B9; Wed, 21 Feb 2024 07:21:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="K6yy5xf/" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 765453B787; Wed, 21 Feb 2024 07:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708500086; cv=none; b=B/zdQ0BZWHqYf+hPsme+MpA0y6PsX7vnsAP00uiiQaieHfKFBSI7MAB8rdFlWUPqWChNDTKIkYeqVIBL/YUem0p78QH1eU9SYhEfhHhBEZcE08Co8Q7jkHPKXJmMFQMmF+jC60A3OnCQ9+gvZSWokS92usRnmBjNxndmAZyGFug= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708500086; c=relaxed/simple; bh=hLBeLFhgQo2IouZ84oByXRXYMmES2v0SNymnjruz2lg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b7nN+xULNzTb547BK/FpWXbBLTY5o8sd0Ki42w3EYspQrNc/4NDMBgMnQXKYlqIPpp7R5OaUqcsVKc3gzXVJoJwQ8w/SpX98MRgTxQGLJFfSl/LnLgit0JVw85dFHV1jFo+NzBKa2w/Hh60oeQH5zWmrECV+R/fEQ65HXoweZMM= 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=K6yy5xf/; arc=none smtp.client-ip=192.198.163.18 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=1708500084; x=1740036084; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hLBeLFhgQo2IouZ84oByXRXYMmES2v0SNymnjruz2lg=; b=K6yy5xf/eTbC4PTlj/3VlC2ohJwuEVV+ED7lO3fdw/ytclsieiVMNxpO CZ8Tt04RQOuUDFFRkt/D/eQJkoHN/rEGhLr3hFxHZuaq9GDX+57iBe5tY FGkkERtKell47Z/LWHzC0B8GUnPARZj9SJmWxuqqFh/tSP68U0R7e2RNm QmLLtyxFJGQh5+XSReMVyrY0EJIy/pTd2YQAs/ipUiYABCfJeROE1b2t2 jYBqADt+xRvhrLCoi/IN0//5Z5/rxrRFYc9bHPjsAjBn+1P+x5M+fIJzT mvBvPUZ4hhmvOc1kp4Y+4ZpbcplQAIwilCzhsW6abhu8Fl6HUaG4Az3Xu A==; X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="2530020" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="2530020" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 23:21:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="5017456" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa010.fm.intel.com with ESMTP; 20 Feb 2024 23:21:21 -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 v1 5/5] perf stat: Add retire latency print functions to print out at the very end of print out Date: Wed, 21 Feb 2024 02:20:59 -0500 Message-ID: <20240221072100.412939-6-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221072100.412939-1-weilin.wang@intel.com> References: <20240221072100.412939-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 afe6db8e7bf4..ea0d67d8993e 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, @@ -415,6 +417,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; @@ -1591,6 +1654,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