From patchwork Mon Aug 17 15:09:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 247881 Delivered-To: patch@linaro.org Received: by 2002:a54:3b12:0:0:0:0:0 with SMTP id j18csp2601033ect; Mon, 17 Aug 2020 12:51:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgvaQXMzrq/YtyFjI2ThoKI32m3FX/YuXFHPXoRcut/4ij2xSQj0RYC6qMX8YMq92CCEh4 X-Received: by 2002:a17:906:970a:: with SMTP id k10mr16543639ejx.189.1597693895240; Mon, 17 Aug 2020 12:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597693895; cv=none; d=google.com; s=arc-20160816; b=SBcnV2ca3HZnuwrW8hMq91zQEtZfPgy+7Bg3iy0FOwEcSDy1EEOyGiUc7ik20yg7yt hKKKvd7e+eg/X/xwNiV4Cghp8XV842GnwZX5+VnA63KF5fNZTkmgt+b9HY4+HZZuqpIy HR4WQlsPT2qMXHA+FUTSR7PZ4ciH8LHqgWy6+h9BReul5E8UJlH8MqtURuoYVdUDZLaN b+OExENbkcHeggLYrKTywanca9aYk3jrT5UJBjkQ+FkTvIxOE+4fDLeDV02jna5NLATZ pyUYiPLYUpFGqG5n/5C8ts19ZQX8sbvroHTBJB/4tTVvr4lDcZahYszxlJnKux51rXjN bYEw== 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=7SsYBoEpFrHONqFrDf4awMdTmjva+uZ8A1IgL8oe3So=; b=Qkzk0/VYGU2uofkHgILN6Io/fez3WLuChsdld0mrNjPaWHDVDF6UC7Z1QDEqUuJgxO GHdZKXPPZN8rJbyAJUC5ZuuuBhAYbItrABP7lVBWvPW5pLoV4ZK4IJwFJjxyMKKCA7r8 /ZhGDThfDs002g8/1TKJ/IVjt9sESVyknArKcFZB0LaZYJ97SIwVSJotw2xGjClDtZsZ WTXe5C0E7kjafuVrD1YZ5trwLof7D0vWz+90yf+jQZvUkUtoiZGZ9zxWRChsHQNB0GFC dmitBnILP3V3zeQqmK4OQDafuQdNePtf/+cwbCuJpVNBNnq17soVl0UMiH1pqFNfJjoZ 09YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Y7SkMb/u"; 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 h24si11598872edv.128.2020.08.17.12.51.35; Mon, 17 Aug 2020 12:51:35 -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="Y7SkMb/u"; 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 S1729436AbgHQTvd (ORCPT + 15 others); Mon, 17 Aug 2020 15:51:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:40168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729138AbgHQPSh (ORCPT ); Mon, 17 Aug 2020 11:18:37 -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 0B84620716; Mon, 17 Aug 2020 15:18:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597677517; bh=Zm0JTxqN7Lag/Job7R8Q84ETS3hXl6RidvnjycO/Xu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y7SkMb/uqzLj8z1KH9zDddKtzP/X6NMzkYwc6cudbp9LrKqcAypeXf7APzghsTPrt w+L6yERPi2zzsB1myGe7yqr/F/4Fi8mV6+0sFCvhXuD7kX43jNaS8Bu92vpb+pC2uI ruxU3k+BXHPH3tG1eCxzxbaHwiN8YgG7ILugVJKI= 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.8 012/464] sched/fair: Fix NOHZ next idle balance Date: Mon, 17 Aug 2020 17:09:25 +0200 Message-Id: <20200817143834.344555529@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@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 04fa8dbcfa4d7..6b3b59cc51d6c 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10027,7 +10027,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(); @@ -10348,6 +10353,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); @@ -10368,14 +10381,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; }