From: Chen Yu <chen.yu@linux.dev>
To: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Zhan Xusheng <zhanxusheng1024@gmail.com>,
yu.c.chen@intel.com, peterz@infradead.org, mingo@redhat.com,
juri.lelli@redhat.com, vincent.guittot@linaro.org,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
kprateek.nayak@amd.com, linux-kernel@vger.kernel.org,
zhanxusheng@xiaomi.com
Subject: Re: sched/fair: which tasks should nr_pref_llc_running be compared against?
Date: Sun, 30 Aug 2026 16:17:41 +0800 [thread overview]
Message-ID: <apPnJaUS5vq2f85J@three-body> (raw)
In-Reply-To: <59e2b8265fc650266b93d8f523c366edfa912428.camel@linux.intel.com>
On Thu, Aug 27, 2026 at 01:57:33PM -0700, Tim Chen wrote:
> On Thu, 2026-08-27 at 21:50 +0800, Zhan Xusheng wrote:
> Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
> ---
> kernel/sched/fair.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index d78467ec6ee1..1673b17273c5 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -1544,7 +1544,14 @@ static void account_llc_dequeue(struct rq *rq, struct task_struct *p)
>
> rq->nr_llc_running--;
> if (p->pref_llc_queued) {
> - rq->nr_pref_llc_running--;
> + /*
> + * If the task is being finally dequeued while still delayed,
> + * set_delayed() already removed it from nr_pref_llc_running;
> + * skip here to avoid underflow. Clearing pref_llc_queued also
> + * stops the subsequent clear_delayed() from re-adding it.
> + */
> + if (!p->se.sched_delayed)
> + rq->nr_pref_llc_running--;
Should we also do similar check in account_llc_enqueue()? It is possible during
load balance migration, a migrate_load allows the task to be migrated across
CPUs. And load balance leverages detach_tasks()/attach_tasks() to move tasks.
During this stage the p->se.sched_delayed remained unchanged:
In enqueue_task_fair(), only when if (se->on_rq && se->sched_delayed) is true,
p->se.sched_delayed will be cleared by requeue_delayed_entity() - during migration,
se->on_rq is false.
As a result, attach_tasks -> enqueue_hierarchy -> enqueue_entity -> account_llc_enqueue(rq, p)
incorrectly increase rq->nr_pref_llc_running - even that task is in delayed state, and
not runnable.
> /*
> * Update the status in case
> * other logic might query
> @@ -1572,6 +1579,24 @@ static void account_llc_dequeue(struct rq *rq, struct task_struct *p)
> }
> }
>
> +/*
> + * A task becoming delay-dequeued leaves the runnable set while staying
> + * queued. Keep nr_pref_llc_running in the runnable domain (like
> + * h_nr_runnable) so alb_break_llc() can compare the two directly.
> + */
>
Regarding alb_break_llc(), since we have compared nr_pref_llc_running vs
nr_runnable, I wonder if we should also change the code?
if (env->src_rq->nr_pref_llc_running &&
env->src_rq->nr_pref_llc_running == env->src_rq->cfs.h_nr_runnable)
unsigned long util = 0;
struct task_struct *cur;
if (env->src_rq->cfs.h_nr_runnable <= 1)
return true;
thanks,
Chenyu
prev parent reply other threads:[~2026-08-30 8:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 13:50 Zhan Xusheng
2026-08-27 20:57 ` Tim Chen
2026-08-28 2:20 ` [PATCH] sched/cache: Keep nr_pref_llc_running in the runnable domain Zhan Xusheng
2026-08-28 17:08 ` Tim Chen
2026-08-30 8:17 ` Chen Yu [this message]
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=apPnJaUS5vq2f85J@three-body \
--to=chen.yu@linux.dev \
--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=rostedt@goodmis.org \
--cc=tim.c.chen@linux.intel.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yu.c.chen@intel.com \
--cc=zhanxusheng1024@gmail.com \
--cc=zhanxusheng@xiaomi.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®