From patchwork Wed Jun 1 19:39:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 69062 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp275132qge; Wed, 1 Jun 2016 12:40:05 -0700 (PDT) X-Received: by 10.98.65.209 with SMTP id g78mr12142953pfd.163.1464810002536; Wed, 01 Jun 2016 12:40:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m64si4518607pfb.124.2016.06.01.12.40.02; Wed, 01 Jun 2016 12:40:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751427AbcFATj4 (ORCPT + 30 others); Wed, 1 Jun 2016 15:39:56 -0400 Received: from foss.arm.com ([217.140.101.70]:39949 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750890AbcFATjy (ORCPT ); Wed, 1 Jun 2016 15:39:54 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 16B9A34; Wed, 1 Jun 2016 12:40:13 -0700 (PDT) Received: from e107985-lin.cambridge.arm.com (e107985-lin.cambridge.arm.com [10.1.207.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 60BCA3F253; Wed, 1 Jun 2016 12:39:42 -0700 (PDT) From: Dietmar Eggemann To: Peter Zijlstra , linux-kernel@vger.kernel.org Cc: Vincent Guittot , Ben Segall , Morten Rasmussen , Yuyang Du Subject: [RFC PATCH 2/3] sched/fair: Sync se with root cfs_rq Date: Wed, 1 Jun 2016 20:39:21 +0100 Message-Id: <1464809962-25814-3-git-send-email-dietmar.eggemann@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464809962-25814-1-git-send-email-dietmar.eggemann@arm.com> References: <1464809962-25814-1-git-send-email-dietmar.eggemann@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since task utilization is accrued only on the root cfs_rq, there are a couple of places where the se has to be synced with the root cfs_rq: (1) The root cfs_rq has to be updated in attach_entity_load_avg() for an se representing a task in a tg other than the root tg before the se utilization can be added to it. (2) The last_update_time value of the root cfs_rq can be higher than the one of the cfs_rq the se is enqueued in. Call __update_load_avg() on the se with the last_update_time value of the root cfs_rq before removing se's utilization from the root cfs_rq in [remove|detach]_entity_load_avg(). In case the difference between the last_update_time value of the cfs_rq and the root cfs_rq is smaller than 1024ns, the additional calls to __update_load_avg() will bail early. Signed-off-by: Dietmar Eggemann --- kernel/sched/fair.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 212becd3708f..3ae8e79fb687 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2970,6 +2970,8 @@ static inline void update_load_avg(struct sched_entity *se, int update_tg) static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { + struct cfs_rq* root_cfs_rq; + if (!sched_feat(ATTACH_AGE_LOAD)) goto skip_aging; @@ -2995,8 +2997,16 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s if (!entity_is_task(se)) return; - rq_of(cfs_rq)->cfs.avg.util_avg += se->avg.util_avg; - rq_of(cfs_rq)->cfs.avg.util_sum += se->avg.util_sum; + root_cfs_rq = &rq_of(cfs_rq)->cfs; + + if (parent_entity(se)) + __update_load_avg(cfs_rq_clock_task(root_cfs_rq), + cpu_of(rq_of(root_cfs_rq)), &root_cfs_rq->avg, + scale_load_down(root_cfs_rq->load.weight), + upd_util_cfs_rq(root_cfs_rq), root_cfs_rq); + + root_cfs_rq->avg.util_avg += se->avg.util_avg; + root_cfs_rq->avg.util_sum += se->avg.util_sum; cfs_rq_util_change(cfs_rq); } @@ -3013,6 +3023,10 @@ static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s if (!entity_is_task(se)) return; + __update_load_avg(rq_of(cfs_rq)->cfs.avg.last_update_time, cpu_of(rq_of(cfs_rq)), + &se->avg, se->on_rq * scale_load_down(se->load.weight), + cfs_rq->curr == se, NULL); + rq_of(cfs_rq)->cfs.avg.util_avg = max_t(long, rq_of(cfs_rq)->cfs.avg.util_avg - se->avg.util_avg, 0); rq_of(cfs_rq)->cfs.avg.util_sum = @@ -3105,6 +3119,9 @@ void remove_entity_load_avg(struct sched_entity *se) if (!entity_is_task(se)) return; + last_update_time = cfs_rq_last_update_time(&rq_of(cfs_rq)->cfs); + + __update_load_avg(last_update_time, cpu_of(rq_of(cfs_rq)), &se->avg, 0, 0, NULL); atomic_long_add(se->avg.util_avg, &rq_of(cfs_rq)->cfs.removed_util_avg); }