From: Valentin Schneider <valentin.schneider@arm.com> To: linux-kernel@vger.kernel.org Cc: Lingutla Chandrasekhar <clingutla@codeaurora.org>, Vincent Guittot <vincent.guittot@linaro.org>, Dietmar Eggemann <dietmar.eggemann@arm.com>, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@kernel.org>, Morten Rasmussen <morten.rasmussen@arm.com>, Qais Yousef <qais.yousef@arm.com>, Quentin Perret <qperret@google.com>, Pavan Kondeti <pkondeti@codeaurora.org>, Rik van Riel <riel@surriel.com> Subject: [PATCH v5 1/3] sched/fair: Ignore percpu threads for imbalance pulls Date: Wed, 7 Apr 2021 23:06:26 +0100 [thread overview] Message-ID: <20210407220628.3798191-2-valentin.schneider@arm.com> (raw) In-Reply-To: <20210407220628.3798191-1-valentin.schneider@arm.com> From: Lingutla Chandrasekhar <clingutla@codeaurora.org> 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> Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org> Reviewed-by: Dietmar Eggemann <dietmar.eggemann@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 6d73bdbb2d40..04d5e14fa261 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7567,6 +7567,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; -- 2.25.1
next prev parent reply other threads:[~2021-04-07 22:06 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 ` Valentin Schneider [this message] 2021-04-09 11:24 ` [tip: sched/core] sched/fair: Ignore percpu threads for imbalance pulls 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 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=20210407220628.3798191-2-valentin.schneider@arm.com \ --to=valentin.schneider@arm.com \ --cc=clingutla@codeaurora.org \ --cc=dietmar.eggemann@arm.com \ --cc=linux-kernel@vger.kernel.org \ --cc=mingo@kernel.org \ --cc=morten.rasmussen@arm.com \ --cc=peterz@infradead.org \ --cc=pkondeti@codeaurora.org \ --cc=qais.yousef@arm.com \ --cc=qperret@google.com \ --cc=riel@surriel.com \ --cc=vincent.guittot@linaro.org \ --subject='Re: [PATCH v5 1/3] sched/fair: Ignore percpu threads for imbalance pulls' \ /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
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).