From patchwork Fri Mar 17 13:47:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 95419 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp315566qgd; Fri, 17 Mar 2017 06:48:54 -0700 (PDT) X-Received: by 10.99.237.17 with SMTP id d17mr15876930pgi.82.1489758534003; Fri, 17 Mar 2017 06:48:54 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si8698163pgf.338.2017.03.17.06.48.53; Fri, 17 Mar 2017 06:48:53 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751189AbdCQNso (ORCPT + 12 others); Fri, 17 Mar 2017 09:48:44 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:35160 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751082AbdCQNsl (ORCPT ); Fri, 17 Mar 2017 09:48:41 -0400 Received: by mail-wm0-f50.google.com with SMTP id u132so16074102wmg.0 for ; Fri, 17 Mar 2017 06:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=dmhUNoxUsJlU0PbDiJQex8HsZgWD7gdF3f3Kt80UO2I=; b=kRkdZCiM0YpidihwNQv7fdLM8NzYemQoBXRg0KDrDpD3mTT36VvleeSiRzTqNRkFMM 8aTLsRffEDY+nAidhcx29ysWDeWSvz7i6cU2KdgfodrflEpiiVATlCEAklbl35hh5Hv/ cNED9N8LD2PtQVLkuMQr73bIeSigGqMM5ISCw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dmhUNoxUsJlU0PbDiJQex8HsZgWD7gdF3f3Kt80UO2I=; b=Efy34yGaq52+k4aEgitlhUQVICLvKbok0XV8LWcc27UBYnjQyK0j8MbAO5pIK1/Nlu FYOgq8obwBsSWyPkYRNSKlbmlBGiowvltk1PJdzf/1tney6WdsKew6LN73scI9lZ/D+V HDrkgqkKlOwc7YQZK1YWWDFJoMaLLxsZXyDgf2/OII/1OFgxrW83Yrnv6vgx1yaj5dAp uL2GzRXuvxpYK8+1pG+yY+rGPzvcm9iwieKmg08gmTcpLl7Wz2GwaL4LVeYBD9vQw6iQ QqIN/Deji+fPc8OS0npUFIh/FKrllXLapMEpsjidA+aHYMVVCvoNdKximyY6HRQ1Twj0 QMBA== X-Gm-Message-State: AFeK/H3eZp5TNno2l18ftEyGCmruzEtA9K8bEtwS+ne9c3ykcY3bhjLbx8mwKZiktW11STmj X-Received: by 10.28.69.202 with SMTP id l71mr3084905wmi.68.1489758463460; Fri, 17 Mar 2017 06:47:43 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:5c35:99d5:525f:55c9]) by smtp.gmail.com with ESMTPSA id u145sm2758794wmu.1.2017.03.17.06.47.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Mar 2017 06:47:42 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, ying.huang@intel.com Cc: dietmar.eggemann@arm.com, Vincent Guittot Subject: [PATCH] sched/fair: Fix ftq noise bench regression Date: Fri, 17 Mar 2017 14:47:22 +0100 Message-Id: <1489758442-2877-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A regression of the ftq noise has been reported by ying.huang@linux.intel.com on 8 threads Intel(R) Core(TM)i7-4770 CPU @ 3.40GHz with 8G memory due to commit 4e5160766fcc ("sched/fair: Propagate asynchrous detach") The only part of the patch that can increase the noise is the update of blocked load of group entity in update_blocked_averages(). We can optimize this call and skip the update of group entity if its load and utilization are already null and there is no pending propagation of load in the task group. This optimization partly restores the noise score. A more agressive optimization has been tried but has shown worse score. Reported-by: ying.huang@linux.intel.com Signed-off-by: Vincent Guittot Fixes: 4e5160766fcc ("sched/fair: Propagate asynchrous detach") --- kernel/sched/fair.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2805bd7..007df59 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3173,6 +3173,36 @@ static inline int propagate_entity_load_avg(struct sched_entity *se) return 1; } +/* + * Check if we need to update the load and the utilization of a blocked + * group_entity + */ +static inline bool skip_blocked_update(struct sched_entity *se) +{ + struct cfs_rq *gcfs_rq = group_cfs_rq(se); + + /* + * If sched_entity still have not null load or utilization, we have to + * decay it. + */ + if (se->avg.load_avg || se->avg.util_avg) + return false; + + /* + * If there is a pending propagation, we have to update the load and + * the utilizaion of the sched_entity + */ + if (gcfs_rq->propagate_avg) + return false; + + /* + * Other wise, the load and the utilization of the sched_entity is + * already null and there is no pending propagation so it will be a + * waste of time to try to decay it. + */ + return true; +} + #else /* CONFIG_FAIR_GROUP_SCHED */ static inline void update_tg_load_avg(struct cfs_rq *cfs_rq, int force) {} @@ -6961,6 +6991,8 @@ static void update_blocked_averages(int cpu) * list_add_leaf_cfs_rq() for details. */ for_each_leaf_cfs_rq(rq, cfs_rq) { + struct sched_entity *se; + /* throttled entities do not contribute to load */ if (throttled_hierarchy(cfs_rq)) continue; @@ -6968,9 +7000,10 @@ static void update_blocked_averages(int cpu) if (update_cfs_rq_load_avg(cfs_rq_clock_task(cfs_rq), cfs_rq, true)) update_tg_load_avg(cfs_rq, 0); - /* Propagate pending load changes to the parent */ - if (cfs_rq->tg->se[cpu]) - update_load_avg(cfs_rq->tg->se[cpu], 0); + /* Propagate pending load changes to the parent if any */ + se = cfs_rq->tg->se[cpu]; + if (se && !skip_blocked_update(se)) + update_load_avg(se, 0); } rq_unlock_irqrestore(rq, &rf); }