From patchwork Fri Jun 8 12:09:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 137952 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp791101lji; Fri, 8 Jun 2018 05:10:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL3BsJvS3KViwv6nJWlySGEhKecRMnFp1VJLORR0CbylWphq/JwpTD+9M7CyNQOai178N97 X-Received: by 2002:a17:902:903:: with SMTP id 3-v6mr6390351plm.377.1528459837700; Fri, 08 Jun 2018 05:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528459837; cv=none; d=google.com; s=arc-20160816; b=oYxvvl3yrUCDQCb6Hir1thfqGgl6SXa/fCItlshZmZSuBTv+f02hS9BrAZ/b770fBW 4IxneD8QolHbb63PTW4OV9bl5iSb7d9TRA+tzREvkydrH4T43q1ycLpDT+bmHFuHsIW4 pkulhPxSjc3wqwKtpTaS2wzt2CQcP8dl51UOr9XW2x1p2XvD4nuHZb0dFUcx7AYUzYfk hcguNAlC7qmTPxk/Ix0Zrt+8AJSDkT0SsGIhM3D+UZhFMtaNFFdovALqva5WJ96NzIHh esYUHH2R3Wr7ZgVzsOeogOr+ltXL1qQ2KCg/LWF90YdDyY4JWUPtLQfDU4IWIqWYAHI7 ZG1A== 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=gUNOi+06UjqIu3kZ8NcmOFtpA+W+JZqfpkKfqG940N0=; b=k8OgXSI0EtLj+D9LDdqHaRMzMx8R6Sr7AWt0oHJ8AvkHqpV843o+YvRwD5NF+Pttpq YbF7iITjAw9en89msdFblsBYuCnE4V3FI+OsC9PGVKqGBR2R3D0FZl9ANM83VpEiu5rO ZrMbJp/kcBhYqZIHdfH8pwu6v78pwPhPxEoHempyXAK3C7QjoODFXaR+uzEN15UiN7JM T9pkI4ydgpfxWx5OoWKYv7CJ03alATKIUjqEnzerKPi8zEqPL8PvavymwhRf5Txuhujv S8iabyjJ6s2QP7KIBu8tIwoSbgfhJLi/rNBAoUgKY/N41lmZWEbHMN8vmZdZ3GrZMmAV i5xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dU1Piiot; 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 e2-v6si35109018pls.575.2018.06.08.05.10.37; Fri, 08 Jun 2018 05:10:37 -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=dU1Piiot; 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 S1752985AbeFHMKf (ORCPT + 30 others); Fri, 8 Jun 2018 08:10:35 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38275 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752938AbeFHMKb (ORCPT ); Fri, 8 Jun 2018 08:10:31 -0400 Received: by mail-wm0-f66.google.com with SMTP id 69-v6so3287347wmf.3 for ; Fri, 08 Jun 2018 05:10:30 -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=gUNOi+06UjqIu3kZ8NcmOFtpA+W+JZqfpkKfqG940N0=; b=dU1PiiotISxwH0ggnI0s9vTAO0eAhEgbarb6Cnz2QFt0T1NY/2Urm0UHgQmKaj2KQ6 py0rdflU/NpFecvQ2yYJRYS5sdg+VeTK/1PBnSV8SzsYaqdJXna3f/DCzU/k2tR7TgVv BHm09w4tVGE91+93NyJxJTssysMTBjZT7YgbE= 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=gUNOi+06UjqIu3kZ8NcmOFtpA+W+JZqfpkKfqG940N0=; b=rUZBteAr5v+U8qwKU/EV+D3SGyiJl6wyJgwFbIGO6s/y0+ZsKGtrRB8lfJj9zneg++ 2KD2vqbJIYHJNBTE4UiliMTHc3g8RazzcjU+cbBoy7ORYu5MuwJKCYgYTopIX96UNi23 A9x+N5eKpB+tk+IxbyXFPOTWBl66E19LKLK1TZpeQY8TBY7ulzzVHOwSue3z00FkUIjT xigbA4v3WAKJe541nZqnhyHRAZgwmSxDLostLh/21VcO2iXcfuVvbti/CsL7rFRlg1R2 TIV+A9UiIaXHBGu65zGv4hp4dAdL84USkhC4NvO34Uq3nZzcF4gN+3897jSA15AamLan jGtA== X-Gm-Message-State: APt69E0yuzXBuVnsMIlCbEDUc9/WqAtg8V4RtS8vXdR5G7b/EDB8J54c wUKEGNF9R6SQz9BqLNxsT28m6g== X-Received: by 2002:a1c:1701:: with SMTP id 1-v6mr1327240wmx.38.1528459829981; Fri, 08 Jun 2018 05:10:29 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jun 2018 05:10:29 -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 06/11] cpufreq/schedutil: use dl utilization tracking Date: Fri, 8 Jun 2018 14:09:49 +0200 Message-Id: <1528459794-13066-7-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 Now that we have both the dl class bandwidth requirement and the dl class utilization, we can detect when CPU is fully used so we should run at max. Otherwise, we keep using the dl bandwidth requirement to define the utilization of the CPU Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Vincent Guittot --- kernel/sched/cpufreq_schedutil.c | 24 +++++++++++++++--------- kernel/sched/sched.h | 7 ++++++- 2 files changed, 21 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 32f97fb..25cee59 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -56,6 +56,7 @@ struct sugov_cpu { /* The fields below are only needed when sharing a policy: */ unsigned long util_cfs; unsigned long util_dl; + unsigned long bw_dl; unsigned long util_rt; unsigned long max; @@ -179,6 +180,7 @@ static void sugov_get_util(struct sugov_cpu *sg_cpu) sg_cpu->max = arch_scale_cpu_capacity(NULL, sg_cpu->cpu); sg_cpu->util_cfs = cpu_util_cfs(rq); sg_cpu->util_dl = cpu_util_dl(rq); + sg_cpu->bw_dl = cpu_bw_dl(rq); sg_cpu->util_rt = cpu_util_rt(rq); } @@ -190,20 +192,24 @@ static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu) if (rq->rt.rt_nr_running) return sg_cpu->max; - util = sg_cpu->util_dl; - util += sg_cpu->util_cfs; + util = sg_cpu->util_cfs; util += sg_cpu->util_rt; + if ((util + sg_cpu->util_dl) >= sg_cpu->max) + return sg_cpu->max; + /* - * Utilization required by DEADLINE must always be granted while, for - * FAIR, we use blocked utilization of IDLE CPUs as a mechanism to - * gracefully reduce the frequency when no tasks show up for longer + * As there is still idle time on the CPU, we need to compute the + * utilization level of the CPU. + * Bandwidth required by DEADLINE must always be granted while, for + * FAIR and RT, we use blocked utilization of IDLE CPUs as a mechanism + * to gracefully reduce the frequency when no tasks show up for longer * periods of time. - * - * Ideally we would like to set util_dl as min/guaranteed freq and - * util_cfs + util_dl as requested freq. However, cpufreq is not yet - * ready for such an interface. So, we only do the latter for now. */ + + /* Add DL bandwidth requirement */ + util += sg_cpu->bw_dl; + return min(sg_cpu->max, util); } diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 4526ba6..bc4305f 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2192,11 +2192,16 @@ static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) {} #endif #ifdef CONFIG_CPU_FREQ_GOV_SCHEDUTIL -static inline unsigned long cpu_util_dl(struct rq *rq) +static inline unsigned long cpu_bw_dl(struct rq *rq) { return (rq->dl.running_bw * SCHED_CAPACITY_SCALE) >> BW_SHIFT; } +static inline unsigned long cpu_util_dl(struct rq *rq) +{ + return READ_ONCE(rq->avg_dl.util_avg); +} + static inline unsigned long cpu_util_cfs(struct rq *rq) { unsigned long util = READ_ONCE(rq->cfs.avg.util_avg);