From: Kayra Cizmeci <kayracizmeci@gmail.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
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,
lukasz.luba@arm.com, rafael@kernel.org,
linux-pm@vger.kernel.org, tj@kernel.org, void@manifault.com,
arighi@nvidia.com, changwoo@igalia.com,
sched-ext@lists.linux.dev, qyousef@layalina.io,
christian.loehle@arm.com, pierre.gondois@arm.com,
sshegde@linux.ibm.com, tim.c.chen@linux.intel.com
Subject: Re: [PATCH 06/20 v3] sched/eevdf: Add min slice check when selecting CPU
Date: Sat, 7 Nov 2026 11:57:12 +0300 [thread overview]
Message-ID: <au7SabL5pfbsApyB@scheduler.schedules> (raw)
In-Reply-To: <20261106151947.3991524-7-vincent.guittot@linaro.org>
Hi Vincent,
Sashiko reviewed this one so I'll just put here my own concerns instead
of repeating.
On Fri, Nov 06, 2026 at 04:19:33PM +0100, Vincent Guittot wrote:
> Add a new level for selecting CPU when select_task_rq_fair() fails to find
> an idle CPU. This last level compares the min slice to select a CPU where
> the task could run 1st.
> This helps a waking task to select a CPU where a longer slice runs
> instead of one where a task with the same or shorter slice already runs.
>
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
> kernel/sched/core.c | 2 +-
> kernel/sched/fair.c | 157 ++++++++++++++++++++++++++++----------------
> 2 files changed, 102 insertions(+), 57 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 031efe7d49fb..d71da9069218 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -9012,7 +9012,7 @@ void __init sched_init(void)
> rq->sd = NULL;
> rq->rd = NULL;
> rq->cpu_capacity = SCHED_CAPACITY_SCALE;
> - rq->min_slice = ULONG_MAX;
> + rq->min_slice = 0;
> rq->balance_callback = &balance_push_callback;
> rq->active_balance = 0;
> rq->next_balance = jiffies;
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index cfc99b94d9ce..039dce244aaa 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8842,11 +8842,25 @@ static inline int sched_balance_find_dst_cpu(struct sched_domain *sd, struct tas
> return new_cpu;
> }
>
> -static inline int __select_idle_cpu(int cpu, struct task_struct *p)
> +static inline bool choose_sched_slice_rq(struct rq *rq, struct task_struct *p)
> {
> - if (choose_idle_cpu(cpu, p) && sched_cpu_cookie_match(cpu_rq(cpu), p))
> + if (p->se.slice < get_rq_min_slice(rq))
> + return true;
> +
> + return false;
> +}
> +
> +static inline int __select_idle_cpu(int cpu, struct task_struct *p, int *slice_cpu)
> +{
> + if (!sched_cpu_cookie_match(cpu_rq(cpu), p))
> + return -1;
> +
> + if (choose_idle_cpu(cpu, p))
> return cpu;
>
> + if (*slice_cpu == -1 && choose_sched_slice_rq(cpu_rq(cpu), p))
> + *slice_cpu = cpu;
> +
> return -1;
> }
Look here:
CPU1: CPU2:
FA RA
FC
CPU2 has 1 RT and 1 Fair tasks named RA and FC.
Let's say RA is running on CPU2 and FC's slice is 10 ms.
And let's say FA has 8 ms slice, and a fair task named TC is waking up
with 9 ms slice:
* We look to CPU1, 9 < 8 is false so we return false
* We look to CPU2, 9 < 10 is true so we return it.
But the problem is, CPU2 has a RT task running and we are going to
compete with the RT task. In that case it can be worse than CPU1.
So, I would suggest something like this or so:
(My editor got crazy, so I had to copy this diff :<)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 262626455497..8b0dd858f332 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8876,10 +8876,8 @@ static inline int sched_balance_find_dst_cpu(struct sched_domain *sd, struct tas
static inline bool choose_sched_slice_rq(struct rq *rq, struct task_struct *p)
{
- if (p->se.slice < get_rq_min_slice(rq))
- return true;
-
- return false;
+ return p->se.slice < get_rq_min_slice(rq) &&
+ READ_ONCE(rq->curr)->sched_class == &fair_sched_class;
}
static inline int __select_idle_cpu(int cpu, struct task_struct *p, int *slice_cpu)
@@ -9193,7 +9191,6 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
bool has_idle_core = sched_smt_active() && test_idle_cores(target);
unsigned long task_util, util_min, util_max, best_cap = 0;
int fits, best_fits = ASYM_IDLE_THREAD_MISFIT;
- unsigned long task_slice;
int cpu, best_cpu = -1;
struct cpumask *cpus;
int nr = INT_MAX;
@@ -9204,7 +9201,6 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
task_util = task_util_est(p);
util_min = uclamp_eff_value(p, UCLAMP_MIN);
util_max = uclamp_eff_value(p, UCLAMP_MAX);
- task_slice = p->se.slice;
if (sched_feat(SIS_UTIL) && sd->shared) {
/*
@@ -9260,7 +9256,7 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
else if (fits > 0)
fits = ASYM_IDLE_THREAD_FITS;
- } else if (fits > 0 && task_slice < get_rq_min_slice(cpu_rq(cpu))) {
+ } else if (fits > 0 && choose_sched_slice_rq(cpu_rq(cpu), p)) {
fits = ASYM_BUSY_THREAD_FITS;
cpu_cap = get_actual_cpu_capacity(cpu);
} else {
Cheers,
Kayra :-)
next prev parent reply other threads:[~2026-11-07 8:57 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 15:19 [PATCH 00/18 v3] Improving latency of short slice tasks Vincent Guittot
2026-11-06 15:19 ` [PATCH 01/20 v3] sched/eevdf: Decay positive lag of sleeping entities Vincent Guittot
2026-11-06 15:43 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 02/20 v3] sched/eevdf: Reset lag at wakeup when prev CPU has been idle Vincent Guittot
2026-11-06 16:22 ` Kayra Cizmeci
2026-11-09 15:27 ` Vincent Guittot
2026-11-09 15:45 ` Peter Zijlstra
2026-11-09 16:27 ` Vincent Guittot
2026-11-11 9:03 ` Peter Zijlstra
2026-11-12 7:02 ` Vincent Guittot
2026-11-11 10:04 ` K Prateek Nayak
2026-11-12 7:33 ` Vincent Guittot
2026-11-06 15:19 ` [PATCH 03/20 v3] sched/eevdf: Reset lag at wakeup when migrating and prev " Vincent Guittot
2026-11-06 18:05 ` Kayra Cizmeci
2026-11-06 15:19 ` [PATCH 04/20 v3] sched/eevdf: Reset lag when waking up on idle cpu Vincent Guittot
2026-11-06 18:39 ` Kayra Cizmeci
2026-11-06 15:19 ` [PATCH 05/20 v3] sched/eevdf: Add per cpu cached min_slice Vincent Guittot
2026-11-07 6:53 ` Kayra Cizmeci
2026-11-09 15:27 ` Vincent Guittot
2026-11-06 15:19 ` [PATCH 06/20 v3] sched/eevdf: Add min slice check when selecting CPU Vincent Guittot
2026-11-06 15:40 ` sashiko-bot
2026-11-07 8:57 ` Kayra Cizmeci [this message]
2026-11-09 13:55 ` Peter Zijlstra
2026-11-09 14:15 ` Kayra Cizmeci
2026-11-09 15:37 ` Vincent Guittot
2026-11-09 15:34 ` Vincent Guittot
2026-11-09 15:55 ` Vincent Guittot
2026-11-09 19:56 ` Kayra Cizmeci
2026-11-10 13:32 ` Vincent Guittot
2026-11-06 15:19 ` [PATCH 07/20 v3] sched/fair: Prepare select_task_rq_fair() to be called for new cases Vincent Guittot
2026-11-06 15:39 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 08/20 v3] sched/fair: Add push task mechanism for fair Vincent Guittot
2026-11-06 16:15 ` sashiko-bot
2026-11-09 14:43 ` Peter Zijlstra
2026-11-09 16:07 ` Vincent Guittot
2026-11-11 8:59 ` Peter Zijlstra
2026-11-12 7:01 ` Vincent Guittot
2026-11-09 15:54 ` Peter Zijlstra
2026-11-09 16:14 ` Vincent Guittot
2026-11-11 9:01 ` Peter Zijlstra
2026-11-12 7:01 ` Vincent Guittot
2026-11-12 7:36 ` Vincent Guittot
2026-11-12 9:49 ` Peter Zijlstra
2026-11-12 11:29 ` Vincent Guittot
2026-11-12 12:19 ` Peter Zijlstra
2026-11-06 15:19 ` [PATCH 09/20 v3] sched/fair: Optimize " Vincent Guittot
2026-11-06 16:00 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 10/20 v3] sched/core: Add rq flag to tick parameters Vincent Guittot
2026-11-06 15:19 ` [PATCH 11/20 v3] sched/fair: Add force push task mechanism for fair Vincent Guittot
2026-11-06 16:16 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 12/20 v3] sched/fair: Support not wakeup case in select_idle_sibling Vincent Guittot
2026-11-06 15:51 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 13/20] sched/eevdf: Try to push short slice task on a better CPU Vincent Guittot
2026-11-06 16:12 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 14/20 v3] sched/eevdf: Push short slice task that are not picked Vincent Guittot
2026-11-06 16:14 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 15/20 v3] sched/fair: Enable push task for preempt short Vincent Guittot
2026-11-06 16:27 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 16/20 v3] energy model: Add a get previous state function Vincent Guittot
2026-11-10 19:55 ` Rafael J. Wysocki (Intel)
2026-11-06 15:19 ` [PATCH 17/20 v3] sched/fair: Rework feec() to use cost instead of spare capacity Vincent Guittot
2026-11-06 16:30 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 18/20 v3] energy model: Remove unused em_cpu_energy() Vincent Guittot
2026-11-06 15:19 ` [PATCH 19/20 v3] sched/fair: Take into account slice in EAS Vincent Guittot
2026-11-06 16:26 ` sashiko-bot
2026-11-06 15:19 ` [PATCH 20/20 v3] sched/fair: Fix tasks stacking on same idle CPU Vincent Guittot
2026-11-06 16:53 ` sashiko-bot
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=au7SabL5pfbsApyB@scheduler.schedules \
--to=kayracizmeci@gmail.com \
--cc=arighi@nvidia.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pierre.gondois@arm.com \
--cc=qyousef@layalina.io \
--cc=rafael@kernel.org \
--cc=rostedt@goodmis.org \
--cc=sched-ext@lists.linux.dev \
--cc=sshegde@linux.ibm.com \
--cc=tim.c.chen@linux.intel.com \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.