From patchwork Mon Aug 17 15:13:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 247846 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2866938ilo; Mon, 17 Aug 2020 11:33:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJym0vsz1wh1YMYw9oXzB6tXWr67TruODF5YL7p2SUFaWv9sP+odr4bT88oiea2fQoHv1Nu0 X-Received: by 2002:a17:906:c7d3:: with SMTP id dc19mr16360103ejb.495.1597689191039; Mon, 17 Aug 2020 11:33:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597689191; cv=none; d=google.com; s=arc-20160816; b=H/5U9KBNYJtAC/AD0BNc9BKKvG3gJkFJfELP7/T8HFTF23Or0MaKdrIQ4uFEzb4pLJ NrwBAJAIg120BHFWh+fWsXTjdwuYvl6SIhCjlv5eEiOJ9wF1sI94DlV5oodIkO2q14w9 Szuce9Nlzczr438d8SMvPQet0Z47SYCbAkDV8kEXBjO2KhiPBR64jzA0pB06mW8QYLy2 er1a4nlX9zbKnagsncBmuqkG42M9WJzX2aAp+x+QPTB906TLviHT4ZAFGNZkxiG29Gzk oAw+6gsudA+CEUQpubOnAIilPrpdBpUo75ZhpnIAqpAsHygF3SxFtS90Rr594IiUqf7U MeIQ== 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=46skSP09KKZ9IHTq8Mk1o1qzAu6LqWB+gT9aQMHDIIY=; b=NZvfV8Y6YgOKGVLLlJYnRKBhBQ4IMHFPp9UO7Mc/bK2CBcDqf99ut8xyRwuBE0OGC6 ky28AGpcX3kNInIQb5G+G5oETtZOCKutfTPO2p1e9Tpa93kxisAfCCMxILid4i3Tn7Ye 0CmADB7oMLVcJ3BopLtTf0kTXpBIgn7SSCLyyyZE7HWBlY6wr4uK857peX39R8IrpZXJ MWViKDNTG1267RSpDkVCKa0tydiByv4g7RlIL/yFPwraKmVz1HNJBC7BQ1vv2dBHcmam O6MSaXAgT4j6VZGWkp+JrhUaBuxpxYxUQAKmjQ6XQlUG02SjgfGB1tZMccLs71wo0QaO OgHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uvzN39dp; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 h6si12624314ejq.39.2020.08.17.11.33.10; Mon, 17 Aug 2020 11:33:11 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=uvzN39dp; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S2391156AbgHQScw (ORCPT + 15 others); Mon, 17 Aug 2020 14:32:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:48138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387560AbgHQQAo (ORCPT ); Mon, 17 Aug 2020 12:00:44 -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 C3BC320885; Mon, 17 Aug 2020 16:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680043; bh=cytyOljv7NTOTrVBQRiR1DPgvbeXqME725xfguHR8S8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uvzN39dpuDg1BeBRKMu0VV8twt+AM/Q6s/qXE5EaYSp9whIdEiUmNysM761iwUqju BbHO50eiEb3BICZDpZ4w4hbjgNL5j07+Lrah5bGQdZjowVd9m+WV3GaS/QjbALiKfo sIrjAl/MEPRikfyWidBdJ4/V1u3OlJLbc3rzwrXo= 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.4 007/270] sched/fair: Fix NOHZ next idle balance Date: Mon, 17 Aug 2020 17:13:28 +0200 Message-Id: <20200817143756.173459004@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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(-) -- 2.25.1 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 9b16080093be1..20bf1f66733ac 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9385,7 +9385,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(); @@ -9703,6 +9708,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); @@ -9723,14 +9736,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; }