Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp766968ybc; Sat, 16 Nov 2019 08:19:45 -0800 (PST) X-Google-Smtp-Source: APXvYqxu/PtPx8q3zZJoHNKIyGYAfHU4aQdUFcAbRSW3vY7jl79GqZjCA4jTANCqQZ/y3ZBg5AzJ X-Received: by 2002:a05:600c:2253:: with SMTP id a19mr20978222wmm.97.1573921185559; Sat, 16 Nov 2019 08:19:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921185; cv=none; d=google.com; s=arc-20160816; b=lR4m/bYzWOvHNZ7+TPpTbLYjaabNlm/MdhTOGbFk3sT0CBhPWdp62Q1wvNR+3wnYe0 qZMt1NRTXldHtG6kUe0FR/tD1PI22U9LLDaZ05OGefG6I9tuy7hhM8b5P9/a7ZvVA80C pw9eGUVFBX2TNB0IiA2ul8KfLA0grPGeJuXrhBw7GLXPl36WAgWhUlpte4oNrpzPAig8 3WrWbxKpnSM6Ezm3B3K2uKOCstwDv//cAkYFh0ClPbBnllq1r9pTEPsYd+HS52RRj4OF bXfa/FxaNSZweECOo4Bv52PmEg2H0Bq1XK5lq7jHkeVkUY0cL4m3uy5XnGs/j2XH27uA uGAw== 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=EKM5mWyHW3YNrL2Bug99Q4azrTM+Y04OfQa7pldp2Dc=; b=mUuq/UDOEEF7lReDbNTMkjVGU9NYiu6zjwVDP+tNDuIcTRJBkRXR0JF30ZOzOHuy2k VKYLWIBRIxz6jT201nw6oBS/8071jH4GbSB4VEWGA5kpD8rA+EG55TYHHRwLbyTWFqOv NGWkRzpMrWCDGljMX7/pglB90OAleR5LiGq03GSL5DO8hPC/DV/ix9qO66473APLjIyr nBp57D7y1PrCPJa5Q2o1bNI2qYeX/41UZxmHbo5ZkcypHmXNvacdNeynVZZUX9AnSywI 23bzH4iJ75DMHLmfWlcnsmKZZAz2GL88sta/9/4Ir7eU5rUPpE6aU2kHbAABCzj/7dIT Gxww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GLFGHRj7; 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 y2si7843866edt.191.2019.11.16.08.19.19; Sat, 16 Nov 2019 08:19:45 -0800 (PST) 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=GLFGHRj7; 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 S1729542AbfKPPqx (ORCPT + 99 others); Sat, 16 Nov 2019 10:46:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:52600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728631AbfKPPqR (ORCPT ); Sat, 16 Nov 2019 10:46:17 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (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 9B6A020830; Sat, 16 Nov 2019 15:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919177; bh=g5JG3N6L0NyVvDNzIuGXVjudP/DJfzVs1xq1Vs9a7Kg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GLFGHRj7cueGZGQY/IG5zfJVyshenXHqQSDHOOtexa6LeoOw6l3J+OfNQsRZpWWVH EGa3GZLBoBbOc7DbjDaqS1s2JhwweUcwN3BOQ2yoP2suHhRs9hTDj2pr+ac4BBBQRD myVo0+DLu4bsdFAyAOZGqguKKrKjKKUFs70dKKew= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Valentin Schneider , Peter Zijlstra , Dietmar.Eggemann@arm.com, Linus Torvalds , Thomas Gleixner , patrick.bellasi@arm.com, vincent.guittot@linaro.org, Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL 4.19 185/237] sched/fair: Don't increase sd->balance_interval on newidle balance Date: Sat, 16 Nov 2019 10:40:20 -0500 Message-Id: <20191116154113.7417-185-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-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: Valentin Schneider [ Upstream commit 3f130a37c442d5c4d66531b240ebe9abfef426b5 ] When load_balance() fails to move some load because of task affinity, we end up increasing sd->balance_interval to delay the next periodic balance in the hopes that next time we look, that annoying pinned task(s) will be gone. However, idle_balance() pays no attention to sd->balance_interval, yet it will still lead to an increase in balance_interval in case of pinned tasks. If we're going through several newidle balances (e.g. we have a periodic task), this can lead to a huge increase of the balance_interval in a very small amount of time. To prevent that, don't increase the balance interval when going through a newidle balance. This is a similar approach to what is done in commit 58b26c4c0257 ("sched: Increment cache_nice_tries only on periodic lb"), where we disregard newidle balance and rely on periodic balance for more stable results. Signed-off-by: Valentin Schneider Signed-off-by: Peter Zijlstra (Intel) Cc: Dietmar.Eggemann@arm.com Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: patrick.bellasi@arm.com Cc: vincent.guittot@linaro.org Link: http://lkml.kernel.org/r/1537974727-30788-2-git-send-email-valentin.schneider@arm.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- kernel/sched/fair.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e5e8f67218728..f77fcd37b226f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8819,13 +8819,22 @@ static int load_balance(int this_cpu, struct rq *this_rq, sd->nr_balance_failed = 0; out_one_pinned: + ld_moved = 0; + + /* + * idle_balance() disregards balance intervals, so we could repeatedly + * reach this code, which would lead to balance_interval skyrocketting + * in a short amount of time. Skip the balance_interval increase logic + * to avoid that. + */ + if (env.idle == CPU_NEWLY_IDLE) + goto out; + /* tune up the balancing interval */ if (((env.flags & LBF_ALL_PINNED) && sd->balance_interval < MAX_PINNED_INTERVAL) || (sd->balance_interval < sd->max_interval)) sd->balance_interval *= 2; - - ld_moved = 0; out: return ld_moved; } -- 2.20.1