[v2,3/6] sched/fair: cleanup sched_use_asym_prio

Message ID 20240130131708.429425-3-alexs@kernel.org
State New
Headers
Series [v2,1/6] sched/fair: add SD_CLUSTER in comments |

Commit Message

alexs@kernel.org Jan. 30, 2024, 1:17 p.m. UTC
  From: Alex Shi <alexs@kernel.org>

And simplify the one line code. No function change.

Signed-off-by: Alex Shi <alexs@kernel.org>
To: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
To: Valentin Schneider <vschneid@redhat.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
To: Peter Zijlstra <peterz@infradead.org>
To: Ingo Molnar <mingo@redhat.com>
---
 kernel/sched/fair.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Ricardo Neri Feb. 1, 2024, 1:13 a.m. UTC | #1
On Tue, Jan 30, 2024 at 09:17:05PM +0800, alexs@kernel.org wrote:
> From: Alex Shi <alexs@kernel.org>
> 
> And simplify the one line code. No function change.
> 
> Signed-off-by: Alex Shi <alexs@kernel.org>
> To: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
> To: Valentin Schneider <vschneid@redhat.com>
> To: Vincent Guittot <vincent.guittot@linaro.org>
> To: Peter Zijlstra <peterz@infradead.org>
> To: Ingo Molnar <mingo@redhat.com>
> ---
>  kernel/sched/fair.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 8d70417f5125..ebd659af2d78 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9741,10 +9741,8 @@ group_type group_classify(unsigned int imbalance_pct,
>   */
>  static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)
>  {
> -	if (!sched_smt_active())
> -		return true;
> -
> -	return sd->flags & SD_SHARE_CPUCAPACITY || is_core_idle(cpu);
> +	return (!sched_smt_active()) ||
> +		(sd->flags & SD_SHARE_CPUCAPACITY) || is_core_idle(cpu);

I think that compressing the two conditions into one hurts readability.
As implemented, it is clear that no further checks are required if there
is no SMT.

Also, please see my comment in patch 6/6.
  
kuiliang Shi Feb. 1, 2024, 8:41 a.m. UTC | #2
On 2/1/24 9:13 AM, Ricardo Neri wrote:
> On Tue, Jan 30, 2024 at 09:17:05PM +0800, alexs@kernel.org wrote:
>> From: Alex Shi <alexs@kernel.org>
>>
>> And simplify the one line code. No function change.
>>
>> Signed-off-by: Alex Shi <alexs@kernel.org>
>> To: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
>> To: Valentin Schneider <vschneid@redhat.com>
>> To: Vincent Guittot <vincent.guittot@linaro.org>
>> To: Peter Zijlstra <peterz@infradead.org>
>> To: Ingo Molnar <mingo@redhat.com>
>> ---
>>  kernel/sched/fair.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 8d70417f5125..ebd659af2d78 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -9741,10 +9741,8 @@ group_type group_classify(unsigned int imbalance_pct,
>>   */
>>  static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)
>>  {
>> -	if (!sched_smt_active())
>> -		return true;
>> -
>> -	return sd->flags & SD_SHARE_CPUCAPACITY || is_core_idle(cpu);
>> +	return (!sched_smt_active()) ||
>> +		(sd->flags & SD_SHARE_CPUCAPACITY) || is_core_idle(cpu);
> 
> I think that compressing the two conditions into one hurts readability.

Sure, will remove this change.

Thanks
Alex

> As implemented, it is clear that no further checks are required if there
> is no SMT.
> 
> Also, please see my comment in patch 6/6.
>
  

Patch

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8d70417f5125..ebd659af2d78 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9741,10 +9741,8 @@  group_type group_classify(unsigned int imbalance_pct,
  */
 static bool sched_use_asym_prio(struct sched_domain *sd, int cpu)
 {
-	if (!sched_smt_active())
-		return true;
-
-	return sd->flags & SD_SHARE_CPUCAPACITY || is_core_idle(cpu);
+	return (!sched_smt_active()) ||
+		(sd->flags & SD_SHARE_CPUCAPACITY) || is_core_idle(cpu);
 }
 
 /**