struct rq_flags *rf)
{
#ifdef CONFIG_SMP
+ const struct sched_class *start_class = prev->sched_class;
const struct sched_class *class;
+
+#ifdef CONFIG_SCHED_CLASS_EXT
+ /*
+ * SCX requires a balance() call before every pick_next_task() including
+ * when waking up from SCHED_IDLE. If @start_class is below SCX, start
+ * from SCX instead.
+ */
+ if (sched_class_above(&ext_sched_class, start_class))
+ start_class = &ext_sched_class;
+#endif
+
/*
* We must do the balancing pass before put_prev_task(), such
* that when we release the rq->lock the task is in the same
* We can terminate the balance pass as soon as we know there is
* a runnable task of @class priority or higher.
*/
- for_balance_class_range(class, prev->sched_class, &idle_sched_class) {
+ for_active_class_range(class, start_class, &idle_sched_class) {
if (class->balance(rq, prev, rf))
break;
}
#define for_each_active_class(class) \
for_active_class_range(class, __sched_class_highest, __sched_class_lowest)
-/*
- * SCX requires a balance() call before every pick_next_task() call including
- * when waking up from idle.
- */
-#define for_balance_class_range(class, prev_class, end_class) \
- for_active_class_range(class, (prev_class) > &ext_sched_class ? \
- &ext_sched_class : (prev_class), (end_class))
-
#ifdef CONFIG_SCHED_CORE
bool scx_prio_less(const struct task_struct *a, const struct task_struct *b,
bool in_fi);
static inline void init_sched_ext_class(void) {}
#define for_each_active_class for_each_class
-#define for_balance_class_range for_class_range
#endif /* CONFIG_SCHED_CLASS_EXT */