diff mbox series

[21/22] cpufreq: use cpumask_weight_gt() in policy_is_shared()

Message ID 20220510154750.212913-22-yury.norov@gmail.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series None | expand

Commit Message

Yury Norov May 10, 2022, 3:47 p.m. UTC
cpumask_weight_gt() is better than cpumask_weight() because it may
return earlier depending on condition.

CC: Rafael J. Wysocki <rafael@kernel.org>
CC: Viresh Kumar <viresh.kumar@linaro.org>
CC: linux-pm@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 include/linux/cpufreq.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Viresh Kumar May 11, 2022, 3:16 a.m. UTC | #1
On 10-05-22, 08:47, Yury Norov wrote:
> cpumask_weight_gt() is better than cpumask_weight() because it may
> return earlier depending on condition.
> 
> CC: Rafael J. Wysocki <rafael@kernel.org>
> CC: Viresh Kumar <viresh.kumar@linaro.org>
> CC: linux-pm@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> ---
>  include/linux/cpufreq.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index d5595d57f4e5..865cc9e23518 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -214,7 +214,7 @@ static inline bool policy_is_inactive(struct cpufreq_policy *policy)
>  
>  static inline bool policy_is_shared(struct cpufreq_policy *policy)
>  {
> -	return cpumask_weight(policy->cpus) > 1;
> +	return cpumask_weight_gt(policy->cpus, 1);
>  }
>  
>  #ifdef CONFIG_CPU_FREQ

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Though the patch to add cpumask_weight_gt() is still in linux-next and so this
patch should get merged after rc1 is out.

And it would have been nice to know of this dependency in the original mail
itself instead of me searching for it :)
diff mbox series

Patch

diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index d5595d57f4e5..865cc9e23518 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -214,7 +214,7 @@  static inline bool policy_is_inactive(struct cpufreq_policy *policy)
 
 static inline bool policy_is_shared(struct cpufreq_policy *policy)
 {
-	return cpumask_weight(policy->cpus) > 1;
+	return cpumask_weight_gt(policy->cpus, 1);
 }
 
 #ifdef CONFIG_CPU_FREQ