From patchwork Tue Dec 3 07:51:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 13891823 X-Patchwork-Delegate: lenb@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 BD0B614389F; Tue, 3 Dec 2024 07:51:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733212281; cv=none; b=Sj4jpW/oAfF8tTpcrAsyEOTFnCghTQnMvqfu/ptgYQv6M65haQJ+jYctrrr012ubYdNp04KnpMkp4HuD3C+O60mnkzaYEdIWB6y83DCaIG7rzC85EeEk2iB+ZhvZ8Xhfgvumlo2Bfwgo68uDd1xqgJ7tXsNY1FdZmww1GzFFL90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733212281; c=relaxed/simple; bh=YK5PQc2Gdt7Umaut3Cs1wIcHAQhwiZ8j7lJAoblrO9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VfKipbAFDNpUppjS+RtStD8PmKbRI0aj3v8K1iZPTtkyV3dRkbTyjQJP71lbYFOf+e4+c/YI+VsF/K4j1VqCw7gLsdrGup71N35og8/JvOlB5x2rNELHs/idrw4s9rh7pmNtp/x9U5TwWwLXIvDwEwikFa2EG4KBpY7mNO294Wo= 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=HStLTfRo; arc=none smtp.client-ip=198.175.65.10 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="HStLTfRo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733212280; x=1764748280; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YK5PQc2Gdt7Umaut3Cs1wIcHAQhwiZ8j7lJAoblrO9g=; b=HStLTfRoGcoV1XHR70UsmKyBDCYUH4NPiPHhO853QWybFlcJrSpNOHsn DABRIGcjSbpu0jRKWmBZF8D3Z01irQndsgSHbcY6Kfi1rX5N61KODqfZg yidF1Zo5qPiLhmM0N4wYpFB+K+ocsHVoNa8F/mF9TkJHWvZpVOx7S84ac TbOXqiHZEb63/wWBN4oHFBXw8rCEP4jmtu42w4eAvOIEWno2DrSPdJS63 tTOX6/7v5klpJ1YsPNP0pjIF6PBkfsfD9Mux6jj3g9Hhjg+yVeRxB5LUP 1V0p2a7Zcv36I1EzW7okb4zbEKYIh9HyOKVcIU7J2anQhXtmek7g+UHfJ w==; X-CSE-ConnectionGUID: cMFY1tdyRVyFfO3jNPdGww== X-CSE-MsgGUID: eawJz99NTtCplZURW5Mf+A== X-IronPort-AV: E=McAfee;i="6700,10204,11274"; a="50822847" X-IronPort-AV: E=Sophos;i="6.12,204,1728975600"; d="scan'208";a="50822847" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2024 23:51:19 -0800 X-CSE-ConnectionGUID: 9QHA8wSHQDOMatwmTBM38w== X-CSE-MsgGUID: D5lL1Zs3QqyqEASzBbQM+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,204,1728975600"; d="scan'208";a="124183016" Received: from rzhang1-mobl.sh.intel.com ([10.239.158.59]) by orviesa002.jf.intel.com with ESMTP; 02 Dec 2024 23:51:18 -0800 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/4] tools/power turbostat: Exit on unsupported Intel models Date: Tue, 3 Dec 2024 15:51:16 +0800 Message-ID: <20241203075119.584419-2-rui.zhang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241203075119.584419-1-rui.zhang@intel.com> References: <20241203075119.584419-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 Turbostat requires per-platform enabling for Intel CPU models due to platform-specific features. When running on unsupported Intel CPU models, turbostat currently operates with limited default features, which can lead to users unknowingly using an outdated version of the tool. Enhance turbostat to exit by default when run on unsupported Intel CPU models, with a clear message to users, informing them that their CPU model is not supported and advising them to update to the latest version of turbostat for full functionality. Signed-off-by: Zhang Rui --- tools/power/x86/turbostat/turbostat.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index e203f109dd2e..bb65c5e1273c 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -1079,6 +1079,13 @@ void probe_platform_features(unsigned int family, unsigned int model) return; } } + + fprintf(stderr, "Unsupported platform detected.\n" + "\tTo get latest turbostat support, please contact\n" + "\t lenb@kernel.org\n" + "\tor pull from\n" + "\t https://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux.git turbostat\n"); + exit(1); } /* Model specific support End */ From patchwork Tue Dec 3 07:51:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 13891824 X-Patchwork-Delegate: lenb@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 40D541AC42C; Tue, 3 Dec 2024 07:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733212284; cv=none; b=c0uC6JMQ3sC0OHCApRXRpFZlLEZcFsAmZ8VB3oFBefbtpGHFCWSvZ9WCdlQ+vmZGa8P2qySg/cJ4WkIwRo4e1PwZa27qnZSLtiFtFQMFqEDi6rbwA8GApcCxptqOUvuzpPd279Lm+jc9ebWEi4/bdSgutcWGq7CmCVQX9v8gCW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733212284; c=relaxed/simple; bh=+yIOxg7UD6tb/FP26lMAhHqnhMvbQO7H+dY3oMrMgiY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hty2e8Ur2ONYJhbDdvtUsfNxZZXkAMC2oGwJvCcoGunV1I/4q+XX04NoYMWXMMeovZK4aMoamcdVAf3nTXVdpsBACL1ak7eS2bidGAAkbhEcyGO6mwp+XOBXxaPTErUYY79j7hvW+ELKT5RISa7tta4/SSjkVEa1Xi+HA6cRP0Y= 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=SMpEtrmN; arc=none smtp.client-ip=198.175.65.10 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="SMpEtrmN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733212282; x=1764748282; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+yIOxg7UD6tb/FP26lMAhHqnhMvbQO7H+dY3oMrMgiY=; b=SMpEtrmN9EZaZ41iAo9ZbSnRibP+B27toKRLkhN5bG0XRX98NkXT/oh7 S/F7kU3YlVWM5liE56/G1I6AfQAWVCtoU8l+72vpwNscK9hVvqQCVlMlx sWhnPROEomY5vTl+uabm8BxABOe6GN5g92t6lvpa0Rx5UZgPUckmOHgBu NeYTdQBubd1aYQ3pgB7uOO1SMRFT9/0Et6/IhRyuq58TVAigYX0dqChYl /rr2m4fv8JHeyoEdGnP9G+dUpovtQ1jTsBO1cA3HmSKc0M9oC4UMN2x8l hC3ph27JPfP+kjxswNeNWl2Qfbg9UoTdPJobGSHakIvCLN3knhh37w26k g==; X-CSE-ConnectionGUID: 0V6kPoWeT7KOFUH/7FPPwA== X-CSE-MsgGUID: X+2aNNYJTk21gs0WCS2V0A== X-IronPort-AV: E=McAfee;i="6700,10204,11274"; a="50822851" X-IronPort-AV: E=Sophos;i="6.12,204,1728975600"; d="scan'208";a="50822851" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2024 23:51:20 -0800 X-CSE-ConnectionGUID: hMtNNo0mRYu9GArDgl+pyw== X-CSE-MsgGUID: xcvWm42BRTWzXz+z6dpUQQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,204,1728975600"; d="scan'208";a="124183026" Received: from rzhang1-mobl.sh.intel.com ([10.239.158.59]) by orviesa002.jf.intel.com with ESMTP; 02 Dec 2024 23:51:20 -0800 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/4] tools/power turbostat: Exit on unsupported Vendors Date: Tue, 3 Dec 2024 15:51:17 +0800 Message-ID: <20241203075119.584419-3-rui.zhang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241203075119.584419-1-rui.zhang@intel.com> References: <20241203075119.584419-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 Turbostat currently supports x86 processors from Intel, AMD, and Hygon. The behavior of turbostat on CPUs from other vendors has not been evaluated and may lead to incorrect or undefined behavior. Enhance turbostat to exit by default when running on an unsupported CPU vendor. This ensures that users are aware that their CPU is not currently supported by turbostat, guiding them to seek support for their specific hardware through future patches. Signed-off-by: Zhang Rui --- tools/power/x86/turbostat/turbostat.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index bb65c5e1273c..508d65e60981 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -1056,9 +1056,9 @@ void probe_platform_features(unsigned int family, unsigned int model) { int i; - platform = &default_features; if (authentic_amd || hygon_genuine) { + platform = &default_features; if (max_extended_level >= 0x80000007) { unsigned int eax, ebx, ecx, edx; @@ -1071,7 +1071,7 @@ void probe_platform_features(unsigned int family, unsigned int model) } if (!genuine_intel) - return; + goto end; for (i = 0; turbostat_pdata[i].features; i++) { if (VFM_FAMILY(turbostat_pdata[i].vfm) == family && VFM_MODEL(turbostat_pdata[i].vfm) == model) { @@ -1080,6 +1080,10 @@ void probe_platform_features(unsigned int family, unsigned int model) } } +end: + if (platform) + return; + fprintf(stderr, "Unsupported platform detected.\n" "\tTo get latest turbostat support, please contact\n" "\t lenb@kernel.org\n" From patchwork Tue Dec 3 07:51:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 13891825 X-Patchwork-Delegate: lenb@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 C11171B0F14; Tue, 3 Dec 2024 07:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733212284; cv=none; b=nHrjDsAkTIOIWjg+LQfhwu1+L4Cjcj3alcVGEkiZtUDGr367rQiWDt8JTs/PgHoihIh02HUDfEWQCZISyxC4QGDyRXqIdBR8CVP6nUGUmDmPJZUI8C4H6w4KNGfDz0nS3OroTc6+ryNmzl7pOWkV1zOZOaY+G+/31Mn911XR1/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733212284; c=relaxed/simple; bh=v3qwmxpDKqg3xwk9gjV3fcUAEJOvWXxp7rHJ7S8iLmc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VnIvFF+d9IJUpMfoYoy2kMzCFgEpsMUZkcGT8JWcEKjyHapxxQjE+NoSkIhHwu5Rhf79p3ZEByzF6c0NhUyyGN3yrQrfJh4qIiVP5mIODMJSq2KcHlhpuXjqNIncJ9Q0VbqgD1+Fc54vdqW6eF/cz4r8csKXGLvtrFzGtT2Zjtg= 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=iFQYhFB9; arc=none smtp.client-ip=198.175.65.10 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="iFQYhFB9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733212283; x=1764748283; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v3qwmxpDKqg3xwk9gjV3fcUAEJOvWXxp7rHJ7S8iLmc=; b=iFQYhFB92vW0YJDFesXP3Sv44Z5I1obBBgstFi4qP0RlNN4Z36UKCsec yb7jEg1/4uUE2vFfrrXJegcOC5kTtLKc6+ejpGVY9fhu7ZHSv3J/Fvps3 2wRSJ4Xg8Uf28b9WWHSCTKPTSNe4jrDSUr5nmXCRSc+wd9Z8QjJB8GWfB 2XiwRX1KbjDsxa2ptlG0Y9DvzwfGD1XUarGGYBL31WKT/zfF6aA+35Nyv ndlcp5Mk5MjyEXDbDxYmuaUfXJF8fz5fke8g7N0LSw2Ded/elXDwU2+F4 FiCHTZhXa5fnxXnXvtTUS+m7uSWIb6d/7SKokX+Cl5Oy5SFV3J/kguGnV A==; X-CSE-ConnectionGUID: mrZuU0CtSUqD/uaphFDZpA== X-CSE-MsgGUID: UEhlQh+KQtqH4LdNIGWE6g== X-IronPort-AV: E=McAfee;i="6700,10204,11274"; a="50822853" X-IronPort-AV: E=Sophos;i="6.12,204,1728975600"; d="scan'208";a="50822853" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2024 23:51:22 -0800 X-CSE-ConnectionGUID: jdO5AyTcTNe2dPY4K8miag== X-CSE-MsgGUID: jWphu4LmRBeMB15khgxaPA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,204,1728975600"; d="scan'208";a="124183034" Received: from rzhang1-mobl.sh.intel.com ([10.239.158.59]) by orviesa002.jf.intel.com with ESMTP; 02 Dec 2024 23:51:21 -0800 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 3/4] tools/power turbostat: Improve --help output Date: Tue, 3 Dec 2024 15:51:18 +0800 Message-ID: <20241203075119.584419-4-rui.zhang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241203075119.584419-1-rui.zhang@intel.com> References: <20241203075119.584419-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 Improve the `--help` output of turbostat by standardizing the format and enhancing readability. The following changes are made to ensure consistency and clarity in the help message: 1. Use a consistent pattern for each parameter's help message: - Display the parameter and its input (if any) on the same line, separated by a space. - Provide the detailed description on a separate line. 2. Ensure that the first character of each description is in lower-case. These changes make the help output more uniform and easier to read, helping users quickly understand the available options and their usage. No functional change. Signed-off-by: Zhang Rui --- tools/power/x86/turbostat/turbostat.c | 41 +++++++++++++++++---------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 508d65e60981..442a993c5114 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -2148,41 +2148,52 @@ void help(void) "when COMMAND completes.\n" "If no COMMAND is specified, turbostat wakes every 5-seconds\n" "to print statistics, until interrupted.\n" - " -a, --add add a counter\n" + " -a, --add counter\n" + " add a counter\n" " eg. --add msr0x10,u64,cpu,delta,MY_TSC\n" " eg. --add perf/cstate_pkg/c2-residency,package,delta,percent,perfPC2\n" " eg. --add pmt,name=XTAL,type=raw,domain=package0,offset=0,lsb=0,msb=63,guid=0x1a067102\n" - " -c, --cpu cpu-set limit output to summary plus cpu-set:\n" + " -c, --cpu cpu-set\n" + " limit output to summary plus cpu-set:\n" " {core | package | j,k,l..m,n-p }\n" - " -d, --debug displays usec, Time_Of_Day_Seconds and more debugging\n" + " -d, --debug\n" + " displays usec, Time_Of_Day_Seconds and more debugging\n" " debug messages are printed to stderr\n" - " -D, --Dump displays the raw counter values\n" - " -e, --enable [all | column]\n" + " -D, --Dump\n" + " displays the raw counter values\n" + " -e, --enable [all | column]\n" " shows all or the specified disabled column\n" - " -H, --hide [column|column,column,...]\n" + " -H, --hide [column | column,column,...]\n" " hide the specified column(s)\n" " -i, --interval sec.subsec\n" - " Override default 5-second measurement interval\n" - " -J, --Joules displays energy in Joules instead of Watts\n" - " -l, --list list column headers only\n" - " -M, --no-msr Disable all uses of the MSR driver\n" - " -P, --no-perf Disable all uses of the perf API\n" + " override default 5-second measurement interval\n" + " -J, --Joules\n" + " displays energy in Joules instead of Watts\n" + " -l, --list\n" + " list column headers only\n" + " -M, --no-msr\n" + " disable all uses of the MSR driver\n" + " -P, --no-perf\n" + " disable all uses of the perf API\n" " -n, --num_iterations num\n" " number of the measurement iterations\n" " -N, --header_iterations num\n" " print header every num iterations\n" " -o, --out file\n" " create or truncate \"file\" for all output\n" - " -q, --quiet skip decoding system configuration header\n" - " -s, --show [column|column,column,...]\n" + " -q, --quiet\n" + " skip decoding system configuration header\n" + " -s, --show [column | column,column,...]\n" " show only the specified column(s)\n" " -S, --Summary\n" " limits output to 1-line system summary per interval\n" " -T, --TCC temperature\n" " sets the Thermal Control Circuit temperature in\n" " degrees Celsius\n" - " -h, --help print this help message\n" - " -v, --version print version information\n" "\n" "For more help, run \"man turbostat\"\n"); + " -h, --help\n" + " print this help message\n" + " -v, --version\n" + " print version information\n" "\n" "For more help, run \"man turbostat\"\n"); } /* From patchwork Tue Dec 3 07:51:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 13891826 X-Patchwork-Delegate: lenb@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 55AA01C9B62; Tue, 3 Dec 2024 07:51:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733212285; cv=none; b=MIu3Y9SPY9481MaxIXS42MZ4qZ1QKRBd24DFDJlSqUjoijGLH+RcDFtca1punRHqKVIXYKK1WlT9X6kR2nCx+36kf/oAqsiHi1f0HsIsmAswdslNRbuVVMqEzHLvDgFQ3AE71zRiWhgEuYt4BA1/+6FujuitUcsZep18kdCHGO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733212285; c=relaxed/simple; bh=f4CC0b0D5MIZ2ZEL/VKxCZPBavAVHtWJayN/GtBBJlc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rr/SXTBGDg1e5ZJBSqCTtvunLnACxC+S/KZz8YdF3pJLcbk+3gVUys/oSe9JA3A5ptHqEyJF6yfdszGyKiPaeXAJLCQ8V8rIgl1xrDAzNoqRCYjw5AHefIW2S3POqH0smkbjalgUB8cfKYPR4lIrgpWWuWT+exFeYnJknu50I2Q= 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=l/+NMBRl; arc=none smtp.client-ip=198.175.65.10 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="l/+NMBRl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733212284; x=1764748284; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f4CC0b0D5MIZ2ZEL/VKxCZPBavAVHtWJayN/GtBBJlc=; b=l/+NMBRltXnXbAx5EQYtIkWW0jhTVAhSFgzI424nyEBeoqp4hlA4ihBW e28eyVp985of987VFc4yO5znwY6AfebolQg23lCJl24xuLRCUgPOPqGqC nASehSy+I2IFFhpXAhEUyqaPMmnRZXdkIwbdJfFVpRUtRzE+ogaXFi6PS SVysPR/p1JtItmtDHsWT9Xf+fTthIrNW4Nir1KiVtaAZ1I1R7Ik5ICVtt lYLo/bWdB/0G3r+AfHVtia4Fz7IImDKsNz8Yc4lI6eyfb7hWavzaH9JWu VsWgZBPkcqmyBaupBov1MxZwf721b3EcGsn+k66Dor2OdY3JRlObHXRno w==; X-CSE-ConnectionGUID: OTwwIMeUQB6WiK5dvCuLrg== X-CSE-MsgGUID: sn6Nu4OZSe+fPIRJZqzUyQ== X-IronPort-AV: E=McAfee;i="6700,10204,11274"; a="50822856" X-IronPort-AV: E=Sophos;i="6.12,204,1728975600"; d="scan'208";a="50822856" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2024 23:51:24 -0800 X-CSE-ConnectionGUID: 509+CLIETPujef2W0E6IAg== X-CSE-MsgGUID: YbZNBhVCTR2eCqkkqRDpMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,204,1728975600"; d="scan'208";a="124183040" Received: from rzhang1-mobl.sh.intel.com ([10.239.158.59]) by orviesa002.jf.intel.com with ESMTP; 02 Dec 2024 23:51:23 -0800 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 4/4] tools/power turbostat: Introduce --force parameter Date: Tue, 3 Dec 2024 15:51:19 +0800 Message-ID: <20241203075119.584419-5-rui.zhang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241203075119.584419-1-rui.zhang@intel.com> References: <20241203075119.584419-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 Turbostat currently exits under the following conditions: 1. When running on non-Intel/AMD/Hygon x86 vendors. 2. When running on Intel models that lack specific platform features. Introduce a new `--force` parameter that allows turbostat to run on these unsupported platforms with minimal default feature support. This provides users with the flexibility to gather basic information even on unsupported systems. Signed-off-by: Zhang Rui --- tools/power/x86/turbostat/turbostat.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 442a993c5114..123eb9ead7df 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -326,6 +326,7 @@ unsigned int rapl_joules; unsigned int summary_only; unsigned int list_header_only; unsigned int dump_only; +unsigned int force_load; unsigned int has_aperf; unsigned int has_aperf_access; unsigned int has_epb; @@ -1058,7 +1059,8 @@ void probe_platform_features(unsigned int family, unsigned int model) if (authentic_amd || hygon_genuine) { - platform = &default_features; + /* fallback to default features on unsupported models */ + force_load++; if (max_extended_level >= 0x80000007) { unsigned int eax, ebx, ecx, edx; @@ -1067,7 +1069,7 @@ void probe_platform_features(unsigned int family, unsigned int model) if ((edx & (1 << 14)) && family >= 0x17) platform = &amd_features_with_rapl; } - return; + goto end; } if (!genuine_intel) @@ -1081,10 +1083,16 @@ void probe_platform_features(unsigned int family, unsigned int model) } end: + if (force_load && !platform) { + fprintf(outf, "Unsupported platform detected. Force running with minimum default support.\n"); + platform = &default_features; + } + if (platform) return; fprintf(stderr, "Unsupported platform detected.\n" + "\tUse \"--force\" parameter to launch turbostat with minimum default support.\n" "\tTo get latest turbostat support, please contact\n" "\t lenb@kernel.org\n" "\tor pull from\n" @@ -2163,6 +2171,8 @@ void help(void) " displays the raw counter values\n" " -e, --enable [all | column]\n" " shows all or the specified disabled column\n" + " -f, --force\n" + " force load turbostat with minimum default features on unsupported platforms.\n" " -H, --hide [column | column,column,...]\n" " hide the specified column(s)\n" " -i, --interval sec.subsec\n" @@ -9945,6 +9955,7 @@ void cmdline(int argc, char **argv) { "Dump", no_argument, 0, 'D' }, { "debug", no_argument, 0, 'd' }, /* internal, not documented */ { "enable", required_argument, 0, 'e' }, + { "force", no_argument, 0, 'f' }, { "interval", required_argument, 0, 'i' }, { "IPC", no_argument, 0, 'I' }, { "num_iterations", required_argument, 0, 'n' }, @@ -10005,6 +10016,9 @@ void cmdline(int argc, char **argv) /* --enable specified counter */ bic_enabled = bic_enabled | bic_lookup(optarg, SHOW_LIST); break; + case 'f': + force_load++; + break; case 'd': debug++; ENABLE_BIC(BIC_DISABLED_BY_DEFAULT);