[RFC PATCH 10/23] sched/fair: Use classes of tasks when selecting a busiest runqueue

Ricardo Neri
2022-09-09T23:07:07Z

For two runqueues of equal priority and equal number of running of tasks,
select the one whose current task would have the highest task class score
if placed on the destination CPU.

Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim C. Chen <tim.c.chen@intel.com>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
kernel/sched/fair.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 7368a0b453ee..085b1f75d90b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10009,6 +10009,7 @@ static struct rq *find_busiest_queue(struct lb_env *env,
int i;

for_each_cpu_and(i, sched_group_span(group), env->cpus) {
+ int busiest_class_delta_score = INT_MIN;
unsigned long capacity, load, util;
unsigned int nr_running;
enum fbq_type rt;
@@ -10118,6 +10119,20 @@ static struct rq *find_busiest_queue(struct lb_env *env,
if (busiest_nr < nr_running) {
busiest_nr = nr_running;
busiest = rq;
+ } else if (sched_task_classes_enabled() &&
+ busiest_nr == nr_running) {
+ int curr_class_delta_score;
+
+ curr_class_delta_score = arch_get_task_class_score(rq->curr->class,
+ env->dst_cpu) -
+ arch_get_task_class_score(rq->curr->class,
+ cpu_of(rq));
+
+ if (busiest_class_delta_score < curr_class_delta_score) {
+ busiest_class_delta_score = curr_class_delta_score;
+ busiest_nr = nr_running;
+ busiest = rq;
+ }
}
break;

--
2.25.1