From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752154AbdBEKEZ (ORCPT ); Sun, 5 Feb 2017 05:04:25 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33143 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751774AbdBEKEX (ORCPT ); Sun, 5 Feb 2017 05:04:23 -0500 From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: linux-kernel@vger.kernel.org Cc: Wanpeng Li , Vincent Guittot , Peter Zijlstra , Ingo Molnar Subject: [PATCH] sched/fair: Fix the nohz.next_balance update mess Date: Sun, 5 Feb 2017 01:57:35 -0800 Message-Id: <1486288655-8620-1-git-send-email-wanpeng.li@hotmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li The commit: c5afb6a87f2 ("sched/fair: Fix nohz.next_balance update") intends to update nohz.next_balance in two steps. 1) The ILB CPU utilizes next_balance variable in nohz_idle_balance() to gather the shortest next balance of other idle CPUs before updating nohz.next_balance. 2) The ILB CPU updates the nohz.next_balance according to its own next_balance after load balance on behalf of other idle CPUs. However, there is a mess which breaks the original intention of the first step, every idle CPUs update nohz.next_balance during ILB CPU on behalf of them to do load balance, and then the ILB CPU utilizes next_balance variable in nohz_idle_balance() to gather the shortest next balance of other idle CPUs before updating nohz.next_balance. This patch fixes it by don't update nohz.next_balance for other idle CPUs when ILB CPU on behalf of them to do load balance. Cc: Vincent Guittot Cc: Peter Zijlstra (Intel) CC: Ingo Molnar Signed-off-by: Wanpeng Li --- kernel/sched/fair.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 274c747..83948a4 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8750,7 +8750,8 @@ static void rebalance_domains(struct rq *rq, enum cpu_idle_type idle) * 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)) + if ((idle == CPU_IDLE) && time_after(nohz.next_balance, rq->next_balance) && + !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_rq()->cpu))) nohz.next_balance = rq->next_balance; #endif } -- 2.7.4