@@ -384,6 +384,24 @@ struct sched_ext_ops {
*/
void (*cpu_release)(s32 cpu, struct scx_cpu_release_args *args);
+ /**
+ * cpu_online - A CPU became online
+ * @cpu: CPU which just came up
+ *
+ * @cpu just came online. @cpu doesn't call ->enqueue() or consume tasks
+ * associated with other CPUs beforehand.
+ */
+ void (*cpu_online)(s32 cpu);
+
+ /**
+ * cpu_offline - A CPU is going offline
+ * @cpu: CPU which is going offline
+ *
+ * @cpu is going offline. @cpu doesn't call ->enqueue() or consume tasks
+ * associated with other CPUs afterwards.
+ */
+ void (*cpu_offline)(s32 cpu);
+
/**
* prep_enable - Prepare to enable BPF scheduling for a task
* @p: task to prepare BPF scheduling for
@@ -1574,6 +1574,18 @@ void __scx_update_idle(struct rq *rq, bool idle)
}
}
+static void rq_online_scx(struct rq *rq, enum rq_onoff_reason reason)
+{
+ if (SCX_HAS_OP(cpu_online) && reason == RQ_ONOFF_HOTPLUG)
+ scx_ops.cpu_online(cpu_of(rq));
+}
+
+static void rq_offline_scx(struct rq *rq, enum rq_onoff_reason reason)
+{
+ if (SCX_HAS_OP(cpu_offline) && reason == RQ_ONOFF_HOTPLUG)
+ scx_ops.cpu_offline(cpu_of(rq));
+}
+
#else /* !CONFIG_SMP */
static bool test_and_clear_cpu_idle(int cpu) { return false; }
@@ -2049,6 +2061,9 @@ DEFINE_SCHED_CLASS(ext) = {
.pick_task = pick_task_scx,
.set_cpus_allowed = set_cpus_allowed_scx,
+
+ .rq_online = rq_online_scx,
+ .rq_offline = rq_offline_scx,
#endif
.task_tick = task_tick_scx,