Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1474563pxf; Fri, 9 Apr 2021 09:15:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTEtSu0oJqJvLzlgpJIvxVFoohmaNXrvXXz59v1fhomNvB+qnY/0H/wqVVwy5XHu9FiGfE X-Received: by 2002:a17:90a:f2c2:: with SMTP id gt2mr10202349pjb.139.1617984937633; Fri, 09 Apr 2021 09:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617984937; cv=none; d=google.com; s=arc-20160816; b=EdwPQ3EhzA8wBY43l1Z9ezYxPnltkks5/YqidZDIvbrjA0NaVKpsgzN9n1u05tMPb1 y+9+KpnZsFqsxYthtbRjd++8OK/aXTNIzd+cfPfiuYc4JO1BtZPJjfDge9n0HAui0nuT Ab+UMAnAx7NykenoZGTpvAxNoG3qXaAb0fj2LM7iBflNSZ6NxucnVOYIuBrkZ5cBctQs zpmxXBs6kwN0hU0l5NumB8d3OJeCMHjWEZALMVtNgxo7jinNAS66NwKDtglnYepISFGc 41Ok3tWRkfKk9l0GbivHl2UsVaQspLsXCVknzbXyydrfeLtPsZ02DAq8y1GSTYy7JQr9 adMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=mWzxCR8+J1Ube9Q5GtGoZlPplWdVgh4JYcxWVgzbuSU=; b=gqmMx0tiW5IgFPR6zHpHOhZb3uqZGpQBrmzHx8Wi3/Bd3plWHTrzVM8sOfTV9jaCDk fgLauLbKzeibxPEoROSlskOtRoiRXh65PGBI/YYscRmq1wuRZIRWR7spry8/esEyL0cx fHUTXqpFyDQkxCk4VAfPz9mPxFHJkSDhIjhd+4m4yYJarDXVhA6PnUe9iBcZ6qsIdnje QticwjgI4gK/97cK0V34sU1vjJA6vF61gAs2Sj7HMVa+kw5Wn4F7ElPYVhRJWyVA269S 94cj2miVLgsXYbH84FGUzyq5F3L/20rax5ibGegTT8Jqtn+E6AGd95gGTX6vmF1kaKUY 3mxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pJqbSR7F; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fz1si3393179pjb.108.2021.04.09.09.15.25; Fri, 09 Apr 2021 09:15: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=@linutronix.de header.s=2020 header.b=pJqbSR7F; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233837AbhDIQPB (ORCPT + 99 others); Fri, 9 Apr 2021 12:15:01 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:51606 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232395AbhDIQOq (ORCPT ); Fri, 9 Apr 2021 12:14:46 -0400 Date: Fri, 09 Apr 2021 16:14:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1617984872; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mWzxCR8+J1Ube9Q5GtGoZlPplWdVgh4JYcxWVgzbuSU=; b=pJqbSR7Fb3b61zLgsRqcOqI5FR8uvOLTb58gRrjxWUAswwtpi1RXL/GXGObrR1y9P9utvZ YsZp/zVjvnnomo1X8kiu77G59fhop1mxXapEKraHUNnZSMHlhHkzUOLWuLnyYWaIZwbrtY 5hiWkSq6BJhios3fht+ifCQZ0PhDbdp8G4Q9GmIsNQpolGZPtdqaoUgkSbdurNjKoGIE59 BlMXyhNO7LkRPOrhEumQumLz4ObFNpLEnrQbOs4iO8MyviHvFMdedPC33tD/IknT9eKU8X A1DzIEXGqQQmCH+JCLY252o4LE5QdmO+xQTG+gQIE3gajLkLgyH2rj11nZsXjg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1617984872; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mWzxCR8+J1Ube9Q5GtGoZlPplWdVgh4JYcxWVgzbuSU=; b=alX3rYWvRahxDZShA+HFKv5VRwTFhEIISs/JzXTb/zaSw3dDLQJ35fsJFVxduJtP9jyNut DC9rRjgTQXEIwkCQ== From: "tip-bot2 for Lingutla Chandrasekhar" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/fair: Ignore percpu threads for imbalance pulls Cc: Lingutla Chandrasekhar , Valentin Schneider , "Peter Zijlstra (Intel)" , Dietmar Eggemann , Vincent Guittot , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210407220628.3798191-2-valentin.schneider@arm.com> References: <20210407220628.3798191-2-valentin.schneider@arm.com> MIME-Version: 1.0 Message-ID: <161798487184.29796.7421551105074944506.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 AuthorDate: Wed, 07 Apr 2021 23:06:26 +01:00 Committer: Peter Zijlstra 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 [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 --- 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;