Re: [PATCH v2 1/3] sched: Tell rq_online() and rq_offline() whether the CPU changes state

From: Li kunyu

Date: Thu Nov 19 2026 - 03:29:50 EST


Hi,

On 2026/11/19 8:57, Qiliang Yuan wrote:
> -void set_rq_online(struct rq *rq)
> +void set_rq_online(struct rq *rq, bool hotplug)
> {
> if (!rq->online) {
> const struct sched_class *class;
> @@ -8554,12 +8554,12 @@ void set_rq_online(struct rq *rq)
>
> for_each_class(class) {
> if (class->rq_online)
> - class->rq_online(rq);
> + class->rq_online(rq, hotplug);
> }
> }
> }
>
> -void set_rq_offline(struct rq *rq)
> +void set_rq_offline(struct rq *rq, bool hotplug)
> {
> if (rq->online) {
> struct root_domain *rd = rcu_dereference_root_domain(rq->rd);
> @@ -8568,7 +8568,7 @@ void set_rq_offline(struct rq *rq)
> update_rq_clock(rq);
> for_each_class(class) {
> if (class->rq_offline)
> - class->rq_offline(rq);
> + class->rq_offline(rq, hotplug);
> }
>
> cpumask_clear_cpu(rq->cpu, rd->online);
> @@ -8585,7 +8585,7 @@ static inline void sched_set_rq_online(struct rq *rq, int cpu)
> rd = rcu_dereference_root_domain(rq->rd);
> if (rd) {
> BUG_ON(!cpumask_test_cpu(cpu, rd->span));
> - set_rq_online(rq);
> + set_rq_online(rq, true);
> }
> rq_unlock_irqrestore(rq, &rf);
> }
> @@ -8599,7 +8599,7 @@ static inline void sched_set_rq_offline(struct rq *rq, int cpu)
> rd = rcu_dereference_root_domain(rq->rd);
> if (rd) {
> BUG_ON(!cpumask_test_cpu(cpu, rd->span));
> - set_rq_offline(rq);
> + set_rq_offline(rq, true);
> }
> rq_unlock_irqrestore(rq, &rf);
> }
>
> +static void rq_online_dl(struct rq *rq, bool hotplug)
> {
> if (rq->dl.overloaded)
> dl_set_overload(rq);
> @@ -3379,7 +3379,7 @@ static void rq_online_dl(struct rq *rq)
> }
>
> /* Assumes rq->lock is held */
> -static void rq_offline_dl(struct rq *rq)
> +static void rq_offline_dl(struct rq *rq, bool hotplug)
> {
> if (rq->dl.overloaded)
> dl_clear_overload(rq);
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 731d78155e654..db9ab8ce36500 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -15082,14 +15082,14 @@ void sched_balance_trigger(struct rq *rq)
> nohz_balancer_kick(rq);
> }
>
>
> -static void rq_online_fair(struct rq *rq)
> +static void rq_online_fair(struct rq *rq, bool hotplug)
> {
> update_sysctl();
>
> update_runtime_enabled(rq);
> }
>
> -static void rq_offline_fair(struct rq *rq)
> +static void rq_offline_fair(struct rq *rq, bool hotplug)
> {
> update_sysctl();
>
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 81a71aa5f094a..fc6224a343552 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2398,7 +2398,7 @@ static void task_woken_rt(struct rq *rq, struct task_struct *p)
> }
>
> /* Assumes rq->lock is held */
> -static void rq_online_rt(struct rq *rq)
> +static void rq_online_rt(struct rq *rq, bool hotplug)
> {
>
> if (rq->rt.overloaded)
> rt_set_overload(rq);
> @@ -2409,7 +2409,7 @@ static void rq_online_rt(struct rq *rq)
> }
>
> /* Assumes rq->lock is held */
> -static void rq_offline_rt(struct rq *rq)
> +static void rq_offline_rt(struct rq *rq, bool hotplug)
> {
> if (rq->rt.overloaded)
> rt_clear_overload(rq);
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index e957524c3ee52..5f7b6ab4dde6d 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -2796,8 +2796,8 @@ struct sched_class {
> /*
> * sched_set_rq_{on,off}line: rq->lock
> */
> - void (*rq_online)(struct rq *rq);
> - void (*rq_offline)(struct rq *rq);
> + void (*rq_online)(struct rq *rq, bool hotplug);
> + void (*rq_offline)(struct rq *rq, bool hotplug);

I noticed that the functions set_rq_online and set_rq_offline have added a new
bool hotplug parameter, and the corresponding scheduler class callback
declarations have also been updated accordingly. However, in the actual
implementations - such as rq_online_fair(struct rq *rq, bool hotplug) - this
parameter does not appear to be used.
Is this parameter currently unused, or is it being introduced at the callback
layer in advance for future use cases?

--
thanks,
kunyu