Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1672903rdb; Wed, 20 Sep 2023 16:38:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKHoK9uEpa6YBiyHdUzmrsHfISnbcq44Wah5dwcdfBg1oC1xAXJYSEk5dGXkYFZyTtnCQL X-Received: by 2002:a17:902:da86:b0:1bb:9e6e:a9f3 with SMTP id j6-20020a170902da8600b001bb9e6ea9f3mr4059992plx.4.1695253121809; Wed, 20 Sep 2023 16:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695253121; cv=none; d=google.com; s=arc-20160816; b=0IZIh3Td8qsO0wSb9m78vCfOWJUOwXvRwYP+L5flxgHjEtkHkFseiUKQYdzDzWdZxZ aqkynM57cvUWGRgoaXodqYEljv+pTzJdcDz40nlnYCSAbFgHD+0jEy4+RjkH0Z1fU5lZ pzsIm9M1IX/zYfhPgMQwMnG7EoW7kuB/ZKZATRFHAaaIN7e3LuOog9juYIZgK6r5dwAU Cix2rVFJvnqE5NWxtwvabsKZM8UuIEC6/05dDdSeIyDeaFFCyZaPRD0hsE45xZGdo/Sm RGKBlupMG8hehvacBqgdGERON8PPfdPMra5RNe8ZRdiKFSQniJMKoJox0wnQJdc9IukV 6fWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=1hKvz7XvoFisXebVKsC7UUKF/hpZhzRWhPwp6F41w0w=; fh=t0qyk7LgJ1hWHHU5kBGtUVAPvlaLsBHKiqgneqbTeQE=; b=Abv2VR6oAp/Qal4kYwku+1hneUOIH1LfUHgauXA8H8XZDimEjs3yPfs2wy9F3FtWAc A90GcgSNCZDxCsEQoEIFSv7EBe6IxneWbTcN1oxc8BXojBEsGRazbQi/W5obLHHEAlrH spD4KjL+KOKhuXd99F1KbV1dJI131hbmdykOBFPk5DBemOctqMd1Uje0/piG547mBLRB o3ECkDzwQDrR/5faYC9IQwZyJPQEvpWjg5YGMU0MQw0NBIns8DJDbZ/z/DRsSORyZHkV VjD3vvmExyR7Qc6zMkOASEjTYdh6OXVz3d5HoAOWkvcHyTjV75j6RKYR0bWMG7nONYlU 9s7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=i9hONhm7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id jk15-20020a170903330f00b001b86671b3f1si141725plb.190.2023.09.20.16.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 16:38:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=i9hONhm7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5F3EC82265D3; Wed, 20 Sep 2023 09:02:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234593AbjITQCo (ORCPT + 99 others); Wed, 20 Sep 2023 12:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235586AbjITQCm (ORCPT ); Wed, 20 Sep 2023 12:02:42 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 369BAD9 for ; Wed, 20 Sep 2023 09:02:36 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-41761e9181eso392781cf.1 for ; Wed, 20 Sep 2023 09:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695225755; x=1695830555; 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=1hKvz7XvoFisXebVKsC7UUKF/hpZhzRWhPwp6F41w0w=; b=i9hONhm7zfnHV/aTzhGs4cQSXGMT2yUc7CjaGBaa6WKeeCP05+3V7isaAv6aJYaEkM YcArR8d8c3S26ZrCOgaN69Dv2lLdu+CfT5iqHbDrPhQBZZm9kB5McPVKGhwpjwRLIYmq tdc+0waZ7rUMVZg4xlQo2UDYKGeAmpJOQHHsW7+C8hOiEGwQ5BGwFMNEliprJzJn1Y0G LhJKf+yjNicp2acodGhD6Ks/C20jtrqSS7htOeQNtRJplpXMhl1ePqw+SywVDXuQFIfw /pnWsEVOBtF2UmKRKkoiqhQclzB1VQIs8B/1RUR8oexIp9XQJdEne1m1dq0PI4U8T1Gh VQgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695225755; x=1695830555; 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=1hKvz7XvoFisXebVKsC7UUKF/hpZhzRWhPwp6F41w0w=; b=F5zrmqW4bSyS/6PGT2c7vz6kh6JJ1KrTzJ5zgzhmofmT2kKxiy3trV/L6FaeKNsc7T WYZDegRts0rHWG3XvR+xEwKM6j7NkF2fmigN+F9JT1zw8h4Xw2t5yN9ykV6HTgbxZ1pd IbkpWVxOeAyCBI31ssR3GDVDIV8VD+hRq+U/jZ2AKL9IzjK8faytRUBjz5CrfRxiHjlK nsXhIKqWLsyQy+EZy++g6rEqaLdkEn5zdI8C9h0fLL1cNzYZSnehNUjWKMlzXriGw6Th 1MjDmT+wz5rcY6oukknTX6gIlYcIqXFNg8UOhC3s63Hdoq3IoLkR91ySxLoO2iByunRx fJig== X-Gm-Message-State: AOJu0Yw41EnR9e8OZxDhoqBOI3p08ULKJu7Zn0RLK0d1vfxCkUohcdU7 brtgKLjaA/iUM1Mj2qpQNnJqLddVVxlXQQNv8rUMDg== X-Received: by 2002:a05:622a:4e:b0:410:9d31:68cd with SMTP id y14-20020a05622a004e00b004109d3168cdmr226058qtw.27.1695225755151; Wed, 20 Sep 2023 09:02:35 -0700 (PDT) MIME-Version: 1.0 References: <20230920122349.418673-1-wyes.karny@amd.com> In-Reply-To: <20230920122349.418673-1-wyes.karny@amd.com> From: Ian Rogers Date: Wed, 20 Sep 2023 09:02:23 -0700 Message-ID: Subject: Re: [PATCH] perf pmu: Fix perf stat output with correct scale and unit To: Wyes Karny Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, adrian.hunter@intel.com, kan.liang@linux.intel.com, james.clark@arm.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, sandipan.das@amd.com, ravi.bangoria@amd.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 20 Sep 2023 09:02:42 -0700 (PDT) On Wed, Sep 20, 2023 at 5:24=E2=80=AFAM Wyes Karny wro= te: > > The perf_pmu__parse_* functions for the sysfs files of pmu event=E2=80=99= s > scale, unit, per-pkg and snapshot were updated in commit 7b723dbb96e8 > ("perf pmu: Be lazy about loading event info files from sysfs"). > However, the paths for these sysfs files were incorrect. This resulted > in perf stat reporting values with wrong scaling and missing units. This > is fixed by correcting the paths for these sysfs files. > > Before this fix: > > $sudo perf stat -e power/energy-pkg/ -- sleep 2 > > Performance counter stats for 'system wide': > > 351,217,188,864 power/energy-pkg/ > > 2.004127961 seconds time elapsed > > After this fix: > > $sudo perf stat -e power/energy-pkg/ -- sleep 2 > > Performance counter stats for 'system wide': > > 80.58 Joules power/energy-pkg/ > > 2.004009749 seconds time elapsed > > Fixes: 7b723dbb96e8 ("perf pmu: Be lazy about loading event info files fr= om sysfs") > Signed-off-by: Wyes Karny Reviewed-by: Ian Rogers Thanks! Ian > --- > tools/perf/util/pmu.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c > index 0d81c059c91c..93feee29d054 100644 > --- a/tools/perf/util/pmu.c > +++ b/tools/perf/util/pmu.c > @@ -295,7 +295,7 @@ static int perf_pmu__parse_scale(struct perf_pmu *pmu= , struct perf_pmu_alias *al > len =3D perf_pmu__event_source_devices_scnprintf(path, sizeof(pat= h)); > if (!len) > return 0; > - scnprintf(path + len, sizeof(path) - len, "%s/%s.scale", pmu->nam= e, alias->name); > + scnprintf(path + len, sizeof(path) - len, "%s/events/%s.scale", p= mu->name, alias->name); > > fd =3D open(path, O_RDONLY); > if (fd =3D=3D -1) > @@ -330,7 +330,7 @@ static int perf_pmu__parse_unit(struct perf_pmu *pmu,= struct perf_pmu_alias *ali > len =3D perf_pmu__event_source_devices_scnprintf(path, sizeof(pat= h)); > if (!len) > return 0; > - scnprintf(path + len, sizeof(path) - len, "%s/%s.unit", pmu->name= , alias->name); > + scnprintf(path + len, sizeof(path) - len, "%s/events/%s.unit", pm= u->name, alias->name); > > fd =3D open(path, O_RDONLY); > if (fd =3D=3D -1) > @@ -364,7 +364,7 @@ perf_pmu__parse_per_pkg(struct perf_pmu *pmu, struct = perf_pmu_alias *alias) > len =3D perf_pmu__event_source_devices_scnprintf(path, sizeof(pat= h)); > if (!len) > return 0; > - scnprintf(path + len, sizeof(path) - len, "%s/%s.per-pkg", pmu->n= ame, alias->name); > + scnprintf(path + len, sizeof(path) - len, "%s/events/%s.per-pkg",= pmu->name, alias->name); > > fd =3D open(path, O_RDONLY); > if (fd =3D=3D -1) > @@ -385,7 +385,7 @@ static int perf_pmu__parse_snapshot(struct perf_pmu *= pmu, struct perf_pmu_alias > len =3D perf_pmu__event_source_devices_scnprintf(path, sizeof(pat= h)); > if (!len) > return 0; > - scnprintf(path + len, sizeof(path) - len, "%s/%s.snapshot", pmu->= name, alias->name); > + scnprintf(path + len, sizeof(path) - len, "%s/events/%s.snapshot"= , pmu->name, alias->name); > > fd =3D open(path, O_RDONLY); > if (fd =3D=3D -1) > -- > 2.34.1 >