Messages in this thread Patch in this message | | | From | Ricardo Neri <> | Subject | [RFC PATCH 09/23] sched/fair: Use task-class performance score to pick the busiest group | Date | Fri, 9 Sep 2022 16:11:51 -0700 |
| |
update_sd_pick_busiest() keeps on selecting as the busiest group scheduling groups of identical priority. Since both groups have the same priority, either group is a good choice. The classes of tasks in the scheduling groups can break this tie.
Pick as busiest the scheduling group that yields a higher task-class performance score after load balancing.
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 | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 97731f81b570..7368a0b453ee 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8777,6 +8777,60 @@ static void compute_ilb_sg_task_class_scores(struct sg_lb_task_class_stats *clas sgs->task_class_score_before = group_score; } +/** + * sched_asym_class_prefer - Select a sched group based on its classes of tasks + * @a: Load balancing statistics of @sg_a + * @b: Load balancing statistics of @sg_b + * + * Returns: true if preferring @a yields a higher overall throughput after + * balancing load. Returns false otherwise. + */ +static bool sched_asym_class_prefer(struct sg_lb_stats *a, + struct sg_lb_stats *b) +{ + if (!sched_task_classes_enabled()) + return false; + + /* @a increases overall throughput after load balance. */ + if (a->task_class_score_after > b->task_class_score_after) + return true; + + /* + * If @a and @b yield the same overall throughput, pick @a if + * its current throughput is lower than that of @b. + */ + if (a->task_class_score_after == b->task_class_score_after) + return a->task_class_score_before < b->task_class_score_before; + + return false; +} + +/** + * sched_asym_class_pick - Select a sched group based on classes of tasks + * @a: A scheduling group + * @b: A second scheduling group + * @a_stats: Load balancing statistics of @a + * @b_stats: Load balancing statistics of @b + * + * Returns: true if @a has the same priority and @a has classes of tasks that + * yield higher overall throughput after load balance. Returns false otherwise. + */ +static bool sched_asym_class_pick(struct sched_group *a, + struct sched_group *b, + struct sg_lb_stats *a_stats, + struct sg_lb_stats *b_stats) +{ + /* + * Only use the class-specific preference selection if both sched + * groups have the same priority. + */ + if (arch_asym_cpu_priority(a->asym_prefer_cpu) != + arch_asym_cpu_priority(b->asym_prefer_cpu)) + return false; + + return sched_asym_class_prefer(a_stats, b_stats); +} + #else /* CONFIG_SCHED_TASK_CLASSES */ static void update_rq_task_classes_stats(struct sg_lb_task_class_stats *class_sgs, struct rq *rq) @@ -8793,6 +8847,14 @@ static void compute_ilb_sg_task_class_scores(struct sg_lb_task_class_stats *clas { } +static bool sched_asym_class_pick(struct sched_group *a, + struct sched_group *b, + struct sg_lb_stats *a_stats, + struct sg_lb_stats *b_stats) +{ + return false; +} + #endif /* CONFIG_SCHED_TASK_CLASSES */ /** @@ -9049,6 +9111,12 @@ static bool update_sd_pick_busiest(struct lb_env *env, /* Prefer to move from lowest priority CPU's work */ if (sched_asym_prefer(sg->asym_prefer_cpu, sds->busiest->asym_prefer_cpu)) return false; + + /* @sg and @sds::busiest have the same priority. */ + if (sched_asym_class_pick(sds->busiest, sg, &sds->busiest_stat, sgs)) + return false; + + /* @sg has lower priority than @sds::busiest. */ break; case group_misfit_task: -- 2.25.1
| |