Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp922195pxf; Wed, 7 Apr 2021 15:08:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFS2iDGxwCDrDNrpGxOrzOD2yd09S1F7DYurD9LLAbx6024xWz7lyc8kVarckDeVdmV9EP X-Received: by 2002:a17:902:be0c:b029:e6:f007:71d with SMTP id r12-20020a170902be0cb02900e6f007071dmr4993796pls.15.1617833303197; Wed, 07 Apr 2021 15:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617833303; cv=none; d=google.com; s=arc-20160816; b=m6xIipsNi0fgQO7DWzKBektCycIzU791S+N7RMsL9KBwVHn6jx/nqBslxynWFSbdT0 ZkUf7vq1RKfJjJM+G/AE+T5rTN2v/anyRmQWc+LhJIIhqDj3sDSA7m8+r596Em5yUni9 ElaRECCvXaa0vp+GJf08VQ8/iazoAdIobKgtjo8yylps8lB8sjZoGVFEIdfWYs7Ituao C9wyvJweOnpeOKO5LQMygmDfwwZcAANPVIrbd4YtpLsR1CHhimDGzW0gO28uUsrqsFY2 P2wWWFzeEgHLY0V5DBd25Hx/XtnFu2ckk0bN+fUJOXjuT3Vpd86fkfg0O1rwbmTE36vW E9/w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Ei/AJrpqfr/P5S7e6zzvstVzvoOnrqu+Iy4KeOL+eng=; b=AUmyfDM3vWRzr35ODyl0DkpWpDMWEDoNxYY80n65CbHq0K4bvxqWM9EgAHQobYQTIY iVZg7GwL2jwOxHjn6TZ76rITA9wrslHDLH8en9mmF2KtPYjr5Jv7m7l7VkHc6utLQlt9 hLOnjEXx5ev1iDAzaab/Yly2vMB5DKk51GSfHW8T7vjFGn3trznnI0O6l6mzT89dIT4W EpHr2OrT7az5E3V1KfjDGb87FwTAIubPZlnDJP4be+BZ4Rus18wh5czTV9WbKMhsyLvd S9Y8QmXkdb4jD9FDuVyLhWqH0IgUgbCFRIaCNxqSYv4rU3ZHJ7RA4zl0efO7Ug0s8JZc o9Kw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mm20si6968703pjb.22.2021.04.07.15.08.10; Wed, 07 Apr 2021 15:08:23 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229830AbhDGWGv (ORCPT + 99 others); Wed, 7 Apr 2021 18:06:51 -0400 Received: from foss.arm.com ([217.140.110.172]:35752 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbhDGWGu (ORCPT ); Wed, 7 Apr 2021 18:06:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CAD3C1435; Wed, 7 Apr 2021 15:06:39 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 44E8F3F792; Wed, 7 Apr 2021 15:06:38 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org Cc: Lingutla Chandrasekhar , Vincent Guittot , Dietmar Eggemann , Peter Zijlstra , Ingo Molnar , Morten Rasmussen , Qais Yousef , Quentin Perret , Pavan Kondeti , Rik van Riel Subject: [PATCH v5 1/3] sched/fair: Ignore percpu threads for imbalance pulls Date: Wed, 7 Apr 2021 23:06:26 +0100 Message-Id: <20210407220628.3798191-2-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210407220628.3798191-1-valentin.schneider@arm.com> References: <20210407220628.3798191-1-valentin.schneider@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lingutla Chandrasekhar 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 Reviewed-by: Vincent Guittot Reviewed-by: Dietmar Eggemann --- 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