Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2542350pxa; Mon, 17 Aug 2020 12:15:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCR1ncRhAWS/iCs4vFkY8zsw5daEUNG4s7BkyQf3BcoKtE0EUi7Js12qdFh03TIm8AfzFy X-Received: by 2002:a17:906:8595:: with SMTP id v21mr17236247ejx.347.1597691752068; Mon, 17 Aug 2020 12:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597691752; cv=none; d=google.com; s=arc-20160816; b=bm8MzhGaITgUplZoNWgAZOqYDxiHSEMMFR7KdRVeNhb/HSbp2DvJsSXPBiTHGB0Fi4 hiOlYA3cyBdxzwPlrfrsi922BETRIbt3CfmpghAs3cAtWfsKCuG12I94KR4hhbw2CAxv EkhR8vxbA6iy3TTqvav+MXpCvE8K5EbrjdjdP+c2+5dlwDGQjj+zUqzS2uXMtxE8M6eM M9JgwIKpccbXDcdHaZJpubRN0Ok4petARnGYMD/yB3lzQu0JMfb9t3j+B3jlp7jYK7tn 3M3LPZmZ6EyY7rLLg3dH78LR3DectaQ2QnQdMduPCMUcCYD6WWJnZy+Hyet1McPrQHx2 MehA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9eI95K4Xcn8A11mbwfwMecYJLTMCtLzTJBY87WW3Djg=; b=Fd+tAxDBBlY/D+Ro0OVUYgS6QcBwZ/TpWuRlIEcP0MJk5O5YIc+akry7j138BufNC2 GaeKFcKpFK2mV11GOio3sDdaY8HfRVWqUG1aWfzR/jTlqF/+avIOzV9fS0b8x6Beb+ZL S02ORq1sMvhUqvjKtm2iGllmdvIXvIa6n7X93P3gO6XsvSrTCeY6ftg7ULmxBNVU7g9Y 0YO+YVgWjknQnCHHiTCJUqlZDd8YQoo9GjEK2HctYJEz3jWlWKnZTKtGatWaLSgOMfrU V3ofF9zAzpP6v798pKZqT0/aGTSHDB0LOtFXxYIyS+RDBfPlPfaI9tQtVzceRslGURCZ o0qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ZHkpE/ow"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n16si11429004ejj.284.2020.08.17.12.15.28; Mon, 17 Aug 2020 12:15:52 -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=@kernel.org header.s=default header.b="ZHkpE/ow"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392036AbgHQTMr (ORCPT + 99 others); Mon, 17 Aug 2020 15:12:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:49916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730384AbgHQPkq (ORCPT ); Mon, 17 Aug 2020 11:40:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EA26E20760; Mon, 17 Aug 2020 15:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678845; bh=4ZMcA9lxt25C+CH9qI2a6HgE43khl92nn/Elyq4fcy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZHkpE/owcQ85ZLpFEYRNJNPhKFlvV4nO9I14Zzkb5+QrsKT0L+u6oKfbbfeeqlsww c4LJPRtMYdelRUESmWBgrukccYTUTsQ1zhGMEttaSZ+WtIaufl99KXgDgU2qXRU+X9 oLYJlG2Uu7A0MJhpQJJeHb8oIEz9RjCprYizro78= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Liu , Vincent Guittot , "Peter Zijlstra (Intel)" , Valentin Schneider , Mel Gorman , Sasha Levin Subject: [PATCH 5.7 010/393] sched/fair: Fix NOHZ next idle balance Date: Mon, 17 Aug 2020 17:11:00 +0200 Message-Id: <20200817143820.097729241@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 3ea2f097b17e13a8280f1f9386c331b326a3dbef ] With commit: 'b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")' rebalance_domains of the local cfs_rq happens before others idle cpus have updated nohz.next_balance and its value is overwritten. Move the update of nohz.next_balance for other idles cpus before balancing and updating the next_balance of local cfs_rq. Also, the nohz.next_balance is now updated only if all idle cpus got a chance to rebalance their domains and the idle balance has not been aborted because of new activities on the CPU. In case of need_resched, the idle load balance will be kick the next jiffie in order to address remaining ilb. Fixes: b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK") Reported-by: Peng Liu Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Valentin Schneider Acked-by: Mel Gorman Link: https://lkml.kernel.org/r/20200609123748.18636-1-vincent.guittot@linaro.org Signed-off-by: Sasha Levin --- kernel/sched/fair.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5c31875a7d9dc..e44332b829b4d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10033,7 +10033,12 @@ static void kick_ilb(unsigned int flags) { int ilb_cpu; - nohz.next_balance++; + /* + * Increase nohz.next_balance only when if full ilb is triggered but + * not if we only update stats. + */ + if (flags & NOHZ_BALANCE_KICK) + nohz.next_balance = jiffies+1; ilb_cpu = find_new_ilb(); @@ -10351,6 +10356,14 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags, } } + /* + * next_balance will be updated only when there is a need. + * When the CPU is attached to null domain for ex, it will not be + * updated. + */ + if (likely(update_next_balance)) + nohz.next_balance = next_balance; + /* Newly idle CPU doesn't need an update */ if (idle != CPU_NEWLY_IDLE) { update_blocked_averages(this_cpu); @@ -10371,14 +10384,6 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags, if (has_blocked_load) WRITE_ONCE(nohz.has_blocked, 1); - /* - * next_balance will be updated only when there is a need. - * When the CPU is attached to null domain for ex, it will not be - * updated. - */ - if (likely(update_next_balance)) - nohz.next_balance = next_balance; - return ret; } -- 2.25.1