Problem: It is undesirable for HT/MC packages to have more than one of their CPUs busy if there are other packages that have all of their CPUs idle. This involves moving the only running task (i.e. the one actually on the CPU) off on to another CPU and is achieved by using active_load_balance() and relying on the fact that (when it starts) the queue's migration thread will preempt the sole running task and (therefore) make it movable. The migration thread then moves it to an idle package. Unfortunately, the mechanism for setting the run queues active_balance flag is buried deep inside load_balance() and relies heavily on find_busiest_group() and find_busiest_queue() reporting success even if the busiest queue has only one task running. This requirement is not currently met. Solution: The long term solution to this problem is provide an alternative mechanism for triggering active load balancing for run queues that need it. However, in the meantime, this patch modifies find_busiest_group() so that (when idle != NEWLY_IDLE) it prefers groups with at least one CPU with more than one running task over those with only one and modifies find_busiest_queue() so that (when idle != NEWLY_IDLE) it prefers queues with more than one running task over those with only one. This means that the "busiest" queue found in load_balance() will only have one or less runnable tasks if there were no queues with more than one runnable task. When called in load_balance_newidle() they will have the existing functionality. These measure will prevent high load weight tasks that have a CPU to themselves from suppressing load balancing between other queues. NB This patch should be backed out when a proper fix for the problems inherit in HT and MC systems is implemented. Signed-off-by: Peter Williams Peter -- Peter Williams pwil3058@bigpond.net.au "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce