From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1E28C433DF for ; Sat, 8 Aug 2020 23:40:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C037F20855 for ; Sat, 8 Aug 2020 23:40:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596930007; bh=xm0scWgzMNXX8bY1xq1gncLZTXDqTEw3T28QhQlMysI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=hhLKX3lPbBD7EEQFEwH9ZD+6PwBfqK5G3/iNhebis7b865H04VFBq4rwnrtoat0Hq Y7AOr1qEZUQN4aZjtkjImCneYZKAnZaUyInnS8qN1V8C6pPgNfmdHos7vEPN5tBq+w xy+wWTN6ztuAVPeEtxiPmdMbj0gYHPsYLYc00aAY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728721AbgHHXkG (ORCPT ); Sat, 8 Aug 2020 19:40:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:54700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727797AbgHHXjp (ORCPT ); Sat, 8 Aug 2020 19:39:45 -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 D00B920855; Sat, 8 Aug 2020 23:39:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596929984; bh=xm0scWgzMNXX8bY1xq1gncLZTXDqTEw3T28QhQlMysI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xVdbpA1ycZ71TKgQsh3j6CwYn2Pd2SU7xu1kS+kM/4wDSz9J8/kw6bgVHYrQ+mhf+ 8H8LbOkqcbVVP5BLsfaLrB0reDujK9oF7oPH2OOteRmKmhVaBQANAcc446iXmZbRju k5I+G7iaKHSy71r6ZMGsHV5xzoK8PnQ+xgQ4LSPc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vincent Guittot , Peng Liu , Peter Zijlstra , Valentin Schneider , Mel Gorman , Sasha Levin Subject: [PATCH AUTOSEL 4.19 02/21] sched/fair: Fix NOHZ next idle balance Date: Sat, 8 Aug 2020 19:39:22 -0400 Message-Id: <20200808233941.3619277-2-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200808233941.3619277-1-sashal@kernel.org> References: <20200808233941.3619277-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 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 d8c249e6dcb7e..696d08a4593ef 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9208,7 +9208,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(); @@ -9503,6 +9508,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); @@ -9523,14 +9536,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