From patchwork Fri Jul 31 09:49:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 51764 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id D753222D9C for ; Fri, 31 Jul 2015 09:53:51 +0000 (UTC) Received: by laah7 with SMTP id h7sf22400607laa.2 for ; Fri, 31 Jul 2015 02:53:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=ZPEllanJWG1LYHl/L2fUODiCwz+fYNR2APMJkNO0nUw=; b=fQKd4Nj22xnNlPw3ujJ9sihocVApzezLH+IfnGUUKqSG+F1dCI50r2mXAiMOl8tuYk VY3qtHq4b4aP893FVOphU9toJmpwfHyniQd8s6+OVx0X+cnqiqW8dZqA7j0EIKEHkOAS 9wgN46ff2WXgtkzAWU4UVija4JZaY/iYP9ACEBszkYlVBvQTRagEEmwB4ETmKqrs47dD j0b/NxhQb01vGvOKRP7nYsYX4bJI08QKfJ+RBx8bAodfvsBaxTkEGIRZReSmUtV8hS7d ZoM89t5Fe9eNtpMyfWBOlGkQJ95hCb9mjBXbqzgrjUdUaJh+oEWPMaYgVjaubQ+GzndJ mccw== X-Gm-Message-State: ALoCoQlVAqr43deDEKEhBLmnzGADqeVLw6cG37rnAZbC7YGmtx2wSycNTV0cPNsAspnJrynlAi2m X-Received: by 10.180.11.226 with SMTP id t2mr808644wib.0.1438336430753; Fri, 31 Jul 2015 02:53:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.166 with SMTP id kr6ls282043lac.32.gmail; Fri, 31 Jul 2015 02:53:50 -0700 (PDT) X-Received: by 10.152.9.137 with SMTP id z9mr1940048laa.68.1438336430227; Fri, 31 Jul 2015 02:53:50 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id tk5si415232lbb.14.2015.07.31.02.53.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Jul 2015 02:53:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by lacct8 with SMTP id ct8so7691863lac.2 for ; Fri, 31 Jul 2015 02:53:49 -0700 (PDT) X-Received: by 10.152.207.76 with SMTP id lu12mr1887331lac.29.1438336429425; Fri, 31 Jul 2015 02:53:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp269137lba; Fri, 31 Jul 2015 02:53:48 -0700 (PDT) X-Received: by 10.107.10.161 with SMTP id 33mr3191999iok.155.1438336427724; Fri, 31 Jul 2015 02:53:47 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id do1si9289821pdb.32.2015.07.31.02.53.46; Fri, 31 Jul 2015 02:53:47 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752714AbbGaJxm (ORCPT + 28 others); Fri, 31 Jul 2015 05:53:42 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:37414 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752194AbbGaJxH (ORCPT ); Fri, 31 Jul 2015 05:53:07 -0400 Received: by wibud3 with SMTP id ud3so24837059wib.0 for ; Fri, 31 Jul 2015 02:53:05 -0700 (PDT) X-Received: by 10.180.24.167 with SMTP id v7mr4803212wif.28.1438336385408; Fri, 31 Jul 2015 02:53:05 -0700 (PDT) Received: from lmenx30s.lme.st.com (LPuteaux-656-1-48-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by smtp.gmail.com with ESMTPSA id n6sm3646823wix.1.2015.07.31.02.53.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Jul 2015 02:53:03 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, preeti@linux.vnet.ibm.com, jason.low2@hp.com Cc: linaro-kernel@lists.linaro.org, Vincent Guittot Subject: [PATCH] sched: fix nohz.next_balance update Date: Fri, 31 Jul 2015 11:49:09 +0200 Message-Id: <1438336149-25809-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vincent.guittot@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Since commit d4573c3e1c99 ("sched: Improve load balancing in the presence of idle CPUs"), the ILB CPU starts with the idle load balancing of other idle CPUs and finishes with itself in order to speed up the spread of tasks in all idle CPUs. The this_rq->next_balance is still used in nohz_idle_balance as an intermediate step to gather the shortest next balance before updating nohz.next_balance. But the former has not been updated yet and is likely to be set with the current jiffies. As a result, the nohz.next_balance will be set with current jiffies instead of the real next balance date. This generates spurious kicks of nohz ilde balance. nohz_idle_balance must set the nohz.next_balance without taking into account this_rq->next_balance which is not updated yet. Then, this_rq will update nohz.next_update with its next_balance once updated and if necessary. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 587a2f6..2b02089 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7779,8 +7779,21 @@ static void rebalance_domains(struct rq *rq, enum cpu_idle_type idle) * When the cpu is attached to null domain for ex, it will not be * updated. */ - if (likely(update_next_balance)) + if (likely(update_next_balance)) { rq->next_balance = next_balance; + + /* + * If this cpu has been elected to perform the nohz idle + * balance. Other idle cpus have already rebalance with + * nohz_idle_balance and the nohz.next_balaance has been + * updated accordingly. This cpu has now run the idle load + * balance for itself and we need to update the + * nohz.next_balance accordingly. + */ + if ((idle == CPU_IDLE) && + time_after(nohz.next_balance, rq->next_balance)) + nohz.next_balance = rq->next_balance; + } } #ifdef CONFIG_NO_HZ_COMMON @@ -7793,6 +7806,9 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) int this_cpu = this_rq->cpu; struct rq *rq; int balance_cpu; + /* Earliest time when we have to do rebalance again */ + unsigned long next_balance = jiffies + 60*HZ; + int update_next_balance = 0; if (idle != CPU_IDLE || !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu))) @@ -7824,10 +7840,19 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) rebalance_domains(rq, CPU_IDLE); } - if (time_after(this_rq->next_balance, rq->next_balance)) - this_rq->next_balance = rq->next_balance; + if (time_after(next_balance, rq->next_balance)) { + next_balance = rq->next_balance; + update_next_balance = 1; + } } - nohz.next_balance = this_rq->next_balance; + + /* + * 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; end: clear_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)); }