From: Tim Chen <tim.c.chen@linux.intel.com>
To: "Chen, Yu C" <yu.c.chen@intel.com>, Lu Wang <wanglu.priv@gmail.com>
Cc: 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,
"chen.yu@linux.dev" <chen.yu@linux.dev>
Subject: Re: [PATCH] sched/cache: honor migrate_llc_task semantics in active load balance
Date: Thu, 06 Aug 2026 10:22:57 -0700 [thread overview]
Message-ID: <a1f50a3a576774a5960c41a73599ec4f2c9a2c4e.camel@linux.intel.com> (raw)
In-Reply-To: <59db4420-7995-4261-89d5-03aa306c1370@intel.com>
On Thu, 2026-08-06 at 23:35 +0800, Chen, Yu C wrote:
> Hi Lu Wang, Tim,
>
> On 8/1/2026 8:22 PM, Lu Wang wrote:
> > A passive load-balance pass marks group_llc_balance as migrate_llc_task
> > and queues active balance when it cannot move a task. The CPU stopper
> > callback constructs a fresh lb_env, so preserve the migration type on
> > the runqueue across the asynchronous boundary.
> >
> > For CAS-directed active balance, reject a candidate whose preferred LLC
> > does not match the destination LLC. This keeps the fallback from moving
> > a task away from its preferred LLC.
> >
>
> It looks like this proposal provides fine-grain control on per-task base
> migration strategy is promising.
>
> > +static inline bool
> > +migrate_llc_task_wrong_dst(struct task_struct *p, struct lb_env *env)
> > +{
> > + return sched_cache_enabled() &&
> > + env->migration_type == migrate_llc_task &&
> > + READ_ONCE(p->preferred_llc) != llc_id(env->dst_cpu);
> > +}
> > +
>
> [ ... ]
>
> > @@ -13654,6 +13672,7 @@ static int active_load_balance_cpu_stop(void *data)
> > .src_rq = busiest_rq,
> > .idle = CPU_IDLE,
> > .flags = LBF_ACTIVE_LB,
> > + .migration_type = (enum migration_type)busiest_rq->active_balance_type,
>
> If we overwrite migration_type for ALB (default is 0, i.e. migrate_load),
> then in can_migrate_task() a delayed task might not be migrated in ALB:
>
> if ((p->se.sched_delayed) && (env->migration_type != migrate_load))
This is a good catch.
It may be easier to create a migrate_llc_task_alb type and pass that
in migration type. Then modify the above as
if ((p->se.sched_delayed) && env->migration_type != migrate_load
&& env->migration_type != migrate_llc_task_alb)
return 0
That avoids creating two cpu stop functions.
Tim
> return 0;
> So an enhanced approach I'm thinking of is to pass
> migrate_llc_task information via env->flags:
> > };
> >
> > schedstat_inc(sd->alb_count);
> > diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> > index 56acf502b..82084d405 100644
> > --- a/kernel/sched/sched.h
> > +++ b/kernel/sched/sched.h
> > @@ -1266,6 +1266,7 @@ struct rq {
> > /* For active balancing */
> > int active_balance;
> > int push_cpu;
> > + int active_balance_type; /* enum migration_type */
>
> We can set env->flags by invoking different callbacks of
> stop_one_cpu_nowait(),
> thus avoiding the need to introduce active_balance_type into rq - which
> could
> cause false sharing if cache-line alignment is broken.
>
> something like:
>
> #define LBF_ACTIVE_LB_LLC 0x40
>
> -static int active_load_balance_cpu_stop(void *data)
> +static int __active_load_balance_cpu_stop(void *data, unsigned int
> lb_flags)
> -static int active_load_balance_cpu_stop(void *data)
> +static int __active_load_balance_cpu_stop(void *data, unsigned int
> lb_flags)
> {
> struct rq *busiest_rq = data;
> int busiest_cpu = cpu_of(busiest_rq);
> @@ -13659,7 +13687,7 @@ static int active_load_balance_cpu_stop(void *data)
> .src_cpu = busiest_rq->cpu,
> .src_rq = busiest_rq,
> .idle = CPU_IDLE,
> - .flags = LBF_ACTIVE_LB,
> + .flags = LBF_ACTIVE_LB | lb_flags,
> };
>
> and in migrate_llc_task_wrong_dst(), we check env->flags & LBF_ACTIVE_LB_LLC
> instead.
>
> static int active_load_balance_cpu_stop(void *data)
> {
> return __active_load_balance_cpu_stop(data, 0);
> }
>
> static int active_load_balance_llc_cpu_stop(void *data)
> {
> return __active_load_balance_cpu_stop(data, LBF_ACTIVE_LB_LLC);
> <-- new flag
> }
>
> static inline cpu_stop_fn_t alb_stop_fn(struct lb_env *env)
> {
> if (env->migration_type == migrate_llc_task)
> return active_load_balance_llc_cpu_stop;
>
> return active_load_balance_cpu_stop;
> }
>
> if (active_balance) {
> stop_one_cpu_nowait(cpu_of(busiest),
> alb_stop_fn(&env), busiest,
> &busiest->active_balance_work);
> }
>
>
> thanks,
> Chenyu
>
> > struct cpu_stop_work active_balance_work;
> >
> > /* CPU of this runqueue: */
next prev parent reply other threads:[~2026-08-06 17:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-01 12:22 [PATCH] sched/cache: honor migrate_llc_task semantics in active load balance Lu Wang
2026-08-03 4:20 ` Chen, Yu C
2026-08-03 10:02 ` Lu Wang
2026-08-04 0:10 ` Tim Chen
2026-08-04 8:17 ` Chen, Yu C
2026-08-04 15:07 ` Lu Wang
2026-08-04 19:42 ` Tim Chen
2026-08-05 2:38 ` wanglu15
2026-08-05 16:04 ` Tim Chen
2026-08-05 16:43 ` Chen, Yu C
2026-08-06 16:21 ` Tim Chen
2026-08-04 8:30 ` Lu Wang
2026-08-06 15:35 ` Chen, Yu C
2026-08-06 17:22 ` Tim Chen [this message]
2026-08-07 6:48 ` Chen, Yu C
-- strict thread matches above, loose matches on Subject: below --
2026-08-01 12:17 Lu Wang
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=a1f50a3a576774a5960c41a73599ec4f2c9a2c4e.camel@linux.intel.com \
--to=tim.c.chen@linux.intel.com \
--cc=bsegall@google.com \
--cc=chen.yu@linux.dev \
--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=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=wanglu.priv@gmail.com \
--cc=yu.c.chen@intel.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