From patchwork Fri Jun 8 12:09:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 137956 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp791968lji; Fri, 8 Jun 2018 05:11:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKP5joA9YMihOFh0JyqTqH0+cvTB+PbORiAj+zCuBDHnOi5BQ49JYuCQh//w35qb6j6XMUn X-Received: by 2002:a63:5fc4:: with SMTP id t187-v6mr4947186pgb.183.1528459882360; Fri, 08 Jun 2018 05:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528459882; cv=none; d=google.com; s=arc-20160816; b=C0oQkEVyuZ0WDEXLcjhS6leHHklc9SF9g5MPt0eEBaiiWfoun/O4U8R/qHMmikULTH Sr+FeQ0YMOwRYpTxOJEO1KXthdUI3B5PErxvi4bVzjxw5uAlVlQpV9NSZlYzyZl5R8aP 1meXAsyGuRkZKinF3TpGHEeuc5mmumHKzx5o53MV/giqj0V3WKRBmRWima49LfNuo8Jp q+hR3pA0z7w6d0GCLNElpNN9lPEMhyxvFkMZyqq5T0RDg66tMEvQKU3+Zwl5mAB3ujQ2 ymf3fPfCx9adRRi4GuyU7r18YsemdfgL5tlvfHcawsTo2GRtUctEWBOlOeGknBdcyGDJ kDHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=pE+h1VuN59ZRcVvHCdR88kNf6zFNrgFECds97E/YUjc=; b=crvAv8nP/upluDvXAldQ6lnoye6PpzHHIQTLqRHuYdnccpptg5DoBiDh/9iXoUEn1x wfxfrnU5T0Uic59OKwdC1bpqn4j4LKbrfQyCbeWTq1O4za+ZBvaRELpNbn9mWC5zBMDs /tQ+Y9IiYKaYnOnxM0dFvfTfbz4TknNUOoUj1iEu95eOyfY/KyrK6+/tYYv5/tWdPbeD RwU7ApVLdaVdMF+7nxIANPl2OrFjE0KGZCQqu4pk8HcbEtjlcENPs22D5Wa8sHTH6s0J qUk6h6xpfthXV0DbF9qtr0elg7Db+6K584yXzv3fe43VBkTbC94ZUvs1o67G0vVvW4Wq PVbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eUzTuj/E; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si56309434plv.16.2018.06.08.05.11.22; Fri, 08 Jun 2018 05:11:22 -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 header.s=google header.b=eUzTuj/E; 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 S932157AbeFHMLT (ORCPT + 30 others); Fri, 8 Jun 2018 08:11:19 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:40162 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752990AbeFHMKi (ORCPT ); Fri, 8 Jun 2018 08:10:38 -0400 Received: by mail-wm0-f67.google.com with SMTP id n5-v6so3265958wmc.5 for ; Fri, 08 Jun 2018 05:10:37 -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=pE+h1VuN59ZRcVvHCdR88kNf6zFNrgFECds97E/YUjc=; b=eUzTuj/EJznv+ZBeXTJveSQv9cLz2aA2lx7toZySZanODcUu27xRotOKHEYQCp6JpV ak68H5qqSQUk5oCOv/+2f2M3/C81vBxB2C6BHzxXz//UeyKqLlHhC80qN1u8qi6IjUyD OtPPs+Ci01sJ06ajI4/k/JjQ2JCUuNZlW5B7A= 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:in-reply-to :references; bh=pE+h1VuN59ZRcVvHCdR88kNf6zFNrgFECds97E/YUjc=; b=DKIdivLKxmZtprSfWJHKUQU82VO8Uyh+0thkTHX2eCK39msFzJ+J79QcGeH/51Sp8e CO+rhYeNeZqxmn0Y2/tosHEptHduraOBNp9wwuP6Y5K4YVLilu8hNxu+4a3A8cyO1AsV yEprm/gmZsNi6uDgZ8T9l0vOse0eBWfS1hNTH0jig403HwbD4mooyQ7YLwmofIQxMCOn 2duWwxGx90zD6QVOfkd3P9RD1lU+UpLTpe2qVJNVS6YDp5jNXrcV07tMeI4UBLJWb+vx 70MPCxI8peywJxPQ33HWK861F7m2YAMYdxbiNKfNi9rnQexKj9ovW/GOhpT3GGw+PBgl neGg== X-Gm-Message-State: APt69E0M2i9X8h2AaZoGqUsIXTcyBZOz6uAp9zww9CbKgWMr8hpLUuB1 z2tlymeW6nVxpy7W33FPaaCP3w== X-Received: by 2002:a1c:256:: with SMTP id 83-v6mr1498778wmc.41.1528459836902; Fri, 08 Jun 2018 05:10:36 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:6c67:7ea:9f4d:8968]) by smtp.gmail.com with ESMTPSA id b204-v6sm1546003wmh.22.2018.06.08.05.10.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jun 2018 05:10:36 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, juri.lelli@redhat.com, dietmar.eggemann@arm.com, Morten.Rasmussen@arm.com, viresh.kumar@linaro.org, valentin.schneider@arm.com, patrick.bellasi@arm.com, joel@joelfernandes.org, daniel.lezcano@linaro.org, quentin.perret@arm.com, Vincent Guittot , Ingo Molnar Subject: [PATCH v6 09/11] sched: use pelt for scale_rt_capacity() Date: Fri, 8 Jun 2018 14:09:52 +0200 Message-Id: <1528459794-13066-10-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528459794-13066-1-git-send-email-vincent.guittot@linaro.org> References: <1528459794-13066-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 The utilization of the CPU by rt, dl and interrupts are now tracked with PELT so we can use these metrics instead of rt_avg to evaluate the remaining capacity available for cfs class. scale_rt_capacity() behavior has been changed and now returns the remaining capacity available for cfs instead of a scaling factor because rt, dl and interrupt provide now absolute utilization value. The same formula as schedutil is used: irq util_avg + (1 - irq util_avg / max capacity ) * /Sum rq util_avg but the implementation is different because it doesn't return the same value and doesn't benefit of the same optimization Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Vincent Guittot --- kernel/sched/deadline.c | 2 -- kernel/sched/fair.c | 41 +++++++++++++++++++---------------------- kernel/sched/pelt.c | 2 +- kernel/sched/rt.c | 2 -- 4 files changed, 20 insertions(+), 27 deletions(-) -- 2.7.4 diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 596097f..c882d156 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1180,8 +1180,6 @@ static void update_curr_dl(struct rq *rq) curr->se.exec_start = now; cgroup_account_cputime(curr, delta_exec); - sched_rt_avg_update(rq, delta_exec); - if (dl_entity_is_special(dl_se)) return; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index cc7a6e2..fefd71b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7551,39 +7551,36 @@ static inline int get_sd_load_idx(struct sched_domain *sd, static unsigned long scale_rt_capacity(int cpu) { struct rq *rq = cpu_rq(cpu); - u64 total, used, age_stamp, avg; - s64 delta; - - /* - * Since we're reading these variables without serialization make sure - * we read them once before doing sanity checks on them. - */ - age_stamp = READ_ONCE(rq->age_stamp); - avg = READ_ONCE(rq->rt_avg); - delta = __rq_clock_broken(rq) - age_stamp; + unsigned long max = arch_scale_cpu_capacity(NULL, cpu); + unsigned long used, irq, free; - if (unlikely(delta < 0)) - delta = 0; +#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING) + irq = READ_ONCE(rq->avg_irq.util_avg); - total = sched_avg_period() + delta; + if (unlikely(irq >= max)) + return 1; +#endif - used = div_u64(avg, total); + used = READ_ONCE(rq->avg_rt.util_avg); + used += READ_ONCE(rq->avg_dl.util_avg); - if (likely(used < SCHED_CAPACITY_SCALE)) - return SCHED_CAPACITY_SCALE - used; + if (unlikely(used >= max)) + return 1; - return 1; + free = max - used; +#if defined(CONFIG_IRQ_TIME_ACCOUNTING) || defined(CONFIG_PARAVIRT_TIME_ACCOUNTING) + free *= (max - irq); + free /= max; +#endif + return free; } static void update_cpu_capacity(struct sched_domain *sd, int cpu) { - unsigned long capacity = arch_scale_cpu_capacity(sd, cpu); + unsigned long capacity = scale_rt_capacity(cpu); struct sched_group *sdg = sd->groups; - cpu_rq(cpu)->cpu_capacity_orig = capacity; - - capacity *= scale_rt_capacity(cpu); - capacity >>= SCHED_CAPACITY_SHIFT; + cpu_rq(cpu)->cpu_capacity_orig = arch_scale_cpu_capacity(sd, cpu); if (!capacity) capacity = 1; diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c index b43e2af..e2d53a6 100644 --- a/kernel/sched/pelt.c +++ b/kernel/sched/pelt.c @@ -237,7 +237,7 @@ ___update_load_avg(struct sched_avg *sa, unsigned long load, unsigned long runna */ sa->load_avg = div_u64(load * sa->load_sum, divider); sa->runnable_load_avg = div_u64(runnable * sa->runnable_load_sum, divider); - sa->util_avg = sa->util_sum / divider; + WRITE_ONCE(sa->util_avg, sa->util_sum / divider); } /* diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index e8c08a8..4fd2b57 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -970,8 +970,6 @@ static void update_curr_rt(struct rq *rq) curr->se.exec_start = now; cgroup_account_cputime(curr, delta_exec); - sched_rt_avg_update(rq, delta_exec); - if (!rt_bandwidth_enabled()) return;