Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp400959lqr; Wed, 5 Jun 2024 09:10:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpT6Tgi9LYoeFMZbetxsopgxMH4A+8rcLWUG8c9+YJE6++fjaGqNBfXX/JoZ9GVi7MbvgyvzatWvLhQQvi09AhKhAwM3XBIuyG/XDM6g== X-Google-Smtp-Source: AGHT+IHgbZWIb8Ks9C3sirqmR719H9SVsZr+O1q5h9JGhE3Rfw1qUGQZPcP2ssfqGQlIJzUoK4MC X-Received: by 2002:a05:6808:278d:b0:3d1:fba1:bd1f with SMTP id 5614622812f47-3d2044dfe09mr3485284b6e.39.1717603830753; Wed, 05 Jun 2024 09:10:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717603830; cv=pass; d=google.com; s=arc-20160816; b=xtZZi7PFPW40fxeQvP0dpbVPv+YDVUEF5TaFA75nzb97YDRONgI0qSXnBSQC8cdZqT 3/mq8ycowkdsa4YPx7RZtkdB8bYbBSVg4dhFX6DeR+6uuQ7akQ0Z4382D2uZ8MkUCVVJ o24IgYGyOD5Wc2Fuu9g8cqCOVdqX6rz/O8NEm8jX3XvSyu5ozseDZ9MX0gTpzBZeioDH nGqR43hsqdS3yFdb54/866mz7BC6KnJPFhGVyJ836VqGd0MssjykXHKdJKHDj3RigPG0 pQfOhQs4loXJwL6Lxt7cZfwOwTL1POxWSn/MPHqCw7PZ3A9iCg/8BsnYiNGQ6WnchuPj 3TfQ== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=R++e8H4Xt1Zs8L5GRTqANQSxs1eM6nB+nZpxH0yaCsk=; fh=R6vlulLCMblno0evipVFd402axpzJTFMW03MpqzBwVI=; b=ipJKkK2fR6aObNcl0LdQdnN1CqViYuN3UMpHdiBHau4M7p13FVFKF/MB9UVrPz5CLy uMsKBArxW9Fh9BlaamO9JJzwPs/ev2RfJDkVWYA919vjDtRjyVdCul5j0djPn5A8Ilmu ion32RgD6NTe+ZXiaZkEXDFW1WPnCzqGEPudZUU9v+dGvuunV0RvrrF16clfpf7tjocJ Imga8kMRmnfUrrRTBJTcb07MQkduHGrwuqP7tAudfKiCl8iRuTgPpdYfNZdCAbWHVR64 8IGqZ9YssTZFg5Pt/cPRTBeJboAT30wft6Gkfw62F4o05/k5hc4Ptf5aa6UgSaVDGRAA L1nw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="RvwX/4Si"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-202889-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202889-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. [147.75.199.223]) by mx.google.com with ESMTPS id a1e0cc1a2514c-80adeeb8f41si1960979241.198.2024.06.05.09.10.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 09:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202889-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=@intel.com header.s=Intel header.b="RvwX/4Si"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-202889-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202889-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 69A6D1C237D4 for ; Wed, 5 Jun 2024 16:10:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79950154457; Wed, 5 Jun 2024 16:10:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RvwX/4Si" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 C1ABE27450; Wed, 5 Jun 2024 16:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717603821; cv=none; b=Ks7Z7GN+UQ1FUqoX9cnJ7tTA6UuJb7ljmbtOIVeI8RmbxQ3DLcZXOOLYhMV1mKKdjILcDiskEPDwawLEMpl6/HiBb/rVqPSKeMC+P9LmDuGVrkICPyh+0ucKDHCpUBVXgYFJibg7WSh8isXbQQrs44oWrjTcIkjWtQpD3a49ktg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717603821; c=relaxed/simple; bh=3klxGnG3GkyhrDKSmcnlThuDuIl/9pv+mo2n6zzAz+o=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=FXXblESjcOO6Q7pTqJgneNvxGokUEJG1/aJ/bauFtPqfNdqzphNp7H3J9oK1p0Idd+votHPGJZyFvtu5MGNiS+5DKyncfdHljOzP1sPB1WT3BY5uoemUa3W0jb+wvZ30xSqM/lR4E9hxIPTKUi8Z/Q53zdfAKsodqC5D6lJ4ccI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RvwX/4Si; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717603820; x=1749139820; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3klxGnG3GkyhrDKSmcnlThuDuIl/9pv+mo2n6zzAz+o=; b=RvwX/4Si+wYPxv9mzyj/ZkLyOvwOL+Wo3fpj49FcGY0UdqR52WiQcAem NVSf6a3JlyVVxOm4WZ7KhVjwm/FcnhQzo/iQD69TUWO0mYQlxkHbrjAwd r2m717NAAc4SkemvLzK7oWfras5Tr/jUYqq26Ia3qv72ZOdoVbGhMFQF4 QpgfsHZVrT5kwt73IWM1mEVvFdF3/pXE0+LlY+IMxNT//l6cuG7J3gh5b S25I3ZNVvhUW162ZVmmT6kDccGk8gASVlgw2puZZSUQAaIlbDqQVYevrQ Dcl1CfpDCqij3GROs0HxlOEZhSxoZfyDoNSg6MtWfiTS1rrIiQRG+0oZW g==; X-CSE-ConnectionGUID: XXmzOSDpSMWr8JYqkntMMg== X-CSE-MsgGUID: +X2XEUlVTe6UC1VhwRlGRQ== X-IronPort-AV: E=McAfee;i="6600,9927,11094"; a="25633485" X-IronPort-AV: E=Sophos;i="6.08,217,1712646000"; d="scan'208";a="25633485" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2024 09:10:03 -0700 X-CSE-ConnectionGUID: KMwrIFJPSKubjbNif9H/mg== X-CSE-MsgGUID: EyQtD6qpQxGjOaC/hL9sVg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,217,1712646000"; d="scan'208";a="38300791" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orviesa007.jf.intel.com with ESMTP; 05 Jun 2024 09:10:03 -0700 From: kan.liang@linux.intel.com To: acme@kernel.org, namhyung@kernel.org, irogers@google.com, jolsa@kernel.org, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kan Liang , "Khalil, Amiri" , stable@vger.kernel.org Subject: [PATCH] perf stat: Fix the hard-coded metrics calculation on the hybrid Date: Wed, 5 Jun 2024 09:08:48 -0700 Message-Id: <20240605160848.4116061-1-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 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: Kan Liang The hard-coded metrics is wrongly calculated on the hybrid machine. $ perf stat -e cycles,instructions -a sleep 1 Performance counter stats for 'system wide': 18,205,487 cpu_atom/cycles/ 9,733,603 cpu_core/cycles/ 9,423,111 cpu_atom/instructions/ # 0.52 insn per cycle 4,268,965 cpu_core/instructions/ # 0.23 insn per cycle The insn per cycle for cpu_core should be 4,268,965 / 9,733,603 = 0.44. When finding the metric events, the find_stat() doesn't take the PMU type into account. The cpu_atom/cycles/ is wrongly used to calculate the IPC of the cpu_core. Fixes: 0a57b910807a ("perf stat: Use counts rather than saved_value") Reported-by: "Khalil, Amiri" Signed-off-by: Kan Liang Cc: stable@vger.kernel.org --- tools/perf/util/stat-shadow.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 3466aa952442..4d0edc061f1a 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -176,6 +176,10 @@ static double find_stat(const struct evsel *evsel, int aggr_idx, enum stat_type if (type != evsel__stat_type(cur)) continue; + /* Ignore if not the PMU we're looking for. */ + if (evsel->pmu != cur->pmu) + continue; + aggr = &cur->stats->aggr[aggr_idx]; if (type == STAT_NSECS) return aggr->counts.val; -- 2.35.1