Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp466035lqo; Thu, 16 May 2024 11:08:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3SaTKMFpnofCvPkrpfAyMDHlE2h5nlpfWcyqIJfqcnks88rcvQVhIUeH7dD93s2PZIVAbDxGa2xkbyGBCYdzc4Gc3fKWwVrbkTK8AnA== X-Google-Smtp-Source: AGHT+IEKO1Q2dVAcm5dOBvGNlrwlEhcMClAQcK7ajJi7fS7utAlgHId1MhZxJfgaP92XMxpLwG9/ X-Received: by 2002:a05:620a:27d0:b0:792:c5d1:1d99 with SMTP id af79cd13be357-792c759aeabmr2627365185a.28.1715882901627; Thu, 16 May 2024 11:08:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715882901; cv=pass; d=google.com; s=arc-20160816; b=wDIkqKIsdQd0vDZmc2IWX1QszqiORIkGrFihSuJnAOYee3YkoWxfXRjTpECrJLidcM Z0BT3jk+UPISbBOVYDA7jQwAxjHtYEU+wddA2ZnLDX5beb/nMINNdu/HkA4FiMBkKcze Jq/2QqlEWjqYfc6/qSkAb/XJTpcAXwIgOM6dm11KDPYRrx8g5YALkW3eOB5iq8BbJZoU CQdqIttmyMQVVrOP1udb6UshZd+eeEgkfL0TGtmE3Qi2k82sDDjexbmOQeYna5qVeAUw RPaVMcZWkT4X9yKfBJCTQDozfvlxKOGKNYozgZT09D8I9naVLLaIb3cmfp/bX5krZXEw YVCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=banjYwwSFjZLLyNlG79LTVlCiVU6mZgaJjWJacGYzYE=; fh=NC8TUisKQewWkmjNgyfJTUj35XXOHHaL18YJQRpE/dI=; b=wZkch6r1WEs6hwFV/hHonrkn+UgIfhkVH1rWxkO3TM4nRDBmyQUe3E03TiKv6dGxFo dtlYSnWvbVLy1lCTSjh/esYc6BmaNlCi6AQkKoRTGJEg5QcJJ+sbBLQX9dz5fcCIl7lT 19jYZpqQMJ229KuAXeApZQ3cyP9RvKPgRoQ5WaKNB33v1IJ+GjbyyS0lUFeXsOJkp2Ul zH11cWHORdMipnSr1736QylxBz4DJBwyiSBHDhhwTZj+qct5kPa2aXWquQLcMSavzRZw 0IyVZFJeUQFWpUg2nil/KBHowV8TReqLPUMoUl8t74mYuW/G9F96liAE+8jok/K/ely1 k/Ow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=28EGLpz6; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-181429-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181429-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf277f7bsi1672902785a.135.2024.05.16.11.08.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 11:08:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181429-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=28EGLpz6; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-181429-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181429-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 508731C21A33 for ; Thu, 16 May 2024 18:08:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5AA8156F23; Thu, 16 May 2024 18:08:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="28EGLpz6" Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11AC71A2C07 for ; Thu, 16 May 2024 18:08:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715882894; cv=none; b=b01D7MLrRYDgbkhRiCtFcxL0W0GlqpuNEL/H2shPYIcZ9t/TwF63XLBFiUr48fXfndXXRtvVlkjTUVW0+jV79zx3vk6TFDPzVEYXWTn42tMZs8Ed/L6uPb0tSY/2prJBLVWhoY0iBV1MpiCzCisa0jAXf1ySmIYeiIwCr3ELkXo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715882894; c=relaxed/simple; bh=1PYeOsOEm7vpaC1EVcf9o484WHJ4uE8YCtY91oEoRh0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=iETLDGkqTABAyd7RIYF5+56XRDTltHit4Kh+7V85kqRRc9ulSx5ALUnPJ3O7XA+jIyjPWFA+7IdyikYidB4w/adN2cDITdlkcBXqgoYefhCnV8qdLfJFN6eCLkXhooV8rWBnaRS6OVdQya5Smf5A+iS8/p0aIQZm8FidzQ+5MqA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=28EGLpz6; arc=none smtp.client-ip=209.85.166.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-36c6056f7bdso14355ab.0 for ; Thu, 16 May 2024 11:08:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715882891; x=1716487691; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=banjYwwSFjZLLyNlG79LTVlCiVU6mZgaJjWJacGYzYE=; b=28EGLpz6Zm8mGK3kKclRYRbM0SojphS0pBXjXPkp4R0LuShZLr1SZQIJavH9X8DTsU UiXPJIehG3IzP3LN/hsBPAAJIkKPB2ZNS23E8OihJO/yrjo18eSYXp3x0/x9VZL4t9Wd g4tCLVDVS6qNhWXvDh/CwXsyuk7fpibQUWEiYhsAVTM2pJFzzA1qx3OIWH6XQgbj3lXj AOc8+zqFqvocsRgCzPA0sIgkMu7ilEqS+Nyrnme3ugVOatipjLvc2obqDFZKdRchAyr5 c/bxQqpQUfI7x0msI2ulekVy0R10zHJwqs3vtUDSvMb86O8Cgnxv/Fs+Il25g547XwWd ylRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715882891; x=1716487691; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=banjYwwSFjZLLyNlG79LTVlCiVU6mZgaJjWJacGYzYE=; b=Fu66G8+anS9hd7WOfJxilrS+NKDGOlA5cH7eQZEbzoyf99aKDrB5qTuqwyFxUbds22 4WTaM3ciIf+Ban5pbUVfsAsnTUyi9JeJashM0iHJPAKU6Qu9lfjUeve2qXyJTaeqr54D GdF4tIctgYNDPLbLgRyip2jxZJOJzK7RfIGNzX6V2Fm5LGutAX1I/pKBwQwB3a+UuMH7 5nlouLVNrVy8wqi1/z/RHprP+eQ3ffzUJTybHNuR7mcAUGLTSZufuLvd2hBsio4k2qe8 5t1Tkzg74hX1BwG2bI4QSoh54DsQwF5Y5/A9turO5C/piilYVAnqtNo9dXZApeDXsp5z idQw== X-Forwarded-Encrypted: i=1; AJvYcCUS42Na0lE1NAJLhR+owl6ef68pw6s9aFzJuUGG/8q93wnQDbHsoz9oS28zPGOgIP6SZt3/d6Vbt9w7MveLEUCtuOoU6+yNy7MCdZ7F X-Gm-Message-State: AOJu0YxzWckptq2MjQvA2XMXgZHeN7h8khLHchLig1SK8oj2LT7X+p++ 7Qn8SIQmPAnqcYo6mqaH8NzTXoB0fBkrFwQyWK8uYZGFGPDaNiqczItdxxa6KvFwfV0+dRHLVmK FVSytSNt9GMkjjfoK8tC6LT3Y5TmanxHTckc3 X-Received: by 2002:a05:6e02:1092:b0:36c:35c9:4b34 with SMTP id e9e14a558f8ab-36dc6d02131mr64695ab.25.1715882891095; Thu, 16 May 2024 11:08:11 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240515054443.2824147-1-weilin.wang@intel.com> <20240515054443.2824147-6-weilin.wang@intel.com> In-Reply-To: From: Ian Rogers Date: Thu, 16 May 2024 11:08:00 -0700 Message-ID: Subject: Re: [RFC PATCH v8 5/7] perf stat: Add retire latency print functions to print out at the very end of print out To: "Wang, Weilin" Cc: Namhyung Kim , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , "Hunter, Adrian" , Kan Liang , "linux-perf-users@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Taylor, Perry" , "Alt, Samantha" , "Biggers, Caleb" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 16, 2024 at 10:52=E2=80=AFAM Wang, Weilin wrote: > > > > > -----Original Message----- > > From: Ian Rogers > > Sent: Thursday, May 16, 2024 9:47 AM > > To: Wang, Weilin > > Cc: Namhyung Kim ; Arnaldo Carvalho de Melo > > ; Peter Zijlstra ; Ingo Molnar > > ; Alexander Shishkin > > ; Jiri Olsa ; Hun= ter, > > Adrian ; Kan Liang = ; > > linux-perf-users@vger.kernel.org; linux-kernel@vger.kernel.org; Taylor,= Perry > > ; Alt, Samantha ; Bigge= rs, > > Caleb > > Subject: Re: [RFC PATCH v8 5/7] perf stat: Add retire latency print fun= ctions to > > print out at the very end of print out > > > > On Tue, May 14, 2024 at 10:44=E2=80=AFPM wrote: > > > > > > From: Weilin Wang > > > > > > Add print out functions so that users could read retire latency value= s. > > > > > > 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:R # 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 > > > > My usual complaint that I hate the stat-display spaghetti code. We > > keep putting more spaghetti on the plate and this change does this > > too. In the evsel approach: > > https://lore.kernel.org/lkml/20240428053616.1125891-1- > > irogers@google.com/ > > retirement latency events just update the counts for the event and so > > we don't need to special case tpebs events like this. I'd prefer we > > went that route. My reviewed-by no longer stands. > > > Based on the current stat-display code and the original TPEBS counting > code, I believe the code in this commit and last commit was the best way = to > do the metric calculation and printout. > > But I totally agree with you that if we could get evsel with retire laten= cy work, > this code is not necessary. > > I was thinking to plugin the retire latency value into evsel so that I co= uld delete > this and last commit. Do you think that would be a solution? Yep, I think that'd be good. Thanks, Ian > Thanks, > Weilin > > > Thanks, > > Ian > > > > > --- > > > 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-di= splay.c > > > index bfc1d705f437..b9c3978cc99c 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 "intel-tpebs.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[] =3D { > > > [AGGR_CORE] =3D 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 =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, 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->tpebs_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 =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, nd) { > > > + fprintf(out, "%f%s%s%s%s%ld%s%d\n", t->val, sep, sep,= t- > > >tpebs_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, nd) { > > > + fprintf(out, "\"retire_latency-value\" : \"%f\", ", t= ->val); > > > + fprintf(out, "\"name\" : \"%s\"", t->tpebs_name); > > > + fprintf(out, "\"sample-counts\" : \"%ld\"", t->count)= ; > > > + fprintf(out, "\"retire_latency-sum\" : \"%d\"", t->su= m); > > > + } > > > + 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 +1676,8 @@ void evlist__print_counters(struct evlist *evli= st, > > struct perf_stat_config *conf > > > break; > > > } > > > > > > + print_retire_lat(config, &os); > > > + > > > print_footer(config); > > > > > > fflush(config->output); > > > -- > > > 2.43.0 > > >