sched/fair: Use recent_used_cpu to test p->cpus_ptr

Message ID 20230620080747.359122-1-linmiaohe@huawei.com
State New
Headers
Series sched/fair: Use recent_used_cpu to test p->cpus_ptr |

Commit Message

Miaohe Lin June 20, 2023, 8:07 a.m. UTC
  When checking whether a recently used CPU can be a potential idle
candidate, recent_used_cpu should be used to test p->cpus_ptr as
p->recent_used_cpu is not equal to recent_used_cpu and candidate
decision is made based on recent_used_cpu here.

Fixes: 89aafd67f28c ("sched/fair: Use prev instead of new target as recent_used_cpu")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Phil Auld June 20, 2023, 5:49 p.m. UTC | #1
On Tue, Jun 20, 2023 at 04:07:47PM +0800 Miaohe Lin wrote:
> When checking whether a recently used CPU can be a potential idle
> candidate, recent_used_cpu should be used to test p->cpus_ptr as
> p->recent_used_cpu is not equal to recent_used_cpu and candidate
> decision is made based on recent_used_cpu here.
> 
> Fixes: 89aafd67f28c ("sched/fair: Use prev instead of new target as recent_used_cpu")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  kernel/sched/fair.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 7666dbc2b788..3cc06cfca350 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7156,7 +7156,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
>  	    recent_used_cpu != target &&
>  	    cpus_share_cache(recent_used_cpu, target) &&
>  	    (available_idle_cpu(recent_used_cpu) || sched_idle_cpu(recent_used_cpu)) &&
> -	    cpumask_test_cpu(p->recent_used_cpu, p->cpus_ptr) &&
> +	    cpumask_test_cpu(recent_used_cpu, p->cpus_ptr) &&
>  	    asym_fits_cpu(task_util, util_min, util_max, recent_used_cpu)) {
>  		return recent_used_cpu;
>  	}
> -- 
> 2.27.0
> 

This looks correct to me.

Reviewed-by: Phil Auld <pauld@redhat.com>


--
  
Mel Gorman June 21, 2023, 10:19 a.m. UTC | #2
On Tue, Jun 20, 2023 at 04:07:47PM +0800, Miaohe Lin wrote:
> When checking whether a recently used CPU can be a potential idle
> candidate, recent_used_cpu should be used to test p->cpus_ptr as
> p->recent_used_cpu is not equal to recent_used_cpu and candidate
> decision is made based on recent_used_cpu here.
> 
> Fixes: 89aafd67f28c ("sched/fair: Use prev instead of new target as recent_used_cpu")

Acked-by: Mel Gorman <mgorman@suse.de>
  
Peter Zijlstra June 21, 2023, 11:32 a.m. UTC | #3
On Wed, Jun 21, 2023 at 11:19:15AM +0100, Mel Gorman wrote:
> On Tue, Jun 20, 2023 at 04:07:47PM +0800, Miaohe Lin wrote:
> > When checking whether a recently used CPU can be a potential idle
> > candidate, recent_used_cpu should be used to test p->cpus_ptr as
> > p->recent_used_cpu is not equal to recent_used_cpu and candidate
> > decision is made based on recent_used_cpu here.
> > 
> > Fixes: 89aafd67f28c ("sched/fair: Use prev instead of new target as recent_used_cpu")
> 
> Acked-by: Mel Gorman <mgorman@suse.de>

Thanks!
  

Patch

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 7666dbc2b788..3cc06cfca350 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7156,7 +7156,7 @@  static int select_idle_sibling(struct task_struct *p, int prev, int target)
 	    recent_used_cpu != target &&
 	    cpus_share_cache(recent_used_cpu, target) &&
 	    (available_idle_cpu(recent_used_cpu) || sched_idle_cpu(recent_used_cpu)) &&
-	    cpumask_test_cpu(p->recent_used_cpu, p->cpus_ptr) &&
+	    cpumask_test_cpu(recent_used_cpu, p->cpus_ptr) &&
 	    asym_fits_cpu(task_util, util_min, util_max, recent_used_cpu)) {
 		return recent_used_cpu;
 	}