From patchwork Tue Jun 17 12:48:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Rui X-Patchwork-Id: 897872 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 998AF2E06CF; Tue, 17 Jun 2025 12:49:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750164557; cv=none; b=HsCQnPm0shSrixCkuVB2gYKQoR1qxMsxPe/QRcBZg8dZy4R/k4bgnyN/w8lI2gJ4TIrhYpE3VIUm+sXWPFE7Kp8ES7Z8e3330vkbI+45SFz/PYxpVQdAyN2q2/54rl9zQXa5zzhgYrN8Yf9GAsDN+TE6sYPoB3Y+k5hgByrMZsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750164557; c=relaxed/simple; bh=U98R0X6/8fnK9rCzgloNwlJHN8hx6yL/+Cb0wkk0l20=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BUN+/Gr+e2AgvDGHs7T2Q2TSuJJDlrDK2/mpIOXV47+dQDfmq1PW8jj5PJKIkdnJeB6VftWRPDIiSUnZUhUMKGpwMGTyO+Y39SVgAuxTrLBZ70NWE8KKGqVhQ/rm6BYXuL2gWDISSzenyY4jYRNy/kOZx4YaILufamHQ/t5xCUs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FL70Voxa; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FL70Voxa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1750164555; x=1781700555; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=U98R0X6/8fnK9rCzgloNwlJHN8hx6yL/+Cb0wkk0l20=; b=FL70Voxa/AyjhcIohx79RAgggRl1J46iNAp/95s9zYq+RL9aFo9ALBOg y0CiDqTWhtbnxJ39BxBm5WLVL6mPYu6ydmEamElSe3NLlt5ygPztYf6OP RYe9Z18KMAkDt7LgF8yPSXVykIKMLf/zJgvJTjckYhxMByyMCZ5i3yRf5 cYuEYaaZEDyAkxuCKBNvPU1V2EiaJQNg24hfTWfprgN/CYxRXaUrekT6t y7sstZvA+W83ZSIKXcEqTiROhqu65289cEWh5hhUr3lrgcyIioP33B1UN xqmYumwvxfoqO7cHANXtYfoZcrustpS5mnfuiIIl6ynytpsXxSg9oHai0 Q==; X-CSE-ConnectionGUID: fIqSIYSqQqizraJ63ppehA== X-CSE-MsgGUID: Qtx4LbBXS+q6GPNwSTuzvQ== X-IronPort-AV: E=McAfee;i="6800,10657,11467"; a="52254986" X-IronPort-AV: E=Sophos;i="6.16,243,1744095600"; d="scan'208";a="52254986" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2025 05:49:06 -0700 X-CSE-ConnectionGUID: oWDfXEy6SmOiFsj81lim1g== X-CSE-MsgGUID: HKltE5ioQEaY/VjTQyX9IA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,243,1744095600"; d="scan'208";a="153661271" Received: from anmitta2-mobl4.gar.corp.intel.com (HELO rzhang1-mobl7.intel.com) ([10.247.119.11]) by fmviesa005.fm.intel.com with ESMTP; 17 Jun 2025 05:49:03 -0700 From: Zhang Rui To: rafael.j.wysocki@intel.com, lenb@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 1/2] tools/power turbostat: Fix bogus SysWatt for forked program Date: Tue, 17 Jun 2025 20:48:59 +0800 Message-ID: <20250617124900.186591-1-rui.zhang@intel.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Similar to delta_cpu(), delta_platform() is called in turbostat main loop. This ensures accurate SysWatt readings in periodic monitoring mode $ sudo turbostat -S -q --show power -i 1 CoreTmp PkgTmp PkgWatt CorWatt GFXWatt RAMWatt PKG_% RAM_% SysWatt 60 61 6.21 1.13 0.16 0.00 0.00 0.00 13.07 58 61 6.00 1.07 0.18 0.00 0.00 0.00 12.75 58 61 5.74 1.05 0.17 0.00 0.00 0.00 12.22 58 60 6.27 1.11 0.24 0.00 0.00 0.00 13.55 However, delta_platform() is missing for forked program and causes bogus SysWatt reporting, $ sudo turbostat -S -q --show power sleep 1 1.004736 sec CoreTmp PkgTmp PkgWatt CorWatt GFXWatt RAMWatt PKG_% RAM_% SysWatt 57 58 6.05 1.02 0.16 0.00 0.00 0.00 0.03 Add missing delta_platform() for forked program. Fixes: e5f687b89bc2 ("tools/power turbostat: Add RAPL psys as a built-in counter") Signed-off-by: Zhang Rui Reviewed-by: Len Brown --- tools/power/x86/turbostat/turbostat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 5230e072e414..5f8ab899b552 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -9817,6 +9817,7 @@ int fork_it(char **argv) timersub(&tv_odd, &tv_even, &tv_delta); if (for_all_cpus_2(delta_cpu, ODD_COUNTERS, EVEN_COUNTERS)) fprintf(outf, "%s: Counter reset detected\n", progname); + delta_platform(&platform_counters_odd, &platform_counters_even); compute_average(EVEN_COUNTERS); format_all_counters(EVEN_COUNTERS); From patchwork Tue Jun 17 12:49:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Rui X-Patchwork-Id: 897456 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 D917F2DBF69; Tue, 17 Jun 2025 12:49:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750164558; cv=none; b=nQljWXT5yvzb6vLXfKz050/CUWnGwsAeT8cpScoAlr3auLMu75L/L+A0mJBqfxvRtRh+XFtEg1MVfyzUlN5Sa3gCGDKFqCc5elOcYaatv3wYXIhIHqNF09mzPuIHc9tDkGHYOrcKfcjPFtdtGvblenZtQ0wcGmy3egwYRKRtj6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750164558; c=relaxed/simple; bh=tGhygor0l+BgsarSmUjvGvw5JgnyQpjXVM+UY+ayPIQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jKNJh0D3pMOd0Odg8jveQk/ZqCsqDnvl3Xze+aX9E6E8s46g2a2MsuolLuFZjFmTrKG4siyfPk4dP9EgXOmes+aqra9LZ0e7kyXzxx5OgOYMbSQ2fviJLwFGOOVN73zSinmNWOBpwVGZC2fNjTVGJNAXWNhltk9eOBBbnayA8Bw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GYkVxmwl; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GYkVxmwl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1750164557; x=1781700557; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tGhygor0l+BgsarSmUjvGvw5JgnyQpjXVM+UY+ayPIQ=; b=GYkVxmwlaIsV0LgH15eltOdup7I0NhswDNSAakUXQFdrxxEGX+C8ZmmJ NI5HNtq614KvVbDaL967QhxUG/pXQCjx0WvQu95pLEdltjILVFGgCfijq zLaV9kUSY2M5oanzVO4auKoP+OQMCHVdxBCvHgHf5U2y/hEAaBHGaP19y V4OAP1FVYziuDbksSGiukMmdRNPRXxWUfZhIS3sUxZIa2j8dywXxg2Jgi LKL1Gv4LI422GjGY0wJzt8+S22u96l0URqS0ZxeC8dTq4ebIABTwLXBnm aRFYtQCFmhHO/D9nCdCWs+UTbMDHPLBALoO6NfcaEojWBomcJmF47DcDx w==; X-CSE-ConnectionGUID: x6t3juZpRRyYMa/NXcU+2A== X-CSE-MsgGUID: PTKNVk3JTgOwnxeT8IdQzQ== X-IronPort-AV: E=McAfee;i="6800,10657,11467"; a="52255008" X-IronPort-AV: E=Sophos;i="6.16,243,1744095600"; d="scan'208";a="52255008" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2025 05:49:11 -0700 X-CSE-ConnectionGUID: DQcMpZnzSKCP8+f7GFqRFw== X-CSE-MsgGUID: m+vPFJLuRNCXICCIqf2OPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,243,1744095600"; d="scan'208";a="153661287" Received: from anmitta2-mobl4.gar.corp.intel.com (HELO rzhang1-mobl7.intel.com) ([10.247.119.11]) by fmviesa005.fm.intel.com with ESMTP; 17 Jun 2025 05:49:07 -0700 From: Zhang Rui To: rafael.j.wysocki@intel.com, lenb@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 2/2] tools/power turbostat: Enhance legacy uncore detection Date: Tue, 17 Jun 2025 20:49:00 +0800 Message-ID: <20250617124900.186591-2-rui.zhang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250617124900.186591-1-rui.zhang@intel.com> References: <20250617124900.186591-1-rui.zhang@intel.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, legacy uncore probe is done by checking the permission for /sys/devices/system/cpu/intel_uncore_frequency/package_X_die_Y/ However, legacy uncore runtime update needs to access /sys/devices/system/cpu/intel_uncore_frequency/package_X_die_Y/current_freq_khz which demands higher privileges. This discrepancy can lead to situations where turbostat incorrectly detects legacy uncore support but fails to access it during runtime when executed without root privileges. Fix the problem by checking the same sysfs entry used for runtime update to decide if legacy uncore support can be probed or not. Reported-by: Artem Bityutskiy Signed-off-by: Zhang Rui Reviewed-by: Len Brown --- tools/power/x86/turbostat/turbostat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 5f8ab899b552..46f6a696b434 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -6737,7 +6737,7 @@ static void probe_intel_uncore_frequency_legacy(void) int k, l; char path_base[128]; - sprintf(path_base, "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d", i, + sprintf(path_base, "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d/current_freq_khz", i, j); if (access(path_base, R_OK))