Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1511145rdb; Wed, 20 Sep 2023 11:04:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFauzWEWxNKTswUTA70JbqMHvyUlOcsQTKgl/34IppMg2E+Tmzy5M9Bv67p86yu5s7uwkfD X-Received: by 2002:a05:6a20:4304:b0:125:3445:8af0 with SMTP id h4-20020a056a20430400b0012534458af0mr4616910pzk.7.1695233086527; Wed, 20 Sep 2023 11:04:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695233086; cv=pass; d=google.com; s=arc-20160816; b=XVm/KlRauVnw7HZrW0/WIJBLHB5D7W5aaESDMqWlu9T1wfOjw790bNTBpz1nAE8oxh XvpdrHIaex54GGnaU2QQd9o2ivjSyXrtR5iGxsDp6wDICfvFA1WwACNebG2c0M6DGCja HRid+pKX0AM2azAvwNO34T5158ZlUF9Tf++BIn1fUQzWwlv6m5i5TozbBxgp8h0t9y8f vZddye9UzEca/uBC5iNTmF7c+00cscf8HbtLS7Eno8CyDzZ9Kb2hOLix00J4+wBQjxa6 V3zKY+lZ7ruj/XKN859v25m88+lg7bMiNOZBdtwVtn7o9TDnBl/2nUyiiFMA8q932zp8 gNDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2sCpGCU3fqgbs5bcyBmaGtePhTvLwP7GlLVCdEJbrug=; fh=6CCBm+jEd6dlXY4zUJEZTrW7Mw/knVN+di59JoZE0YY=; b=b400Q+q1McmKBvCbtaNRY4tuoUnB/pF5SIPgA/NJLVo8qeV6XoSOiMwLc8BIDzX1al r67YwpLwi83ovxCyHJHsYrhYSev0VQ34fpTRmIuyuL0ShzcTcS0XRTZlxa/0gSEsFw24 ndSUZ5mOzon7dXR9ENYUqSVnSxxiAEarrIZdsyQbU+Kpnh1Zp2Drm2G8tbe8bgat9T/b XxQPRAVX1rTn+tKm9lWrQxaGp2XRGTtzix4uo+8xxowJjv5AIlafx//y1M/MKKA6ixay iO/iVIwGQZnsOI+H+IBkf4tE4KHuVL9OA1KQ1vxLsQyGAnfZ8bMb4N8W/XmuXeRzs5CP ztxw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Nfl2I5X9; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id o15-20020a656a4f000000b00578e6358053si1747887pgu.269.2023.09.20.11.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 11:04:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Nfl2I5X9; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6BF8980EA97F; Wed, 20 Sep 2023 05:24:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235254AbjITMYT (ORCPT + 99 others); Wed, 20 Sep 2023 08:24:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234502AbjITMYR (ORCPT ); Wed, 20 Sep 2023 08:24:17 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2085.outbound.protection.outlook.com [40.107.96.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C666D93; Wed, 20 Sep 2023 05:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oo75ohxZMVnI1eHGIvSaN9ZOWyiWIUY/7itfPHeSHqYmxuN+e3RDMeFlE+on0c0R8bB/Ehk6LrWrzJRBczLCcnESRTBi6eNYkHPs99lzq2tXqo009Ph7XhAcu7n+D8BhOJ0Zzp4OvJrV5geemtZsPotswvibmDxAD06pSHQFInbXo2BzmLnKPi/MS8qFuqLtpi2khNcqfoSRMjtpCUjjqEmoPYdx7f8oJZtOdopxtrE5qii3OyNJT2lZKbPouAvbvO4dAlEzqe0O9zAtRpZb4H1UsCYVMnByypW0UEXeSOOFf9NdszwXRfvcSkIyfBEPsuYplXLvunBZQimFTbX2fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2sCpGCU3fqgbs5bcyBmaGtePhTvLwP7GlLVCdEJbrug=; b=ZedUpx9dqNVAauuxVOTcQ7l9pPtt2+aTyzqa57eOo3aJ7k6gBS35MDoy62RRjENPzmJAH4tEeYoyHg2LVGxlM9qOUBJioEQj6sroYDgxJnVCt00arJDqD2SoMsj4st5mH/tE7IAy5R6TE+lAR64bFTaDCuZoRDhDR0utxF4bETL2438o/eu1vBp/e+2rxKYPZGab71pcUh3s5tj3ZbyROWfdZYWHStwUPccNQljYjFOU0/2UPF1n7a8qQ8IJ3qgG8Hae9eTOjdUg4B2KDyi4gh07hmNvCRBZ2W4fESJ6hlVuMvQ/00UE/tmkrQ89133z38bc9o0DjyDKlAFyEdoyxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2sCpGCU3fqgbs5bcyBmaGtePhTvLwP7GlLVCdEJbrug=; b=Nfl2I5X9jtLJDt8cogqMhButSUO+PiRBCQkjQcYpM0BKE4FD/G0P5NGXSwUcBVBlLMM9NPgFCDlHvnhmBxhXHA6KCWPHb6CnjPHKyg8irUIhGNDPxqzriMoqhtF5b0+B8XqkRTYMkaF4y88PFzvHt+i02VU0Hd+Zb/ejR5Y3nTU= Received: from MN2PR18CA0006.namprd18.prod.outlook.com (2603:10b6:208:23c::11) by BL1PR12MB5173.namprd12.prod.outlook.com (2603:10b6:208:308::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28; Wed, 20 Sep 2023 12:24:08 +0000 Received: from BL6PEPF0001AB77.namprd02.prod.outlook.com (2603:10b6:208:23c:cafe::4c) by MN2PR18CA0006.outlook.office365.com (2603:10b6:208:23c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.29 via Frontend Transport; Wed, 20 Sep 2023 12:24:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB77.mail.protection.outlook.com (10.167.242.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.19 via Frontend Transport; Wed, 20 Sep 2023 12:24:08 +0000 Received: from beas.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 20 Sep 2023 07:24:03 -0500 From: Wyes Karny To: , , , CC: , , , , , , , , , , , Wyes Karny Subject: [PATCH] perf pmu: Fix perf stat output with correct scale and unit Date: Wed, 20 Sep 2023 12:23:49 +0000 Message-ID: <20230920122349.418673-1-wyes.karny@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB77:EE_|BL1PR12MB5173:EE_ X-MS-Office365-Filtering-Correlation-Id: caf992b9-47ef-4aac-38ff-08dbb9d47ce7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GJLxQVma+OrY/wmf6Fr12F4lGLmpnJFBPNNO2CdpZthV3qnmyGkCnsIRJjF+XTLbNqrsJWepSEw4mRfs89IxklMVk9kV0CJIYdf2NyTEZJ0ItJElfpgxY0M/8sAKxYPidYf88tuvXX03q4YtgPNBlPHXbD/ONEPotsWEzvAbrJMC346HDdmAIV5jolgP2Tbywb+k0YkFnp+jN2bQEFHdYS2vvEKmJ6W72AR39cd0FsNDUV9C56vB/5/4fH1GLxJnyDjoqTTIGL8HVX5DKjKxDwGW4F237VUW1mR9wX2i4PRc+c0/i75m5grSOcJOBraJPDzN2Xc2E39/+RJAfX72p3EOrNIZ74D68dnOng+HvbijM9qYCKC5F+FlyY1XY/VDV0h/ROJO4exEleTg+iKKaCsyuWee8HkWgLYdskmjDHspvj63tNUeQEaXjgs+mR8OF/Dx8tCMK3s9tqGbG7zNCh7YhC8wAkt+FKKVEUX4iRjBdEZ770W6RQheY/FcFr+SMTZ54yVEGrR8Zko9IjZKikwFAEICVskqCiP78jayIh/ft7OaaqXnDtQOpCvOOlGDbOqTbfMHQo6d1AujsAZFc03ZgO1ZmyGRkHQhpOveWCkX/eYOaryxre8oi/z0FqWGxF/CS95svfpVpc87b9Y1AWALlrH0lO3jrmyUyp53kcEXV0ZAkpn04hEfb8EKho3y5Z/oebtf4laRgrFNObapW/fTpSBttQ83QuoB6fZQunZuRla9g3yGgb2xZdkGex93HlfMqXCrAwviaGXXpYIkcw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(376002)(136003)(39860400002)(346002)(82310400011)(1800799009)(186009)(451199024)(36840700001)(46966006)(40470700004)(426003)(36860700001)(40460700003)(47076005)(7416002)(2906002)(86362001)(36756003)(82740400003)(40480700001)(316002)(110136005)(54906003)(70206006)(70586007)(41300700001)(8676002)(2616005)(8936002)(4326008)(1076003)(6666004)(356005)(7696005)(81166007)(83380400001)(478600001)(5660300002)(16526019)(26005)(44832011)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2023 12:24:08.2321 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: caf992b9-47ef-4aac-38ff-08dbb9d47ce7 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB77.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5173 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Wed, 20 Sep 2023 05:24:21 -0700 (PDT) The perf_pmu__parse_* functions for the sysfs files of pmu event’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 from sysfs") Signed-off-by: Wyes Karny --- 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 = perf_pmu__event_source_devices_scnprintf(path, sizeof(path)); if (!len) return 0; - scnprintf(path + len, sizeof(path) - len, "%s/%s.scale", pmu->name, alias->name); + scnprintf(path + len, sizeof(path) - len, "%s/events/%s.scale", pmu->name, alias->name); fd = open(path, O_RDONLY); if (fd == -1) @@ -330,7 +330,7 @@ static int perf_pmu__parse_unit(struct perf_pmu *pmu, struct perf_pmu_alias *ali len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path)); 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", pmu->name, alias->name); fd = open(path, O_RDONLY); if (fd == -1) @@ -364,7 +364,7 @@ perf_pmu__parse_per_pkg(struct perf_pmu *pmu, struct perf_pmu_alias *alias) len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path)); if (!len) return 0; - scnprintf(path + len, sizeof(path) - len, "%s/%s.per-pkg", pmu->name, alias->name); + scnprintf(path + len, sizeof(path) - len, "%s/events/%s.per-pkg", pmu->name, alias->name); fd = open(path, O_RDONLY); if (fd == -1) @@ -385,7 +385,7 @@ static int perf_pmu__parse_snapshot(struct perf_pmu *pmu, struct perf_pmu_alias len = perf_pmu__event_source_devices_scnprintf(path, sizeof(path)); 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 = open(path, O_RDONLY); if (fd == -1) -- 2.34.1