Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1999101lqp; Sat, 23 Mar 2024 20:45:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWCmOWgXHjB7dCs87sC6qcdzurgpqPITGArf6BgTCFWCqcJfmytoJfdtwiIMK5eQJZfqRkkwd4yNx8YgqH+dpl3T6UC95xZYmSFllg/YA== X-Google-Smtp-Source: AGHT+IGbEONwbpBXO7unGm/B/i3Uya0Ykz1yeT2xWztTZZvl0WdojcHcOCQ+aVOaHGqdrAe2Phw5 X-Received: by 2002:a05:6358:33aa:b0:17f:4964:3e04 with SMTP id i42-20020a05635833aa00b0017f49643e04mr4629491rwd.10.1711251940925; Sat, 23 Mar 2024 20:45:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711251940; cv=pass; d=google.com; s=arc-20160816; b=BIhMnk72fhmfwpeTrwMMrOeTMV1ePYZRc7ZwNiweo/4nf+K7CrK6knNMxwCcatsONq Ts5fIU6WXrvheG9AN7txHY3BO/hSX53lWO+KVBXMldyhuTV9o6sEmZGhk0EgO6sXeDK4 2XgOtIxMWV7ZN+uMMp+BitTGOpYKOKCSIgtUTPfECtjJnsLCst+eA7J4D0HC7+Ny9M2a 9EulZxBfwMzCkgNf8lAXqftbHbNSysCd15Ne6SyMJKL07rYEsG4xkUZ9nsJN88exSkQX sc0tXW774rohqlmRJeySuVYBjt976RCB/eVjys8f58rthYY/n15/cZOyhdGOeniygtqT VhyA== 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=EZCokTmZle4WRUisGL16ZDZ627DO4HnlPXhDi+B1ycU=; fh=jzeJnIMTqNPA6Ix9vTj5TLSOPaaTFv18kVsT8P9P/dg=; b=pIaQAfHxjgysVLnYnrnrLs8aqpUx5F1Lt7ZmgaxsCaia1io58w8KeKL2bvzV7y0izg /K77QqPXOkM2IPA3tMJjopPrb59Q+bQyxYwIdcj+MDvh3m4mKy0wqujyCF24Wy7JTFor E3GbXhWJLEjJnU4DQYyN/yG4nO7FeP6a3hqji85OG/WSvqm/e1A6vf0kkKfy0UUblaOB yg0jiR0Lc1x/uYI8m6POb54JCuvDYGVBV2T2vE7uRkS9zK6PJ0JnD7bRbVBKqW2MRG7+ UOLbpIT5D87v/pL0gk4jmyIbWbZwQeUUOWEAVkxyGEL6ujJZO4EqqrVziS4nouZxTwuH pFfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EyZlVcOf; 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-112567-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112567-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l197-20020a633ece000000b005dc6576d8adsi5020681pga.386.2024.03.23.20.45.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 20:45:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112567-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=EyZlVcOf; 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-112567-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112567-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7F5A12826DD for ; Sun, 24 Mar 2024 03:45:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B07E34439; Sun, 24 Mar 2024 03:45:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EyZlVcOf" Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (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 4EA8D17F3 for ; Sun, 24 Mar 2024 03:45:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711251930; cv=none; b=sdCL68Tx47BvxhohPj218K2TJHch50Fb+63XJCxRI6iCFE4EtkW+9m+68ZXu0FbeqBK7ziZNzbtn6sFCJtIOqJfnkJF8/MVNzeRKbORjqkH8hQvwYWWni/Ks0N2RKW6Sp4+/GsQjwPdkyqTKQRkO83HsucFrwlc0oYtZLu2Wdio= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711251930; c=relaxed/simple; bh=iUzFpA4Fu9YSmQkZKCSOgGKftUekVbN3SUQ87quTRH0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=l93OqGvtAWijo4KKBnohVOst53Std5h1bslgiNljyUxe52jq5Dl0b5F+pPJtdy3wXRRclsg/Dq7JGNn/oxftTTd2DG3QAV3XZ+Wo1oBDvzL+3uD8d4Lf2+Btn/hCW3lIN/7CbvugOrycbRi1W/fjiuLSHg0IObeWAmUNujl8W2g= 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=EyZlVcOf; arc=none smtp.client-ip=209.85.166.174 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-f174.google.com with SMTP id e9e14a558f8ab-3686ad91b9bso140765ab.1 for ; Sat, 23 Mar 2024 20:45:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711251928; x=1711856728; 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=EZCokTmZle4WRUisGL16ZDZ627DO4HnlPXhDi+B1ycU=; b=EyZlVcOfn2+UYty3BpUX1+7YyL3lxQjtz8AUUZel2B/mIOJAMY+lZ9OWrbHvGiMGzc zvNw+RsA29fgra0RFXlwmVsBB2ganmy4MzWMU13uJHGT8JXIK3tiv+bNv8JfNAtllEos cn5c0H/DH6nY+XLAJprv/Y9tWKuyIFMvpEEdGITOa+bj0Bt6tWCFVh0OQzGTXjRC0suE h4Usmmqu4hnATBbFVjCvrs+d1HDohMP4JCwfNSInUmwngVDyd8IBEW96ubyU5ZhWOyLC MB57+kMQCKP/eUyt0lMTFPu1p+lgK/Ezi43PApZUVDkcMxMaV1gdG+rYLmms9/V3cMEY n8rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711251928; x=1711856728; 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=EZCokTmZle4WRUisGL16ZDZ627DO4HnlPXhDi+B1ycU=; b=DsQgLD4IsOJxzQGN95OSDK0n6a0uXlhspaHLLxk1C2EtlV33z+63i165heWGzmlIqK Kbu+oWhChMnRRsjLPWY8BN61Ru249d08PT6EwFFzpNpDLM5WY+TfXA4ZBi5Q+foy49M3 0M2hXp/n4rJRw9hhUosntPidorLCraHUX6cNDCJ2JAg9j2uHFOAwZbWMUPNl8K8mMUMC reOyTC+gJ9oAn9S4s3/3MiVrQ0BQ0pe9T+AYq+vZu++BmkQIrK3T1fDqH5+Qo1DDhe8g dlFtRl5TivoIkY3cx7ZsqNzIgzBF6rHfw1gYPj7IOHP5rhLfp1Ro+tunQIxTVlKEqg6Y 0TGA== X-Forwarded-Encrypted: i=1; AJvYcCWT0hwvbhxHNO39i4gHchxKA3T4oPE/zFtnjSwFbqyQTRBi/E5WoXH1F5oFTbuyzaM42DDvcbGMAs/CUiktOjYTxMxwcPOAshdw2rrf X-Gm-Message-State: AOJu0YzIMUvnWZjCIEfIZhc1BspuABX5B51b9toliRWilfFAhvAKa5jg dLIDf+WATRxr5ur3TdN+P7qM6loH8cc81L01T1bHNK5wsdNIx1WM7s3lWTv99T1oHPS0EqVjCCy z1G/1p/kVnnqsIDmH+bH2ycZ4U6d1k0VY8r6cVKLH6gfuszoWAdMe X-Received: by 2002:a05:6e02:12e4:b0:366:526f:17b2 with SMTP id l4-20020a056e0212e400b00366526f17b2mr815554iln.9.1711251928224; Sat, 23 Mar 2024 20:45:28 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240312234921.812685-1-weilin.wang@intel.com> <20240312234921.812685-4-weilin.wang@intel.com> In-Reply-To: <20240312234921.812685-4-weilin.wang@intel.com> From: Ian Rogers Date: Sat, 23 Mar 2024 20:45:14 -0700 Message-ID: Subject: Re: [RFC PATCH v4 3/6] perf stat: Add retire latency values into the expr_parse_ctx to prepare for final metric calculation To: weilin.wang@intel.com Cc: Namhyung Kim , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 12, 2024 at 4:49=E2=80=AFPM wrote: > > From: Weilin Wang > > Retire latency values of events are used in metric formulas. This update = adds > code to process data from perf record for required retire latency values. > > Signed-off-by: Weilin Wang > --- > tools/perf/builtin-stat.c | 1 + > tools/perf/util/metricgroup.h | 1 + > tools/perf/util/stat-shadow.c | 19 +++++++++++++++++++ > 3 files changed, 21 insertions(+) > > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > index 4e92e73cbeaf..a479b21874b0 100644 > --- a/tools/perf/builtin-stat.c > +++ b/tools/perf/builtin-stat.c > @@ -786,6 +786,7 @@ static int process_sample_event(struct perf_tool *too= l __maybe_unused, > if (!strcmp(evname, t->name)) { > t->count +=3D 1; > t->sum +=3D sample->retire_lat; > + t->val =3D (double) t->sum / t->count; > break; > } > } > diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.= h > index 3c37d80c4d34..38f9134d8b54 100644 > --- a/tools/perf/util/metricgroup.h > +++ b/tools/perf/util/metricgroup.h > @@ -82,6 +82,7 @@ struct tpebs_retire_lat { > const char *tpebs_name; > size_t count; > int sum; > + double val; Given the similarity of count, sum and val it would be good to document the= m. > }; > > struct metric_event *metricgroup__lookup(struct rblist *metric_events, > diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.= c > index 3466aa952442..8fc3415de106 100644 > --- a/tools/perf/util/stat-shadow.c > +++ b/tools/perf/util/stat-shadow.c > @@ -355,6 +355,20 @@ static void print_nsecs(struct perf_stat_config *con= fig, > print_metric(config, ctxp, NULL, NULL, "CPUs utilized", 0= ); > } > > +static int prepare_retire_lat(struct expr_parse_ctx *pctx, > + struct list_head *retire_lats) > +{ > + int ret =3D 0; > + struct tpebs_retire_lat *t; > + > + list_for_each_entry(t, retire_lats, nd) { > + ret =3D expr__add_id_val(pctx, strdup(t->tpebs_name), t->= val); > + if (ret < 0) > + return ret; > + } > + return ret; > +} > + > static int prepare_metric(const struct metric_expr *mexp, > const struct evsel *evsel, > struct expr_parse_ctx *pctx, > @@ -486,6 +500,11 @@ static void generic_metric(struct perf_stat_config *= config, > pctx->sctx.user_requested_cpu_list =3D strdup(config->use= r_requested_cpu_list); > pctx->sctx.runtime =3D runtime; > pctx->sctx.system_wide =3D config->system_wide; > + i =3D prepare_retire_lat(pctx, &config->tpebs_results); > + if (i < 0) { > + expr__ctx_free(pctx); > + return; > + } > i =3D prepare_metric(mexp, evsel, pctx, aggr_idx); > if (i < 0) { > expr__ctx_free(pctx); > -- > 2.43.0 >