diff mbox series

[v2,04/11] ACPI: CPPC: Drop check for non zero perf ratio

Message ID 20240903203701.2695040-5-superm1@kernel.org (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series Adjustments for preferred core detection | expand

Commit Message

Mario Limonciello Sept. 3, 2024, 8:36 p.m. UTC
From: Mario Limonciello <mario.limonciello@amd.com>

perf_ratio is a u64 and SCHED_CAPACITY_SCALE is a larg number.
Shifting by one will never have a zero value.

Drop the check.

Suggested-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 arch/x86/kernel/acpi/cppc.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Gautham R. Shenoy Sept. 5, 2024, 3 p.m. UTC | #1
On Tue, Sep 03, 2024 at 03:36:54PM -0500, Mario Limonciello wrote:
> From: Mario Limonciello <mario.limonciello@amd.com>
> 
> perf_ratio is a u64 and SCHED_CAPACITY_SCALE is a larg number.

s/larg/large

> Shifting by one will never have a zero value.
> 
> Drop the check.
> 
> Suggested-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Other than that, LGTM

Reviewed-by: Gautham R. Shenoy <gautham.sheoy@amd.com>

--
Thanks and Regards
gautham

> ---
>  arch/x86/kernel/acpi/cppc.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c
> index 660cfeb6384ba..e65c77afab318 100644
> --- a/arch/x86/kernel/acpi/cppc.c
> +++ b/arch/x86/kernel/acpi/cppc.c
> @@ -91,13 +91,8 @@ static void amd_set_max_freq_ratio(void)
>  		return;
>  	}
>  
> -	perf_ratio = div_u64(numerator * SCHED_CAPACITY_SCALE, nominal_perf);
>  	/* midpoint between max_boost and max_P */
> -	perf_ratio = (perf_ratio + SCHED_CAPACITY_SCALE) >> 1;
> -	if (!perf_ratio) {
> -		pr_debug("Non-zero highest/nominal perf values led to a 0 ratio\n");
> -		return;
> -	}
> +	perf_ratio = (div_u64(numerator * SCHED_CAPACITY_SCALE, nominal_perf) + SCHED_CAPACITY_SCALE) >> 1;
>  
>  	freq_invariance_set_perf_ratio(perf_ratio, false);
>  }
> -- 
> 2.43.0
>
diff mbox series

Patch

diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c
index 660cfeb6384ba..e65c77afab318 100644
--- a/arch/x86/kernel/acpi/cppc.c
+++ b/arch/x86/kernel/acpi/cppc.c
@@ -91,13 +91,8 @@  static void amd_set_max_freq_ratio(void)
 		return;
 	}
 
-	perf_ratio = div_u64(numerator * SCHED_CAPACITY_SCALE, nominal_perf);
 	/* midpoint between max_boost and max_P */
-	perf_ratio = (perf_ratio + SCHED_CAPACITY_SCALE) >> 1;
-	if (!perf_ratio) {
-		pr_debug("Non-zero highest/nominal perf values led to a 0 ratio\n");
-		return;
-	}
+	perf_ratio = (div_u64(numerator * SCHED_CAPACITY_SCALE, nominal_perf) + SCHED_CAPACITY_SCALE) >> 1;
 
 	freq_invariance_set_perf_ratio(perf_ratio, false);
 }