mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Li kunyu <likunyu@open-hieco.net>
To: Qiliang Yuan <qiliang.yuan@linux.dev>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] sched: Keep CPUs that stay active online across root domain moves
Date: Mon, 23 Nov 2026 15:25:14 +0800	[thread overview]
Message-ID: <a0be247c-24be-5b13-ce39-48ed45d2eb64@open-hieco.net> (raw)
In-Reply-To: <20261120-bug-sched-fair-offline-active-v3-2-325e9eefa56d@linux.dev>



On 2026/11/21 10:57, Qiliang Yuan wrote:
> +void rq_attach_root_domain(struct rq *rq)
> +{
> +	struct root_domain *rd = rcu_dereference_root_domain(rq->rd);
> +	const struct sched_class *class;
> +
> +	cpumask_set_cpu(rq->cpu, rd->online);
> +
> +	for_each_class(class) {
> +		if (class->rq_attach_root)
> +			class->rq_attach_root(rq);
> +	}
> +}
> +
> +void rq_detach_root_domain(struct rq *rq)
> +{
> +	struct root_domain *rd = rcu_dereference_root_domain(rq->rd);
> +	const struct sched_class *class;
> +
> +	update_rq_clock(rq);
> +	for_each_class(class) {
> +		if (class->rq_detach_root)
> +			class->rq_detach_root(rq);
> +	}
> +
> +	cpumask_clear_cpu(rq->cpu, rd->online);
> +}
> +
> 
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 99878da03bce7..cc2bc832dad1a 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -488,14 +488,26 @@ static void free_rootdomain(struct rcu_head *rcu)
>  void rq_attach_root(struct rq *rq, struct root_domain *rd)
>  {
>  	struct root_domain *old_rd = NULL;
> +	bool active, move = false;
>  	struct rq_flags rf;
>  
>  	rq_lock_irqsave(rq, &rf);
>  
> +	active = cpumask_test_cpu(rq->cpu, cpu_active_mask);
> +
>  	old_rd = rcu_dereference_root_domain(rq->rd);
>  	if (old_rd) {
> -		if (cpumask_test_cpu(rq->cpu, old_rd->online))
> -			set_rq_offline(rq);
> +		if (cpumask_test_cpu(rq->cpu, old_rd->online)) {
> +			/*
> +			 * Keep an online CPU that stays active online and move
> +			 * only its root domain state.
> +			 */
> +			move = active;
> +			if (move)
> +				rq_detach_root_domain(rq);
> +			else
> +				set_rq_offline(rq);

Check whether rq->cpu is active. This approach effectively prevents a series of
issues such as the active CPU going offline and then back online (after the rd
root domain is updated). It also invokes the abstraction function for rd root
domain updates implemented for RT and DL, thereby ensuring the overall logic
remains correct.

> +		}
> 
> @@ -512,7 +524,9 @@ void rq_attach_root(struct rq *rq, struct root_domain *rd)
>  	rcu_assign_pointer(rq->rd, rd);
>  
>  	cpumask_set_cpu(rq->cpu, rd->span);
> -	if (cpumask_test_cpu(rq->cpu, cpu_active_mask))
> +	if (move)
> +		rq_attach_root_domain(rq);
> +	else if (active)
>  		set_rq_online(rq);
>  

By the way, does "base-commit: b251360cb2e6c7b74d962831f5797a4520511b36" point
to a specific development branch of the kernel (such as tip/sched/core)? The
code in the rq_attach_root function appears to differ slightly from what is
currently in mainline.

-- 
thanks,
kunyu

  reply	other threads:[~2026-11-23  7:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21  2:57 [PATCH v3 0/3] sched/fair: Cut per-group work from sched domain rebuilds Qiliang Yuan
2026-11-21  2:57 ` [PATCH v3 1/3] sched: Give root domain moves their own sched_class callbacks Qiliang Yuan
2026-11-23  5:56   ` Li kunyu
2026-11-21  2:57 ` [PATCH v3 2/3] sched: Keep CPUs that stay active online across root domain moves Qiliang Yuan
2026-11-23  7:25   ` Li kunyu [this message]
2026-11-23  7:43     ` Qiliang Yuan
2026-11-21  2:57 ` [PATCH v3 3/3] sched/fair: Drop the active CPU check from unthrottle_offline_cfs_rqs() Qiliang Yuan
2026-11-23  7:28   ` Li kunyu
2026-11-23  7:48     ` Qiliang Yuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0be247c-24be-5b13-ce39-48ed45d2eb64@open-hieco.net \
    --to=likunyu@open-hieco.net \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=qiliang.yuan@linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®