sched/fair: Keep a fully_busy SMT sched group as busiest
authorRicardo Neri <ricardo.neri-calderon@linux.intel.com>
Thu, 6 Apr 2023 20:31:41 +0000 (13:31 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 8 May 2023 08:58:35 +0000 (10:58 +0200)
When comparing two fully_busy scheduling groups, keep the current busiest
group if it represents an SMT core. Tasks in such scheduling group share
CPU resources and need more help than tasks in a non-SMT fully_busy group.

Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Link: https://lore.kernel.org/r/20230406203148.19182-6-ricardo.neri-calderon@linux.intel.com
kernel/sched/fair.c

index 85ce249..4a9f040 100644 (file)
@@ -9619,10 +9619,22 @@ static bool update_sd_pick_busiest(struct lb_env *env,
                 * contention when accessing shared HW resources.
                 *
                 * XXX for now avg_load is not computed and always 0 so we
-                * select the 1st one.
+                * select the 1st one, except if @sg is composed of SMT
+                * siblings.
                 */
-               if (sgs->avg_load <= busiest->avg_load)
+
+               if (sgs->avg_load < busiest->avg_load)
                        return false;
+
+               if (sgs->avg_load == busiest->avg_load) {
+                       /*
+                        * SMT sched groups need more help than non-SMT groups.
+                        * If @sg happens to also be SMT, either choice is good.
+                        */
+                       if (sds->busiest->flags & SD_SHARE_CPUCAPACITY)
+                               return false;
+               }
+
                break;
 
        case group_has_spare: