mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Keisuke Nishimura <keisuke.nishimura@inria.fr>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	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>,
	linux-kernel@vger.kernel.org, julia.lawall@inria.fr,
	jean-pierre.lozi@inria.fr
Subject: Re: [PATCH v2] sched/fair: Don't pick recent_used_cpu if target has no sched domain
Date: Thu, 26 Nov 2026 13:14:12 +0100	[thread overview]
Message-ID: <8e3f3ce6-2194-489a-9f30-91eb71f5e33f@inria.fr> (raw)
In-Reply-To: <CAKfTPtCaWVApT+6WAreKapk2wRCrXCngZPLt8oayuZT9cB1k+Q@mail.gmail.com>



On 11/26/26 12:26, Vincent Guittot wrote:
> On Thu, 26 Nov 2026 at 12:21, Vincent Guittot
> <vincent.guittot@linaro.org> wrote:
>>
>> On Wed, 25 Nov 2026 at 01:54, Keisuke Nishimura
>> <keisuke.nishimura@inria.fr> wrote:
>>>
>>> select_idle_sibling() can return recent_used_cpu if it is idle and
>>> shares the LLC with target. However, it does not check if target is an
>>> isolated CPU where the scheduler should not move tasks.
>>>
>>> Consider the following situation:
>>> * isolcpus=1,2
>>> * recent_used_cpu=1
>>> * target=prev=2
>>> * affinity=1,2
>>>
>>> When CPU 1 is idle but CPU 2 is busy, select_idle_sibling() returns
>>> recent_used_cpu (CPU 1).
>>>
>>> To prevent the scheduler from moving the task among isolated CPUs, check
>>> whether target has a sched domain before searching for an idle CPU.
>>>
>>> This bug was found with the help of verification using Frama-C.
>>>
>>> Fixes: 32e839dda3ba ("sched/fair: Use a recently used CPU as an idle candidate and the basis for SIS")
>>> Signed-off-by: Keisuke Nishimura <keisuke.nishimura@inria.fr>
>>> ---
>>> Changes in v2:
>>> - Return early at the beginning of select_idle_sibling() if target has
>>>    no sched domain.
>>> - Instead of `per_cpu(sd_llc, target)`, use `cpu_rq(target)->sd` to
>>>    check if target is isolated or not. A CPU might be in an asymmetric
>>>    capacity domain, but not in an LLC domain. In this case, returning
>>>    early based only on the LLC domain would miss the chance to run
>>>    select_idle_capacity().
>>> - Rewrite the explanation, because sd_llc is not the main issue anymore.
>>> ---
>>>   kernel/sched/fair.c | 4 ++++
>>>   1 file changed, 4 insertions(+)
>>>
>>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>>> index da0d9e19c457..9746fc55241b 100644
>>> --- a/kernel/sched/fair.c
>>> +++ b/kernel/sched/fair.c
>>> @@ -9155,6 +9155,10 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
>>>          unsigned long task_util, util_min, util_max;
>>>          int i, recent_used_cpu, prev_aff = -1;
>>>
>>> +       /* Do not search for idle CPUs if target has no sched domain. */
>>> +       if (!rcu_dereference_all(cpu_rq(target)->sd))
>>> +               return target;
>>
>> After more thought,  You have to move this check one level up at the
>> beg of select_task_rq_fair().
>> Something like:
>>
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -9979,6 +9979,11 @@ select_task_rq_fair(struct task_struct *p, int
>> prev_cpu, int wake_flags)
>>           * required for stable ->cpus_allowed
>>           */
>>          lockdep_assert_held(&p->pi_lock);
>> +
>> +       /* Do not search for a CPU if prev has no sched domain. */
>> +       if (!rcu_dereference_sched_domain(cpu_rq(target)->sd))
>> +               return;
>> +
>>          if (wake_flags & WF_TTWU) {
>>                  record_wakee(p);
>>
> 
> And this still doesn't fix the case when cpus are isolated at runtime

Thanks. Moving the check to select_task_rq_fair() makes sense.

Could you elaborate on the case where CPUs are isolated at runtime? I would 
expect rq->sd to be NULL in that case as well?

Best,
Keisuke

> 
>>
>>> +
>>>          /*
>>>           * On asymmetric system, update task utilization because we will check
>>>           * that the task fits with CPU's capacity.
>>> --
>>> 2.34.1
>>>


  reply	other threads:[~2026-11-26 12:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  0:36 Keisuke Nishimura
2026-11-26 11:21 ` Vincent Guittot
2026-11-26 11:26   ` Vincent Guittot
2026-11-26 12:14     ` Keisuke Nishimura [this message]
2026-11-26 13:30       ` Vincent Guittot

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=8e3f3ce6-2194-489a-9f30-91eb71f5e33f@inria.fr \
    --to=keisuke.nishimura@inria.fr \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=jean-pierre.lozi@inria.fr \
    --cc=julia.lawall@inria.fr \
    --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 \
    /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®