From patchwork Wed Dec 18 19:09:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13914056 X-Patchwork-Delegate: shuah@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C7D2A1FAC40 for ; Wed, 18 Dec 2024 19:12:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549125; cv=none; b=gQs2v+Fvgj05j3o6irprZPlWlK031QHp0JBKkUESf8px/xOiu4+8q8NOqeQTE8XDlKKYbFGB3Nfu1DBgzatPZc1ufmhspThsWYy9BqUR9BGn1vvjPvIJVmTgF/vljDgJ/L+JZlkXF+O8iOxc5wxZHwttfrJkbm0NHuuYWbuZiJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549125; c=relaxed/simple; bh=nMOaexMm3AD0X9zJdec41KmxIJRAJkYJSkmyOr+Dd+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bg2PO1MLSaI5wWHV3RXPsanqSOh1/Aftunv3+Cse+hlVOB9bDb7c+ZRGdm1cWEqMVpX/kTp7dQWVu9oT/Uh5t71cFf8fEb5e46uS90AufAxHQeLpkUtyguaB/Su8bBSteYTL49s0qf2NRKGLQqqkABSbJO4E2Ud5UHi67hkCJos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bbPTFGvW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bbPTFGvW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B007DC4CEDC; Wed, 18 Dec 2024 19:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734549125; bh=nMOaexMm3AD0X9zJdec41KmxIJRAJkYJSkmyOr+Dd+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bbPTFGvWFDCCMlDm3Pee3ukM5MmsrlC9/1OCOajcJLAbp0Ew66iBR1C98eN6B6XUI Cf+SWwn0rjsZXTGwuBCAcB4GdjjP1SSW9y81S+RWxhS+VU4f+hQ+wRsbSAKwyYDu2q lxXVLKUlY5egTLlxJE6S+fdncIz2fvcDEmtuPPmQeQ7ZXuyi2oPM13HYDu1zntMMb+ NoLFb4pBzZ02SGw0oldlmphHdMW/4fZP6KdcsS0L9ctvOXxyYD3lfI60nSh8NklYtT JpTO5EoAEdfiwkI4MYwTHbCu4VQ0OmQ26sMeD1JP9FGfav7Eh9tsqDvhrtJhyh8DTJ q3bKwEAAKDJfA== From: Mario Limonciello To: mario.limonciello@amd.com, trenn@suse.com, shuah@kernel.org, jwyatt@redhat.com, jkacur@redhat.com Cc: linux-pm@vger.kernel.org Subject: [PATCH 1/7] cpupower: Remove spurious return statement Date: Wed, 18 Dec 2024 13:09:50 -0600 Message-ID: <20241218191144.3440854-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218191144.3440854-1-superm1@kernel.org> References: <20241218191144.3440854-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello print_duration() has a return; statement at the end of the function that is not necessary as it's a void function. Signed-off-by: Mario Limonciello --- tools/power/cpupower/utils/cpufreq-info.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index c96b77365c637..5f092f3c729e7 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -120,7 +120,6 @@ static void print_duration(unsigned long duration) } else printf("%lu ns", duration); } - return; } static int get_boost_mode_x86(unsigned int cpu) From patchwork Wed Dec 18 19:09:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13914057 X-Patchwork-Delegate: shuah@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A1A021FAC40 for ; Wed, 18 Dec 2024 19:12:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549126; cv=none; b=uzEEjFNWAxtDPrA+d0OBHu+hMtVIU2uvrK1NFTT08tKfc1qTKcHTE9zxkpMDcE41b+7/xD8Gk0fxzgK6IWTF0DIR957uAz5pZoEq7lPrr5UGMM0LKPYA8pk/06XRFBKHe1HIuLqPo1EnZY9Axdc3nGDH7KnZ05n657XYQQoGMk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549126; c=relaxed/simple; bh=+HpnK1/8zAyOotqNrpnCyj2V09vsKx8pA30RMzSTFdg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E9zg1Iw6cf62eu42BjdZ7W0hUWafnJrBqTM+yDC/NnnJfg3MltK1IB0qKcQLo5aIaRbeUzZKxBHZm3tOSLFOUzyO06HmdZbiiTe3Qd+Tfx/dendX+5BiXlSXSPfZOgbAu+ZIF4u6WDZCyGtxxywXIP2xcXitMOqO8FwZTnyO+Oc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Yb9g6hyV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Yb9g6hyV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2EF5C4CECD; Wed, 18 Dec 2024 19:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734549126; bh=+HpnK1/8zAyOotqNrpnCyj2V09vsKx8pA30RMzSTFdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yb9g6hyV8lT1J3oie20Tx7TTZn9xUVncCnGO0jw6WiNMFFFQCjRmwnb/18AEeZV8w /LfaPXI5VWbILZgYIV+LbdSWaJDinLDhFwMwXvaWGxxUj4jIC03RCXDv24QvroG2r/ orGeEoKjBgpann40/UHoNvtCEkb5duwDsaCo7ER0wLNQRSXEFLFcwhqWnKgYhQePL+ XXVXAX2rWHG7yMEuPGJNpCT888aHUM76cx9Gxd95mM9rjsMWAqfFk7drZRr30p68x5 zmCGgDffQVyOeKyleJhoBsjtGO8BH4aa32P+qVlJx6MRjZL8O79kHh1r66KuRtMsrW yG/RSaDH/I9MQ== From: Mario Limonciello To: mario.limonciello@amd.com, trenn@suse.com, shuah@kernel.org, jwyatt@redhat.com, jkacur@redhat.com Cc: linux-pm@vger.kernel.org Subject: [PATCH 2/7] cpupower: Add support for parsing 'enabled' or 'disabled' strings from table Date: Wed, 18 Dec 2024 13:09:51 -0600 Message-ID: <20241218191144.3440854-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218191144.3440854-1-superm1@kernel.org> References: <20241218191144.3440854-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello When cpufreq_get_sysfs_value_from_table() is passed a table with kernel strings that report 'enabled' or 'disabled' it always returns 0 because these can't cleanly convert to integers. Explicitly look for enabled or disabled strings from the kernel to handle this. Signed-off-by: Mario Limonciello --- tools/power/cpupower/lib/cpufreq.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c index 1516d23c17c98..f27ee6d4b000c 100644 --- a/tools/power/cpupower/lib/cpufreq.c +++ b/tools/power/cpupower/lib/cpufreq.c @@ -102,6 +102,10 @@ unsigned long cpufreq_get_sysfs_value_from_table(unsigned int cpu, if (len == 0) return 0; + if (!strcmp(linebuf, "enabled\n")) + return 1; + if (!strcmp(linebuf, "disabled\n")) + return 0; value = strtoul(linebuf, &endp, 0); if (endp == linebuf || errno == ERANGE) From patchwork Wed Dec 18 19:09:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13914058 X-Patchwork-Delegate: shuah@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BBFCE1FAC40 for ; Wed, 18 Dec 2024 19:12:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549127; cv=none; b=Ue/CKbQhhU4+eWxaP3Mj9pFPzZK7OXYx8b1HNzN+qjS0/exo14iaF+Mces2vFYfF1hlNGEaOT2tn3za0sY03gjyL680h9E/j5kcfSsnkk5gTT1FX0iOpa/Qf/IptKiIONoYJqroULACcXzf7OcuDOPu9Qu5nARqYtKY0i2/AXe8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549127; c=relaxed/simple; bh=CuUZg4845wczGJgTn9sPWKeN9Z7IQqRUSZ9Dsp6GVx4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QkhMjwMKcT8fosm5zwQSbGzvPdb2XfEPgkKIwJFL7u+wC6nwBM5gbEp5Xw/Tm9V1ap9OJVTAC0bjegIL66NnrHbNiulwskGPpjXqzOWLv2vdlqLjH7aVK7UGlejFna19GjYctOiS0l4gl21aDpLLuV2qlv0RkMB+RhvkkTLpITo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RXck5TcL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RXck5TcL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91496C4CEDC; Wed, 18 Dec 2024 19:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734549127; bh=CuUZg4845wczGJgTn9sPWKeN9Z7IQqRUSZ9Dsp6GVx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RXck5TcLNHy1GTjdO9CU4UNfnC+dvvII5mJRWHFysjTA+aLMLaEGDJjZgYQHRO5Ce XKsqU5xm1yrjsjbz7AwNSz+dAiPNS2Q6lko8gNffbX4iYkPjvFGQx/XRCqduUtx/gs OdEq0HdYFsDjZTnypG1RAk/QLdXNy2Pfuo+N9UH5Q5DrhOoWLZuQrdFOsKUIoIq09n Ey3T8S52gZtQ3GqfKpmD3Fj3r9XangkIqGuJ+ksFQCOruBXFvMe8kTG1BWzrIWt3gZ ucEfKs0rZIzSEvD/memQLVBCrsTQjUeItbwi3JMDFaMvk/q/8MhMSZbfNTykdM0XZN H6ZnA/jch3t6g== From: Mario Limonciello To: mario.limonciello@amd.com, trenn@suse.com, shuah@kernel.org, jwyatt@redhat.com, jkacur@redhat.com Cc: linux-pm@vger.kernel.org Subject: [PATCH 3/7] cpupower: Add support for amd-pstate preferred core rankings Date: Wed, 18 Dec 2024 13:09:52 -0600 Message-ID: <20241218191144.3440854-4-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218191144.3440854-1-superm1@kernel.org> References: <20241218191144.3440854-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello The rankings are useful information to determine if the scheduler is placing tasks appropriately for the hardware. Signed-off-by: Mario Limonciello --- tools/power/cpupower/utils/helpers/amd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index 0a56e22240fc8..090fdd6d15510 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -177,6 +177,8 @@ enum amd_pstate_value { AMD_PSTATE_HIGHEST_PERF, AMD_PSTATE_MAX_FREQ, AMD_PSTATE_LOWEST_NONLINEAR_FREQ, + AMD_PSTATE_HW_PREFCORE, + AMD_PSTATE_PREFCORE_RANKING, MAX_AMD_PSTATE_VALUE_READ_FILES, }; @@ -184,6 +186,8 @@ static const char *amd_pstate_value_files[MAX_AMD_PSTATE_VALUE_READ_FILES] = { [AMD_PSTATE_HIGHEST_PERF] = "amd_pstate_highest_perf", [AMD_PSTATE_MAX_FREQ] = "amd_pstate_max_freq", [AMD_PSTATE_LOWEST_NONLINEAR_FREQ] = "amd_pstate_lowest_nonlinear_freq", + [AMD_PSTATE_HW_PREFCORE] = "amd_pstate_hw_prefcore", + [AMD_PSTATE_PREFCORE_RANKING] = "amd_pstate_prefcore_ranking", }; static unsigned long amd_pstate_get_data(unsigned int cpu, @@ -240,6 +244,10 @@ void amd_pstate_show_perf_and_freq(unsigned int cpu, int no_rounding) acpi_cppc_get_data(cpu, LOWEST_PERF)); print_speed(acpi_cppc_get_data(cpu, LOWEST_FREQ) * 1000, no_rounding); printf(".\n"); + + printf(_(" Preferred Core Support: %lu. Preferred Core Ranking: %lu.\n"), + amd_pstate_get_data(cpu, AMD_PSTATE_HW_PREFCORE), + amd_pstate_get_data(cpu, AMD_PSTATE_PREFCORE_RANKING)); } /* AMD P-State Helper Functions ************************************/ From patchwork Wed Dec 18 19:09:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13914059 X-Patchwork-Delegate: shuah@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DD7D41FAC40 for ; Wed, 18 Dec 2024 19:12:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549128; cv=none; b=p31GIQ7GW5fYhLBOHw5tQgf1antCSvFcU9Wdf+mTYPJ+iQpaj6husZPXFD3sd0ZO/26BP9qk2xWqLU2R2NkfH3yUiFCaa8JwKa2c9eXoeVqX+XGajvyVTOF4yQLzSQCFnJUgJJ04m/Ed608qppP+K9kM6cBp99pQdv8X5fKVEP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549128; c=relaxed/simple; bh=4oO1EcVm33bIsq/HWyN5rzW7cr4ThZfhyYM7ahaK10M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jb4K0PKfqnEJUwiimiI6CtSwPnI3VGZ+M7pPQUuX9G9PZP8c58EmADqN9ZZMKW3FKSEEznPM0Nst0ZcpqvSCohoWnHTpoQbPvrzka0Ix7RPWkbYUpGMMb5uKOTJNFyD3GuOiy/zogpjUSz+qrD/5q23ccG4YhdcWCzn2YXZEbSc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pAmhhtVM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pAmhhtVM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BA3FC4CED7; Wed, 18 Dec 2024 19:12:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734549128; bh=4oO1EcVm33bIsq/HWyN5rzW7cr4ThZfhyYM7ahaK10M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pAmhhtVM+HllD+p/erPDLVUjSNIXpCN1Fhr79caMM7mZKA0CKSLyBGhjh4gW90b++ wInXOZbYJbEof1+IJMTG85qMrQ6VRqwCHLKuLM28QVeheuX1601NwwDyyYl+Mm+dQd PGHqLbH/+jyaPI39T6ypRTizk2COVlEqLKqWuRWlbSwo2z/GBFTkrI5wHbYAu0cDGP MUqPapZiEvv5kD1BmrmQt9sS+Z426z1SfDCdSFWXoiIPKFYmYbb0hbLFes00ltWktm brzfDqfxzSMDPuiIN/AFFMcDtwDfGOSKYWm7jPLOxOi1aNhu2dH635fIhPfmHBBPju YUZKkIOlrlAug== From: Mario Limonciello To: mario.limonciello@amd.com, trenn@suse.com, shuah@kernel.org, jwyatt@redhat.com, jkacur@redhat.com Cc: linux-pm@vger.kernel.org Subject: [PATCH 4/7] cpupower: Don't try to read frequency from hardware when kernel uses aperfmperf Date: Wed, 18 Dec 2024 13:09:53 -0600 Message-ID: <20241218191144.3440854-5-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218191144.3440854-1-superm1@kernel.org> References: <20241218191144.3440854-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello When the amd-pstate is in use frequency is set by the hardware and measured by the kernel through using the aperf and mperf registers. There is no direct call to the hardware to indicate current frequency. Detect that this feature is in use and skip the check. Signed-off-by: Mario Limonciello --- tools/power/cpupower/utils/cpufreq-info.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index 5f092f3c729e7..3df28e45be421 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -254,7 +254,12 @@ static int get_freq_kernel(unsigned int cpu, unsigned int human) static int get_freq_hardware(unsigned int cpu, unsigned int human) { - unsigned long freq = cpufreq_get_freq_hardware(cpu); + unsigned long freq; + + if (cpupower_cpu_info.caps & CPUPOWER_CAP_APERF) + return -EINVAL; + + freq = cpufreq_get_freq_hardware(cpu); printf(_(" current CPU frequency: ")); if (!freq) { printf("Unable to call hardware\n"); From patchwork Wed Dec 18 19:09:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13914060 X-Patchwork-Delegate: shuah@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DA1771FAC40 for ; Wed, 18 Dec 2024 19:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549129; cv=none; b=hqSPEjFbOcf3AqUUU+jUZp43v+TyGvG+f98bEg200hkIDYaBzFX1uU/E2Iy+l2/2xeB0WippkZS2XptGuHoRWlA62X5p/C4c8LRGge7lbtbtBDDhPxr2ls+OBenHjk9Igl7gym3XgXZWgPRwDM9Ddmj4Pf5dHcSCRe7TVpIsxMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549129; c=relaxed/simple; bh=RBlJn7kJazVA2Z7Y7DdRGx8zUnRq8xka3qeIQ7oNXXQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iWcWh3XRTcvKaJHpjwX0M2rFUFkNhA12ao7cp/iTCsJvQsWpwaWNwukjlwZ1RWT7WwVnmGhmWAu8iAgPqUmC5B2MO30Om9XyzMH2MMmdFVWoPo0dDXhqqGNe1P5/zUIPvZjel8FnnIne7El7xXxBRZ6JWQ9+bAL3WBvk0ZXutUs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qJ+MlRtA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qJ+MlRtA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC8DFC4CECD; Wed, 18 Dec 2024 19:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734549129; bh=RBlJn7kJazVA2Z7Y7DdRGx8zUnRq8xka3qeIQ7oNXXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qJ+MlRtA11Dx0Ptk9nRGDhC1rq5feKTm1tzlmbB/zrBuMOjZ0Dn1iCFiYvSTCVjGm sLWMkpWKip6/8u0E7TvePFMOoeObc6AsweqFN/dw1LzCi9EmqK+CsiTkKbvZuUul7v aCotTCQK9ek8R3RCC6Yt3QlPMSEsGfk3Mbrrjv/WkK0/aKJvEnonsqKjA66eygk1XF CWw+xhBGYfz7sbnl3TKeDXxsvxK3JeCROWQMV+2drg70I2VZm3GUb/nce3TbCIHB2O DDQObWLyty362TgdpiOA/R8iBUFiQKkl9FOGECWkbAJR0usxKw6WP+WkFSdnxkz5NT 3LGH7mx1q4xjQ== From: Mario Limonciello To: mario.limonciello@amd.com, trenn@suse.com, shuah@kernel.org, jwyatt@redhat.com, jkacur@redhat.com Cc: linux-pm@vger.kernel.org Subject: [PATCH 5/7] cpupower: Add support for showing energy performance preference Date: Wed, 18 Dec 2024 13:09:54 -0600 Message-ID: <20241218191144.3440854-6-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218191144.3440854-1-superm1@kernel.org> References: <20241218191144.3440854-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello The EPP value is useful for characterization of performance. Show it in cpupower frequency-info output. Signed-off-by: Mario Limonciello --- tools/power/cpupower/lib/cpufreq.c | 14 +++++++++++++ tools/power/cpupower/lib/cpufreq.h | 8 ++++++++ tools/power/cpupower/utils/cpufreq-info.c | 25 ++++++++++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c index f27ee6d4b000c..8dda3db2dff0e 100644 --- a/tools/power/cpupower/lib/cpufreq.c +++ b/tools/power/cpupower/lib/cpufreq.c @@ -127,12 +127,14 @@ static unsigned long sysfs_cpufreq_get_one_value(unsigned int cpu, enum cpufreq_string { SCALING_DRIVER, SCALING_GOVERNOR, + ENERGY_PERFORMANCE_PREFERENCE, MAX_CPUFREQ_STRING_FILES }; static const char *cpufreq_string_files[MAX_CPUFREQ_STRING_FILES] = { [SCALING_DRIVER] = "scaling_driver", [SCALING_GOVERNOR] = "scaling_governor", + [ENERGY_PERFORMANCE_PREFERENCE] = "energy_performance_preference", }; @@ -207,6 +209,18 @@ unsigned long cpufreq_get_transition_latency(unsigned int cpu) return sysfs_cpufreq_get_one_value(cpu, CPUINFO_LATENCY); } +char *cpufreq_get_energy_performance_preference(unsigned int cpu) +{ + return sysfs_cpufreq_get_one_string(cpu, ENERGY_PERFORMANCE_PREFERENCE); +} + +void cpufreq_put_energy_performance_preference(char *ptr) +{ + if (!ptr) + return; + free(ptr); +} + int cpufreq_get_hardware_limits(unsigned int cpu, unsigned long *min, unsigned long *max) diff --git a/tools/power/cpupower/lib/cpufreq.h b/tools/power/cpupower/lib/cpufreq.h index 2f3c840358063..bfc617311ebd6 100644 --- a/tools/power/cpupower/lib/cpufreq.h +++ b/tools/power/cpupower/lib/cpufreq.h @@ -68,6 +68,14 @@ unsigned long cpufreq_get_freq_hardware(unsigned int cpu); unsigned long cpufreq_get_transition_latency(unsigned int cpu); +/* determine energy performance preference + * + * returns NULL on failure, else the string that represents the energy performance + * preference requested. + */ +char *cpufreq_get_energy_performance_preference(unsigned int cpu); +void cpufreq_put_energy_performance_preference(char *ptr); + /* determine hardware CPU frequency limits * * These may be limited further by thermal, energy or other diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index 3df28e45be421..eb9cc0f106342 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -422,6 +422,23 @@ static int get_freq_stats(unsigned int cpu, unsigned int human) return 0; } +/* --epp / -z */ + +static int get_epp(unsigned int cpu, bool interactive) +{ + char *epp; + + epp = cpufreq_get_energy_performance_preference(cpu); + if (!epp) + return -EINVAL; + if (interactive) + printf(_(" energy performance preference: %s\n"), epp); + + cpufreq_put_energy_performance_preference(epp); + + return 0; +} + /* --latency / -y */ static int get_latency(unsigned int cpu, unsigned int human) @@ -461,6 +478,7 @@ static void debug_output_one(unsigned int cpu) get_related_cpus(cpu); get_affected_cpus(cpu); get_latency(cpu, 1); + get_epp(cpu, true); get_hardware_limits(cpu, 1); freqs = cpufreq_get_available_frequencies(cpu); @@ -501,6 +519,7 @@ static struct option info_opts[] = { {"human", no_argument, NULL, 'm'}, {"no-rounding", no_argument, NULL, 'n'}, {"performance", no_argument, NULL, 'c'}, + {"epp", no_argument, NULL, 'z'}, { }, }; @@ -514,7 +533,7 @@ int cmd_freq_info(int argc, char **argv) int output_param = 0; do { - ret = getopt_long(argc, argv, "oefwldpgrasmybnc", info_opts, + ret = getopt_long(argc, argv, "oefwldpgrasmybncz", info_opts, NULL); switch (ret) { case '?': @@ -538,6 +557,7 @@ int cmd_freq_info(int argc, char **argv) case 's': case 'y': case 'c': + case 'z': if (output_param) { output_param = -1; cont = 0; @@ -647,6 +667,9 @@ int cmd_freq_info(int argc, char **argv) case 'c': ret = get_perf_cap(cpu); break; + case 'z': + ret = get_epp(cpu, true); + break; } if (ret) return ret; From patchwork Wed Dec 18 19:09:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13914061 X-Patchwork-Delegate: shuah@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AFCDC1FAC40 for ; Wed, 18 Dec 2024 19:12:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549130; cv=none; b=a1+YED9VR0OYomz8oFNgvgG3CFAYdaV/SIumx5rCINSQW+7s3v9yXtX/UbKlClDUsmNbGQA6R+arorGZjM5CwU7pAO3K1se8+6taLxZPTWgbPtciAbPjZQXMnSNJjpOTkDKnLmvmA0zdY06B7bhNxSoak2o7xoDMXC6mC7uExAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549130; c=relaxed/simple; bh=FNAns3HGMMiWJClk3bjmuwwnGyxHx+RxRdEcce09HEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HhU+TRVRYHcRXjqN5G0KYgJx36Km6NHsT4LDq8Bz7PrRuCnZQ7GI3iS3u9Nr//shZmgVyonbT7kJvRn6oSrVKn1Q4nWTniVo5m+e0vGMm06Hw8VeaWopsiY4VVgVRGympZinjmPPD6GxrVMOtYmzEZa8OOhbJLJouoo/VyqWAo4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oIIVIMKc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oIIVIMKc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A367AC4CED7; Wed, 18 Dec 2024 19:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734549130; bh=FNAns3HGMMiWJClk3bjmuwwnGyxHx+RxRdEcce09HEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oIIVIMKcOBjKJLTcQ9CFKQUzdqe7+qW64kxViY3ltpZhm3/66RLSsAoUq84a4UM1m rMarLkSqLvQb/Urb7yh3vv1v2NMq2gEiDbICgPjX1dYlbhMs2xbPKu7/C1BV2NDxf9 OKlxlzz8xOfFZdTD3uy6ZBfY0m5TJ5qGuTMvKIGvgD08vNYoZLPT/CFfqPBFkj79VS cAxzScRso+kxR3Wwr64k47GEMYaLayiAUi/qjWcUkFawQTeN0ZRfQVcrSKUmQeKDd3 E+tLY5ODj5c9UV6Hbie+vKipmw0zOQFgEQ0j9e0VhMd0nYgEJ5X2qBv+3f6XZP7Gqv ja39tiK+ASYbA== From: Mario Limonciello To: mario.limonciello@amd.com, trenn@suse.com, shuah@kernel.org, jwyatt@redhat.com, jkacur@redhat.com Cc: linux-pm@vger.kernel.org Subject: [PATCH 6/7] cpupower: Don't fetch maximum latency when EPP is enabled Date: Wed, 18 Dec 2024 13:09:55 -0600 Message-ID: <20241218191144.3440854-7-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218191144.3440854-1-superm1@kernel.org> References: <20241218191144.3440854-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello When EPP has been enabled the hardware will autonomously change frequencies on it's own and thus there is no latency with changing from the kernel. Avoid doing the maximum latency check when EPP is found. This will apply to both amd-pstate and intel-pstate drivers. Signed-off-by: Mario Limonciello --- tools/power/cpupower/utils/cpufreq-info.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index eb9cc0f106342..fc750e127404c 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -445,6 +445,9 @@ static int get_latency(unsigned int cpu, unsigned int human) { unsigned long latency = cpufreq_get_transition_latency(cpu); + if (!get_epp(cpu, false)) + return -EINVAL; + printf(_(" maximum transition latency: ")); if (!latency || latency == UINT_MAX) { printf(_(" Cannot determine or is not supported.\n")); From patchwork Wed Dec 18 19:09:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13914062 X-Patchwork-Delegate: shuah@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A6D8A1FAC40 for ; Wed, 18 Dec 2024 19:12:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549131; cv=none; b=mHiTm1mtGlIxeDSG6vEYYLVbiKOWBOWV8biy9XaJEYuTvYZJekhCJQzc54bNbvmrc6TNXdNnBt86dj2LnQLfAyYsu3MUgK4LW5qMjLR3TRxzS/Xf+NaTcViQfW2raiv/U6R94S/dh3HZJPilOI4FOV6Bk/CsNU2u6o5RrxWiuGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734549131; c=relaxed/simple; bh=DrB2+b+1jQ9/2cQwpSUJx0otoaYdhEjQwLycpVXD0j0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=evrFcMofL/SXYleOg6jwhRFTpLg3mbhUcM9fjXuL4QPUugBKmNYIGTIYhom/1zOWXvEpeRwV0E6hFAeko78ao5ci1RlATxCT9lTwkSHHSVmk+iunEtB1t5nh1+la9amG3+oh+haDxXp0BHbcy9XQnBCy6NhQE7L17jkhyKm5kj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pjEjB0WR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pjEjB0WR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BBAAC4CEDC; Wed, 18 Dec 2024 19:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734549131; bh=DrB2+b+1jQ9/2cQwpSUJx0otoaYdhEjQwLycpVXD0j0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pjEjB0WR8nTJpIk/+rSEKe1RZJmYxsxFwSg/7+TY1wD8BOj5WJHliOYJld8IcWcyJ KKiAc8oRoUIv773TrQIH7kjiEQfXcwgUggQ/F96vuhJGPA3Do7iAchULKgg123pDcb q12KieoYNbjK2JE/SdLr0yM3mgXMmct8C+EiRl6ckOkoLflbd/gn/iaxlSyOj5Fld6 ShHAyaUaSuL7KpPM/qHka9zoHwJSoWwqEtzcWzmTb9FoDq/xEoFR1wtXu5pYdv5j4j R44QUNtS2jec44sNb7/MN/5p4NsqHMj7h0heoVnP35ePZknIkmb+YQUxJmF4jZA9BH wr9eU2xJf7KbA== From: Mario Limonciello To: mario.limonciello@amd.com, trenn@suse.com, shuah@kernel.org, jwyatt@redhat.com, jkacur@redhat.com Cc: linux-pm@vger.kernel.org Subject: [PATCH 7/7] cpupower: Adjust whitespace for amd-pstate specific prints Date: Wed, 18 Dec 2024 13:09:56 -0600 Message-ID: <20241218191144.3440854-8-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218191144.3440854-1-superm1@kernel.org> References: <20241218191144.3440854-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello The amd-pstate section is grouped under boost, which isn't appropriate. Adjust the indentation so that it is it's own section. Signed-off-by: Mario Limonciello --- tools/power/cpupower/utils/helpers/amd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index 090fdd6d15510..795562e879dee 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -219,7 +219,9 @@ void amd_pstate_boost_init(unsigned int cpu, int *support, int *active) void amd_pstate_show_perf_and_freq(unsigned int cpu, int no_rounding) { - printf(_(" AMD PSTATE Highest Performance: %lu. Maximum Frequency: "), + + printf(_(" amd-pstate limits:\n")); + printf(_(" Highest Performance: %lu. Maximum Frequency: "), amd_pstate_get_data(cpu, AMD_PSTATE_HIGHEST_PERF)); /* * If boost isn't active, the cpuinfo_max doesn't indicate real max @@ -228,19 +230,19 @@ void amd_pstate_show_perf_and_freq(unsigned int cpu, int no_rounding) print_speed(amd_pstate_get_data(cpu, AMD_PSTATE_MAX_FREQ), no_rounding); printf(".\n"); - printf(_(" AMD PSTATE Nominal Performance: %lu. Nominal Frequency: "), + printf(_(" Nominal Performance: %lu. Nominal Frequency: "), acpi_cppc_get_data(cpu, NOMINAL_PERF)); print_speed(acpi_cppc_get_data(cpu, NOMINAL_FREQ) * 1000, no_rounding); printf(".\n"); - printf(_(" AMD PSTATE Lowest Non-linear Performance: %lu. Lowest Non-linear Frequency: "), + printf(_(" Lowest Non-linear Performance: %lu. Lowest Non-linear Frequency: "), acpi_cppc_get_data(cpu, LOWEST_NONLINEAR_PERF)); print_speed(amd_pstate_get_data(cpu, AMD_PSTATE_LOWEST_NONLINEAR_FREQ), no_rounding); printf(".\n"); - printf(_(" AMD PSTATE Lowest Performance: %lu. Lowest Frequency: "), + printf(_(" Lowest Performance: %lu. Lowest Frequency: "), acpi_cppc_get_data(cpu, LOWEST_PERF)); print_speed(acpi_cppc_get_data(cpu, LOWEST_FREQ) * 1000, no_rounding); printf(".\n");