From patchwork Fri May 23 15:52:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 4234091 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C69A99F32B for ; Fri, 23 May 2014 15:57:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 01428201EC for ; Fri, 23 May 2014 15:57:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2EE0120172 for ; Fri, 23 May 2014 15:57:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wnrnu-0005wp-Mw; Fri, 23 May 2014 15:54:42 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wnrnh-0005nu-7p for linux-arm-kernel@lists.infradead.org; Fri, 23 May 2014 15:54:29 +0000 Received: by mail-wg0-f49.google.com with SMTP id m15so4938937wgh.8 for ; Fri, 23 May 2014 08:54:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ip2cvs3yJsbKe0316Fd3ipfdtAxtz5+nW3KDZo1/SJU=; b=XvqEZ5ByEKzs8GuBGYL2V9dEZMNzWKhD6V0diMfdz1XRIaXm7TCS/kSpmHApzKO1eH UqEMYEBVKSZjBJ6rR6Za6+dNBX6i1yV96+oO5r2VvHl+JmZyAW8DNZ3Vf0seu615Poj4 ao2dIjL9HDGI7FfjSvB47N9CDRVXR9o4UBCrpXr+BVszIC8fw283l7bXfyqYQqxFWEhv ORmfvvKQxgex5tCLGsduKrhifXIX+c9VaFSHKyERijGzgdaHxAl0Tgi52P4LORcAyk5F IaQe+4IK+Z5lROoOYY6hmvg37LJjtw/YnFAEaunhnwEe8InSfNgxWuKhu+JehJHo3kTz eoAg== X-Gm-Message-State: ALoCoQlFN8IpXeHHxm6nF9BBo5XlIjteSFgId5HCyapanaxTfc/cZUcz5g60BSmHJM0j8u6eirIz X-Received: by 10.194.221.69 with SMTP id qc5mr2731104wjc.91.1400860446746; Fri, 23 May 2014 08:54:06 -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 m1sm3558594wib.20.2014.05.23.08.54.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 May 2014 08:54:06 -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 Subject: [PATCH v2 01/11] sched: fix imbalance flag reset Date: Fri, 23 May 2014 17:52:55 +0200 Message-Id: <1400860385-14555-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1400860385-14555-1-git-send-email-vincent.guittot@linaro.org> References: <1400860385-14555-1-git-send-email-vincent.guittot@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140523_085429_423345_06B3D9E6 X-CRM114-Status: GOOD ( 15.53 ) X-Spam-Score: -0.7 (/) Cc: nicolas.pitre@linaro.org, efault@gmx.de, Vincent Guittot , daniel.lezcano@linaro.org, linaro-kernel@lists.linaro.org, preeti@linux.vnet.ibm.com, Morten.Rasmussen@arm.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 c9617b7..9587ed1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6610,10 +6610,8 @@ more_balance: if (sd_parent) { int *group_imbalance = &sd_parent->groups->sgp->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 */ @@ -6698,6 +6696,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->sgp->imbalance; + if (*group_imbalance) + *group_imbalance = 0; + } + schedstat_inc(sd, lb_balanced[idle]); sd->nr_balance_failed = 0;