From: Konstantin Khorenko <khorenko@virtuozzo.com>
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>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Valentin Schneider <vschneid@redhat.com>,
Alexander Atanasov <alexander.atanasov@virtuozzo.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/fair: Do not scan non-movable tasks several times
Date: Mon, 25 Dec 2023 16:17:49 +0100 [thread overview]
Message-ID: <2cf94373-4f25-4a33-a0b4-cab04031bae7@virtuozzo.com> (raw)
In-Reply-To: <CAKfTPtAqkY+attpekOyjeY10dcwgK0eND5_385cH6+wjR3EkTw@mail.gmail.com>
On 18.12.2023 17:48, Vincent Guittot wrote:
> On Thu, 14 Dec 2023 at 15:42, Konstantin Khorenko
> <khorenko@virtuozzo.com> wrote:
>>
>> If busiest rq is small, nr_running < SCHED_NR_MIGRATE_BREAK and all
>> tasks are not movable, detach_tasks() should not iterate more than tasks
>> available in the busiest rq.
>>
>> Previously the (env->loop > env->loop_max) condition prevented us from
>
> It's usually better to give the commit directly when we know it :
> Before commit : b0defa7ae03e ("sched/fair: Make sure to try to detach
> at least one movable task"),
> the (env->loop > env->loop_max) condition prevented us from ...
You are definitely right, added.
>> scanning non-movable tasks more than rq size times, but after we start
>> checking the LBF_ALL_PINNED flag, the "all tasks are not movable" case
>> is under threat.
>>
>
> Fixes: b0defa7ae03e ("sched/fair: Make sure to try to detach at least
> one movable task")
Added this too, thank you.
>> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
>> ---
>> kernel/sched/fair.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index d7a3c63a2171..faa2a765e899 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -11219,7 +11219,6 @@ static int load_balance(int this_cpu, struct rq *this_rq,
>> .dst_rq = this_rq,
>> .dst_grpmask = group_balance_mask(sd->groups),
>> .idle = idle,
>> - .loop_break = SCHED_NR_MIGRATE_BREAK,
>> .cpus = cpus,
>> .fbq_type = all,
>> .tasks = LIST_HEAD_INIT(env.tasks),
>> @@ -11265,6 +11264,12 @@ static int load_balance(int this_cpu, struct rq *this_rq,
>> * correctly treated as an imbalance.
>> */
>> env.loop_max = min(sysctl_sched_nr_migrate, busiest->nr_running);
>> + /*
>> + * If busiest rq is small, nr_running < SCHED_NR_MIGRATE_BREAK
>> + * and all tasks are not movable, detach_tasks() should not
>> + * iterate more than tasks available in rq.
>> + */
>> + env.loop_break = min(SCHED_NR_MIGRATE_BREAK, busiest->nr_running);
>
> Should it be after more_balance: ?
> In case we do "more_balance:" on a new_dst_cpu and it ends up that
> finally there is no more movable task as we released the lock of
> busiest rq in the meantime ?
Well, both yes and no here.
If we simply move the env.loop_break assignment after "more_balance" label,
we will break the handling LBF_NEED_BREAK case.
But you are right, the new_dst_cpu case should also not just reset loop_break to
SCHED_NR_MIGRATE_BREAK, but do the same min() calculation.
So i've added one more label before the env.loop_break = min(...) and used it in
the new_dst_cpu case.
> Also you can remove one more superfluous init of loop_break:
Yep, dropped it, thank you.
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -11361,7 +11361,6 @@ static int load_balance(int this_cpu, struct
> rq *this_rq,
> */
> if (!cpumask_subset(cpus, env.dst_grpmask)) {
> env.loop = 0;
> - env.loop_break = SCHED_NR_MIGRATE_BREAK;
> goto redo;
> }
> goto out_all_pinned;
>
>>
>> more_balance:
>> rq_lock_irqsave(busiest, &rf);
>> --
>> 2.39.3
>>
next prev parent reply other threads:[~2023-12-25 15:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 14:42 Konstantin Khorenko
2023-12-18 16:48 ` Vincent Guittot
2023-12-25 15:17 ` Konstantin Khorenko [this message]
2023-12-25 15:29 ` [PATCH v2] " Konstantin Khorenko
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=2cf94373-4f25-4a33-a0b4-cab04031bae7@virtuozzo.com \
--to=khorenko@virtuozzo.com \
--cc=alexander.atanasov@virtuozzo.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.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®