From patchwork Mon Oct 17 09:14:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 77722 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp300081qge; Mon, 17 Oct 2016 02:15:49 -0700 (PDT) X-Received: by 10.66.222.5 with SMTP id qi5mr29741515pac.138.1476695749636; Mon, 17 Oct 2016 02:15:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14si26530059pgc.57.2016.10.17.02.15.49; Mon, 17 Oct 2016 02:15:49 -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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933995AbcJQJPk (ORCPT + 27 others); Mon, 17 Oct 2016 05:15:40 -0400 Received: from mail-qk0-f179.google.com ([209.85.220.179]:35668 "EHLO mail-qk0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933773AbcJQJPC (ORCPT ); Mon, 17 Oct 2016 05:15:02 -0400 Received: by mail-qk0-f179.google.com with SMTP id z190so221962183qkc.2 for ; Mon, 17 Oct 2016 02:15:01 -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:in-reply-to:references; bh=7q/pg+P5tKaZLy4LO7WK0i6sQJ1viszIBk/xxflu4Z8=; b=j1tgWjpD+HlRLRuVGLTxqO6Bhwd8umAvFepryKne9EI7ftlSw0Z9j+whBMyDCa5LGS h9k8x5fmv5iOKv9NSUGXiONHkLuW7/pktBYqra6E0kSiMI/qA3//dezOVQptBusuxlgM tB1iiq403r+4Vp13cEHc66OCMCxlV0W3Nrmow= 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=7q/pg+P5tKaZLy4LO7WK0i6sQJ1viszIBk/xxflu4Z8=; b=RxtS3CGi6pE1mCtyA975EbzZvBUrsLd9aGrBRgiwRq14KT7RTfgdYg0ezv5sAKQLYi izlbqNz4/9ZEK1chAc54nvm68JEGTZvpivvSGXcTUG/57FT4NsquE4SOPBLsct65G1sZ 844IXppiQyKhv7bOmvbHoKXuLwrtdjBP5tEEjGVXMQ8gPohmexLaDcKTWDsfBYGrRKKs QgZyq30n5tkGdKgALxaRo4CTW2zMHI0c+6LqPXUbOKt6vx955Zi/V+FjbDvMxy+Av7nN jGnZK13DDGLkB/h16gKTj88G3pKjCapSmuPCfXOIm/TxZf6tG9om1+VjJJomGl/q9DMF UzYQ== X-Gm-Message-State: AA6/9RlsFSFYUDA3gH/zabGtMaZd6dDVrRiIV+R2wKhupMXWCpRVyZ9iAEmmsf8Bb3F/GF// X-Received: by 10.194.235.165 with SMTP id un5mr10740353wjc.200.1476695700881; Mon, 17 Oct 2016 02:15:00 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:8bd4:7750:80a0:ca36:f872:d659]) by smtp.gmail.com with ESMTPSA id f2sm51341206wjr.2.2016.10.17.02.14.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Oct 2016 02:14:59 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com Cc: yuyang.du@intel.com, Morten.Rasmussen@arm.com, linaro-kernel@lists.linaro.org, pjt@google.com, bsegall@google.com, kernellwp@gmail.com, Vincent Guittot Subject: [PATCH 1/6 v5] sched: factorize attach entity Date: Mon, 17 Oct 2016 11:14:08 +0200 Message-Id: <1476695653-12309-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476695653-12309-1-git-send-email-vincent.guittot@linaro.org> References: <1476695653-12309-1-git-send-email-vincent.guittot@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Factorize post_init_entity_util_avg and part of attach_task_cfs_rq in one function attach_entity_cfs_rq Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 543b2f2..584b86f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -701,9 +701,7 @@ void init_entity_runnable_average(struct sched_entity *se) } static inline u64 cfs_rq_clock_task(struct cfs_rq *cfs_rq); -static int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq, bool update_freq); -static void update_tg_load_avg(struct cfs_rq *cfs_rq, int force); -static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se); +static void attach_entity_cfs_rq(struct sched_entity *se); /* * With new tasks being created, their initial util_avgs are extrapolated @@ -735,7 +733,6 @@ void post_init_entity_util_avg(struct sched_entity *se) struct cfs_rq *cfs_rq = cfs_rq_of(se); struct sched_avg *sa = &se->avg; long cap = (long)(SCHED_CAPACITY_SCALE - cfs_rq->avg.util_avg) / 2; - u64 now = cfs_rq_clock_task(cfs_rq); if (cap > 0) { if (cfs_rq->avg.util_avg != 0) { @@ -763,14 +760,12 @@ void post_init_entity_util_avg(struct sched_entity *se) * such that the next switched_to_fair() has the * expected state. */ - se->avg.last_update_time = now; + se->avg.last_update_time = cfs_rq_clock_task(cfs_rq); return; } } - update_cfs_rq_load_avg(now, cfs_rq, false); - attach_entity_load_avg(cfs_rq, se); - update_tg_load_avg(cfs_rq, false); + attach_entity_cfs_rq(se); } #else /* !CONFIG_SMP */ @@ -8697,9 +8692,8 @@ static void detach_task_cfs_rq(struct task_struct *p) update_tg_load_avg(cfs_rq, false); } -static void attach_task_cfs_rq(struct task_struct *p) +static void attach_entity_cfs_rq(struct sched_entity *se) { - struct sched_entity *se = &p->se; struct cfs_rq *cfs_rq = cfs_rq_of(se); u64 now = cfs_rq_clock_task(cfs_rq); @@ -8711,10 +8705,18 @@ static void attach_task_cfs_rq(struct task_struct *p) se->depth = se->parent ? se->parent->depth + 1 : 0; #endif - /* Synchronize task with its cfs_rq */ + /* Synchronize entity with its cfs_rq */ update_cfs_rq_load_avg(now, cfs_rq, false); attach_entity_load_avg(cfs_rq, se); update_tg_load_avg(cfs_rq, false); +} + +static void attach_task_cfs_rq(struct task_struct *p) +{ + struct sched_entity *se = &p->se; + struct cfs_rq *cfs_rq = cfs_rq_of(se); + + attach_entity_cfs_rq(se); if (!vruntime_normalized(p)) se->vruntime += cfs_rq->min_vruntime;