mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	sched/fair: Make sure to try to detach at least one movable task
During load balance, we try at most env->loop_max time to move a task. But it can happen that the loop_max LRU tasks (ie tail of the cfs_tasks list) can't be moved to dst_cpu because of affinity. In this case, loop in the list until we found at least one. The maximum of detached tasks remained the same as before. Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20220825122726.20819-2-vincent.guittot@linaro.org
This commit is contained in:
		
							parent
							
								
									fb04563d1c
								
							
						
					
					
						commit
						b0defa7ae0
					
				
					 1 changed files with 9 additions and 3 deletions
				
			
		| 
						 | 
					@ -8049,8 +8049,12 @@ static int detach_tasks(struct lb_env *env)
 | 
				
			||||||
		p = list_last_entry(tasks, struct task_struct, se.group_node);
 | 
							p = list_last_entry(tasks, struct task_struct, se.group_node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		env->loop++;
 | 
							env->loop++;
 | 
				
			||||||
		/* We've more or less seen every task there is, call it quits */
 | 
							/*
 | 
				
			||||||
		if (env->loop > env->loop_max)
 | 
							 * We've more or less seen every task there is, call it quits
 | 
				
			||||||
 | 
							 * unless we haven't found any movable task yet.
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							if (env->loop > env->loop_max &&
 | 
				
			||||||
 | 
							    !(env->flags & LBF_ALL_PINNED))
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* take a breather every nr_migrate tasks */
 | 
							/* take a breather every nr_migrate tasks */
 | 
				
			||||||
| 
						 | 
					@ -10179,6 +10183,8 @@ static int load_balance(int this_cpu, struct rq *this_rq,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (env.flags & LBF_NEED_BREAK) {
 | 
							if (env.flags & LBF_NEED_BREAK) {
 | 
				
			||||||
			env.flags &= ~LBF_NEED_BREAK;
 | 
								env.flags &= ~LBF_NEED_BREAK;
 | 
				
			||||||
 | 
								/* Stop if we tried all running tasks */
 | 
				
			||||||
 | 
								if (env.loop < busiest->nr_running)
 | 
				
			||||||
				goto more_balance;
 | 
									goto more_balance;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue