linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "tip-bot2 for Lingutla Chandrasekhar" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Lingutla Chandrasekhar <clingutla@codeaurora.org>,
	Valentin Schneider <valentin.schneider@arm.com>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] sched/fair: Ignore percpu threads for imbalance pulls
Date: Fri, 09 Apr 2021 16:14:31 -0000	[thread overview]
Message-ID: <161798487184.29796.7421551105074944506.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210407220628.3798191-2-valentin.schneider@arm.com>

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     9bcb959d05eeb564dfc9cac13a59843a4fb2edf2
Gitweb:        https://git.kernel.org/tip/9bcb959d05eeb564dfc9cac13a59843a4fb2edf2
Author:        Lingutla Chandrasekhar <clingutla@codeaurora.org>
AuthorDate:    Wed, 07 Apr 2021 23:06:26 +01:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 09 Apr 2021 18:02:20 +02:00

sched/fair: Ignore percpu threads for imbalance pulls

During load balance, LBF_SOME_PINNED will be set if any candidate task
cannot be detached due to CPU affinity constraints. This can result in
setting env->sd->parent->sgc->group_imbalance, which can lead to a group
being classified as group_imbalanced (rather than any of the other, lower
group_type) when balancing at a higher level.

In workloads involving a single task per CPU, LBF_SOME_PINNED can often be
set due to per-CPU kthreads being the only other runnable tasks on any
given rq. This results in changing the group classification during
load-balance at higher levels when in reality there is nothing that can be
done for this affinity constraint: per-CPU kthreads, as the name implies,
don't get to move around (modulo hotplug shenanigans).

It's not as clear for userspace tasks - a task could be in an N-CPU cpuset
with N-1 offline CPUs, making it an "accidental" per-CPU task rather than
an intended one. KTHREAD_IS_PER_CPU gives us an indisputable signal which
we can leverage here to not set LBF_SOME_PINNED.

Note that the aforementioned classification to group_imbalance (when
nothing can be done) is especially problematic on big.LITTLE systems, which
have a topology the likes of:

  DIE [          ]
  MC  [    ][    ]
       0  1  2  3
       L  L  B  B

  arch_scale_cpu_capacity(L) < arch_scale_cpu_capacity(B)

Here, setting LBF_SOME_PINNED due to a per-CPU kthread when balancing at MC
level on CPUs [0-1] will subsequently prevent CPUs [2-3] from classifying
the [0-1] group as group_misfit_task when balancing at DIE level. Thus, if
CPUs [0-1] are running CPU-bound (misfit) tasks, ill-timed per-CPU kthreads
can significantly delay the upgmigration of said misfit tasks. Systems
relying on ASYM_PACKING are likely to face similar issues.

Signed-off-by: Lingutla Chandrasekhar <clingutla@codeaurora.org>
[Use kthread_is_per_cpu() rather than p->nr_cpus_allowed]
[Reword changelog]
Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://lkml.kernel.org/r/20210407220628.3798191-2-valentin.schneider@arm.com
---
 kernel/sched/fair.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index bc34e35..1ad929b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7598,6 +7598,10 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
 	if (throttled_lb_pair(task_group(p), env->src_cpu, env->dst_cpu))
 		return 0;
 
+	/* Disregard pcpu kthreads; they are where they need to be. */
+	if ((p->flags & PF_KTHREAD) && kthread_is_per_cpu(p))
+		return 0;
+
 	if (!cpumask_test_cpu(env->dst_cpu, p->cpus_ptr)) {
 		int cpu;
 

  parent reply	other threads:[~2021-04-09 16:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 22:06 [PATCH v5 0/3] sched/fair: load-balance vs capacity margins Valentin Schneider
2021-04-07 22:06 ` [PATCH v5 1/3] sched/fair: Ignore percpu threads for imbalance pulls Valentin Schneider
2021-04-09 11:24   ` [tip: sched/core] " tip-bot2 for Lingutla Chandrasekhar
2021-04-09 12:05   ` tip-bot2 for Lingutla Chandrasekhar
2021-04-09 16:14   ` tip-bot2 for Lingutla Chandrasekhar [this message]
2021-04-14  5:21   ` [sched/fair] 38ac256d1c: stress-ng.vm-segv.ops_per_sec -13.8% regression kernel test robot
2021-04-14 17:17     ` Valentin Schneider
2021-04-21  3:20       ` Oliver Sang
2021-04-21 10:27         ` Valentin Schneider
2021-04-21 12:03           ` Peter Zijlstra
2021-04-22  7:47           ` Oliver Sang
2021-04-22  9:55             ` Valentin Schneider
2021-04-22 20:42               ` Valentin Schneider
2021-04-28 22:00                 ` Valentin Schneider
2021-05-06 16:11                   ` Valentin Schneider
2021-04-07 22:06 ` [PATCH v5 2/3] sched/fair: Clean up active balance nr_balance_failed trickery Valentin Schneider
2021-04-09 11:24   ` [tip: sched/core] " tip-bot2 for Valentin Schneider
2021-04-09 12:05   ` tip-bot2 for Valentin Schneider
2021-04-09 16:14   ` tip-bot2 for Valentin Schneider
2021-04-07 22:06 ` [PATCH v5 3/3] sched/fair: Introduce a CPU capacity comparison helper Valentin Schneider
2021-04-09 11:24   ` [tip: sched/core] " tip-bot2 for Valentin Schneider
2021-04-09 12:05   ` tip-bot2 for Valentin Schneider
2021-04-09 16:14   ` tip-bot2 for Valentin Schneider

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=161798487184.29796.7421551105074944506.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=clingutla@codeaurora.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=valentin.schneider@arm.com \
    --cc=vincent.guittot@linaro.org \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).