From patchwork Mon Jun 30 16:05:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 32772 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C42F7203C0 for ; Mon, 30 Jun 2014 16:07:02 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id a41sf19277854yho.1 for ; Mon, 30 Jun 2014 09:07:02 -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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=oXFLdhinS06yD6/33sbXCGJ1Mf0HpvXGs4AJRJUsBFY=; b=Ow4jBgGMUNiS+kjKMfQeadeaxhfVPXF1kmrIQfW/9UsEM49GhtysxUrWxeFrRdZND7 4SU5PySZ0E1pMdcYEsGiVle4ZUrDbdWRJcuDkvk3LXXjcA/m+qPlsTeP+BwS1BlzT1gy 4epYiZHix+MWUswNfR01dywR9KdZagbCE3qJplzAwihy6sRDPtXtZh7+RFhOf3uyWq18 fYiaeRLR00uKn0laULed1FCI2sGqkkaVj1aYU+sSTJGwvqAD1KPs5LPhTu60rHltzDNs SqpWf4Nw7uhI3fmHECSqDgyi0hqmRjCPaiiOBbVCXH6cwMuLuGwu7LM47bUfCpc5NRPp UbNw== X-Gm-Message-State: ALoCoQlkMSNSwqD8Wi+kL+eU6VyyAWO4FGhZI5D7P8SV+W8BRsxy55JrzxVDXistoxkgVF6150ux X-Received: by 10.52.230.71 with SMTP id sw7mr19329421vdc.9.1404144422616; Mon, 30 Jun 2014 09:07:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.36 with SMTP id 33ls1465702qgg.19.gmail; Mon, 30 Jun 2014 09:07:02 -0700 (PDT) X-Received: by 10.52.69.133 with SMTP id e5mr1108332vdu.66.1404144422510; Mon, 30 Jun 2014 09:07:02 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id fv10si10213916vdc.39.2014.06.30.09.07.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 09:07:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.181 as permitted sender) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id db11so8225402veb.26 for ; Mon, 30 Jun 2014 09:07:02 -0700 (PDT) X-Received: by 10.52.248.146 with SMTP id ym18mr32776784vdc.8.1404144422401; Mon, 30 Jun 2014 09:07:02 -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.221.37.5 with SMTP id tc5csp151214vcb; Mon, 30 Jun 2014 09:07:01 -0700 (PDT) X-Received: by 10.68.164.229 with SMTP id yt5mr53457159pbb.28.1404144421659; Mon, 30 Jun 2014 09:07:01 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ef2si23660456pbb.106.2014.06.30.09.07.01; Mon, 30 Jun 2014 09:07:01 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756147AbaF3QGt (ORCPT + 27 others); Mon, 30 Jun 2014 12:06:49 -0400 Received: from mail-wg0-f41.google.com ([74.125.82.41]:41773 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754530AbaF3QGq (ORCPT ); Mon, 30 Jun 2014 12:06:46 -0400 Received: by mail-wg0-f41.google.com with SMTP id a1so8373293wgh.12 for ; Mon, 30 Jun 2014 09:06:45 -0700 (PDT) X-Received: by 10.194.110.10 with SMTP id hw10mr45883165wjb.81.1404144405455; Mon, 30 Jun 2014 09:06:45 -0700 (PDT) Received: from lmenx30s.lme.st.com (LPuteaux-656-01-48-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPSA id lo18sm32896271wic.1.2014.06.30.09.06.43 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 09:06:44 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org Cc: preeti@linux.vnet.ibm.com, Morten.Rasmussen@arm.com, efault@gmx.de, nicolas.pitre@linaro.org, linaro-kernel@lists.linaro.org, daniel.lezcano@linaro.org, dietmar.eggemann@arm.com, Vincent Guittot Subject: [PATCH v3 01/12] sched: fix imbalance flag reset Date: Mon, 30 Jun 2014 18:05:32 +0200 Message-Id: <1404144343-18720-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1404144343-18720-1-git-send-email-vincent.guittot@linaro.org> References: <1404144343-18720-1-git-send-email-vincent.guittot@linaro.org> 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.128.181 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: , The imbalance flag can stay set whereas there is no imbalance. Let assume that we have 3 tasks that run on a dual cores /dual cluster system. We will have some idle load balance which are triggered during tick. Unfortunately, the tick is also used to queue background work so we can reach the situation where short work has been queued on a CPU which already runs a task. The load balance will detect this imbalance (2 tasks on 1 CPU and an idle CPU) and will try to pull the waiting task on the idle CPU. The waiting task is a worker thread that is pinned on a CPU so an imbalance due to pinned task is detected and the imbalance flag is set. Then, we will not be able to clear the flag because we have at most 1 task on each CPU but the imbalance flag will trig to useless active load balance between the idle CPU and the busy CPU. We need to reset of the imbalance flag as soon as we have reached a balanced state. Signed-off-by: Vincent Guittot Acked-by: Rik van Riel --- kernel/sched/fair.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d3c73122..0c48dff 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6615,10 +6615,8 @@ more_balance: if (sd_parent) { int *group_imbalance = &sd_parent->groups->sgc->imbalance; - if ((env.flags & LBF_SOME_PINNED) && env.imbalance > 0) { + if ((env.flags & LBF_SOME_PINNED) && env.imbalance > 0) *group_imbalance = 1; - } else if (*group_imbalance) - *group_imbalance = 0; } /* All tasks on this runqueue were pinned by CPU affinity */ @@ -6703,6 +6701,16 @@ more_balance: goto out; out_balanced: + /* + * We reach balance although we may have faced some affinity + * constraints. Clear the imbalance flag if it was set. + */ + if (sd_parent) { + int *group_imbalance = &sd_parent->groups->sgc->imbalance; + if (*group_imbalance) + *group_imbalance = 0; + } + schedstat_inc(sd, lb_balanced[idle]); sd->nr_balance_failed = 0;