Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2484314pxj; Mon, 10 May 2021 04:12:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc7OPjPOOvFQESvzizbb7uvjKqoyS0Q9Vr9Lxv5nMhRz73NpZX748fwLuwQjmkNVrVmAXl X-Received: by 2002:a05:6638:2643:: with SMTP id n3mr20819386jat.104.1620645157141; Mon, 10 May 2021 04:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645157; cv=none; d=google.com; s=arc-20160816; b=0z66X76pme5trRXrcORp+Y/OjcX7VsZKnSa4MlX3QgH/D06PX+rXpTzOhLnE0uRjpU 57Ij1yPF0xLA13s3HoJJGT1jznEtPlywdAakClu6VLiCQn9x+LnC6QLr2ROyphQTqP1u mBl9zcMgcpZITWMOiSZWUFKWVM8CRXmv5dPuJq4PSuOWbW+JQplraoujK13Sp6T5k6jb lNV8e9u5ZiQzpVqbU6NWYsbRvt5ooSHKz3Hyucx4w1OUnfhq4aiwpnzsUrL1CT2OzZoz Wv33Zgex6GS65SLkUJyCV3Tl5lYEP7bGv4FsSmeBlj/Tqe/TxOIDiPjc37jm4pHMBUsM VTZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LBDZtwzTn6NR6i4XAkyYV2+9Jo+Ca1gzwilez+pPkPI=; b=da69tzXu/JCFQhnTtAcjim6peHeCZSe2hfMhogz5gsG1ZvX2dIUNUAI4Xdrsyp5t6p lYXb0GjoMw5wHnSnsndKW4dZ4fE3yKJr2B2OIZYiGo5JV9nTtDYFd2AfwQy1ouAd9h5u CknJqnfoadfc8N7UQrMEoeQ9ztMsrXcepoL8qXH57QIbN8ufIG7znXdbNFv9t7IuWTWi bNb7+ScxrrmEpaTJmFyqwoZZyYns37Pc64rkndxrEdHYF/M0ZjBHy6s4PClZy3nYTLmT FpJWMnajiOlJ3vQarDiCD/9tpMRO6EUMuteB28iLFVuOjn/8XMMkqQVnGVm8ByInP0Bz HMWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HiRdfZUR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c16si15628933ilh.10.2021.05.10.04.12.24; Mon, 10 May 2021 04:12:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HiRdfZUR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237221AbhEJLLg (ORCPT + 99 others); Mon, 10 May 2021 07:11:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:41732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233214AbhEJKtv (ORCPT ); Mon, 10 May 2021 06:49:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A167461585; Mon, 10 May 2021 10:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643118; bh=Xnzjb+FsT7+G9jlVObWkuaYMYrYQsJmC7M+t5r9/v8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HiRdfZURfkFONgYB2vn5NObgPZDEVL9xvmX8jdzC523Rxb8PA/lPAimeQTk5psKEV GZ8en5IlWzJ8Zw+B6FBfw082l7UxlCEdIgJWXEt0Qm3aajzCxB5FwoyyUiWZCtWo5f NfaXnz6Ox9WYOgK81JL+Mk28MBzM0z8Gik8CmofM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lingutla Chandrasekhar , Valentin Schneider , "Peter Zijlstra (Intel)" , Dietmar Eggemann , Vincent Guittot , Sasha Levin Subject: [PATCH 5.10 185/299] sched/fair: Ignore percpu threads for imbalance pulls Date: Mon, 10 May 2021 12:19:42 +0200 Message-Id: <20210510102011.069570656@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lingutla Chandrasekhar [ Upstream commit 9bcb959d05eeb564dfc9cac13a59843a4fb2edf2 ] 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 [Use kthread_is_per_cpu() rather than p->nr_cpus_allowed] [Reword changelog] Signed-off-by: Valentin Schneider Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Dietmar Eggemann Reviewed-by: Vincent Guittot Link: https://lkml.kernel.org/r/20210407220628.3798191-2-valentin.schneider@arm.com Signed-off-by: Sasha Levin --- kernel/sched/fair.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 8f5bbc1469ed..481f4cc0958f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7552,6 +7552,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.30.2