Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp776767ybn; Tue, 24 Sep 2019 09:19:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLtBhFRz/A1dQlMc+xbNzZFhK4I48jCdpPuCW8sGhM4VQoSWJnqaIXC3GgLqlSmuM/I9hD X-Received: by 2002:a7b:c764:: with SMTP id x4mr995054wmk.138.1569341959411; Tue, 24 Sep 2019 09:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569341959; cv=none; d=google.com; s=arc-20160816; b=BFkqifgac45XuWiKVQWi+EwSqxtPnvd81nBPzLMJSwDFgrXVEU4LBw8X/HCgpUFyth 5Pf0RXQSB/rej9KFnh3yZKav7uCqAOBSI0qvmtgbsAiZAwafVK+bVze1VHym3vuIo2Rn +enXU36LKitVJRsoOpJuedz/DeVdvFIP/7p7S8IWEpfQr98+GLuBGPjvLcXd0r+DffLQ n2uyMYjfMhzxkH2ZFJNpDy+LkfSiDf8jL4H7coox8qOfgoxdIf6N+Ed4b69+/C2zY/4w yFizLPNqUOi33dxZ1aBEH5T4l0jExe1wRTzqJ4L9zTepkOG+xh7HEoCHZ1W/6lc/J3na TPWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=T85Mt7ceCZCc6xb2hg1v4u3najU42avN/Q4U+mTTaYc=; b=kduGUpYu9ERJmnyNc87No4cokWlgUJHOtmE5WTiBgn6LpbopUPY3Jleae3VS8ND9Ri eYV0rGmPccfhmLscUho+H4l/HOqULZgEm6vY8KSpZc8g5z68YdyMMRUwpdLJvStAldbd R0Bvsm6hnEb8eGgzgTRYENbOnyDvGA2sEHnoTq4HXuf/cl6P53Du71PI9JOGvLUWAYhn jMXdLmxt8t94EX1+YquWKnj+jxUIfuEq2/JtW+PJFWN3cjRZP4QlRQex7Eyz22Wiaxv+ 2OxW5Cz464j0RRf9irll9y2Gi4NmExmx9X7I/p7AZcn3JmQ2o9Hh6XiGeozcdr4+FxOj /ypQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QPe57gk1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g32si1422631eda.330.2019.09.24.09.18.55; Tue, 24 Sep 2019 09:19:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QPe57gk1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439320AbfIVTjL (ORCPT + 99 others); Sun, 22 Sep 2019 15:39:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:40718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388007AbfIVSpJ (ORCPT ); Sun, 22 Sep 2019 14:45:09 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 549F4208C0; Sun, 22 Sep 2019 18:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569177909; bh=ZC9lpSM5Wj6CgnpGxKHza4H16yIMHAvueVMdgbA3+Lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPe57gk1OK9EmZCM263GijVwfUP9c7XAPi5MBjLf3/s/99Xcmoh3+Y3ao1bc1u789 ARkrUrExThjrb7NgaRmPILZBgunbFMVdDh0i8oHX7WiggYH+TWoJk7TKSRAiZAdW8M mWFQSDNUANzCHaN4nEPHrLZYnj1LjylitBbsnJVg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vincent Guittot , Peter Zijlstra , Linus Torvalds , Thomas Gleixner , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL 5.3 025/203] sched/fair: Fix imbalance due to CPU affinity Date: Sun, 22 Sep 2019 14:40:51 -0400 Message-Id: <20190922184350.30563-25-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922184350.30563-1-sashal@kernel.org> References: <20190922184350.30563-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Guittot [ Upstream commit f6cad8df6b30a5d2bbbd2e698f74b4cafb9fb82b ] The load_balance() has a dedicated mecanism to detect when an imbalance is due to CPU affinity and must be handled at parent level. In this case, the imbalance field of the parent's sched_group is set. The description of sg_imbalanced() gives a typical example of two groups of 4 CPUs each and 4 tasks each with a cpumask covering 1 CPU of the first group and 3 CPUs of the second group. Something like: { 0 1 2 3 } { 4 5 6 7 } * * * * But the load_balance fails to fix this UC on my octo cores system made of 2 clusters of quad cores. Whereas the load_balance is able to detect that the imbalanced is due to CPU affinity, it fails to fix it because the imbalance field is cleared before letting parent level a chance to run. In fact, when the imbalance is detected, the load_balance reruns without the CPU with pinned tasks. But there is no other running tasks in the situation described above and everything looks balanced this time so the imbalance field is immediately cleared. The imbalance field should not be cleared if there is no other task to move when the imbalance is detected. Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: https://lkml.kernel.org/r/1561996022-28829-1-git-send-email-vincent.guittot@linaro.org Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- kernel/sched/fair.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 500f5db0de0ba..105b1aead0c3a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9052,9 +9052,10 @@ static int load_balance(int this_cpu, struct rq *this_rq, out_balanced: /* * We reach balance although we may have faced some affinity - * constraints. Clear the imbalance flag if it was set. + * constraints. Clear the imbalance flag only if other tasks got + * a chance to move and fix the imbalance. */ - if (sd_parent) { + if (sd_parent && !(env.flags & LBF_ALL_PINNED)) { int *group_imbalance = &sd_parent->groups->sgc->imbalance; if (*group_imbalance) -- 2.20.1