From patchwork Mon Dec 4 10:23:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 120499 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4244752qgn; Mon, 4 Dec 2017 02:24:16 -0800 (PST) X-Google-Smtp-Source: AGs4zMZyX0UC6rafvjmD/GimH2+5FZhmGSEbVgFGVBrTpqR2OwOHb7lC+kDTlusssFptzzMwqA0y X-Received: by 10.84.134.34 with SMTP id 31mr14216851plg.154.1512383056691; Mon, 04 Dec 2017 02:24:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512383056; cv=none; d=google.com; s=arc-20160816; b=ZASq1Tu/vsM3VaLyNP5SFAMc208xW6AvrLjzwNfjqNpIW7NIE5yV3orcMnAQUtlY/q D1eMdEpzNfc77nlNuVWnLaqQt5AX3UQIwIkyjPJXr9sg55cJ7NuoPCRxz7iNufs50YsT 9gWH/h3GChP+Waf+Kdh93Bli7+7ZbVwRsp0EsVIZz9HzOQijHpSzD00OzoeYCFA/FN/b cnkoTLAVVeS0zBJOpIJFS39bIVQTTUNEzAIlZnyzyHElHc6flpkqsf45O4C1/gFtY/6F +P6lKlsyQPMLuAqVVsrC+kF2jsxvGEpwxFkcDgR5kMrOilWnz1P33yALtYTUvYMmkBL/ CBGA== 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:arc-authentication-results; bh=0XhyR1UASuJ8L7pnK8ePgzf3K/mAtz1dG3Iqsd5Bb4k=; b=PkHR2esf8TfQ6R8585c44znUJ+Ss1XEzwotzhrw9osdZbg39+kekJMf/8Y63OZm/mA LjseD5j/eq3/L68a9VCpEr7UrWrEkrxIcVLWQ/74MAWxdalP573KXCjKQnZNZrS7K2JU 0Gdb7Zb7ih5oxiIz6AlgziWRSXYiWjhUQ/0QGMVUPJaYMJ7CZNf65rLm79//1SD54m4g N/fv1AXAWSjnm9Yje0dqqabFZrCrgUKLcb08Bbu1f1Losf7BxiWAm+6FsWp6/ufqbymt rkKXwjYVzZ6rJroiqG+mvMebStX4GOLHswwQ6y7EsS16PDcvla/gY5HdMV1EieZJ45Bu XLjQ== ARC-Authentication-Results: i=1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t19si9350389plo.269.2017.12.04.02.24.16; Mon, 04 Dec 2017 02:24:16 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753596AbdLDKYN (ORCPT + 28 others); Mon, 4 Dec 2017 05:24:13 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:40124 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752166AbdLDKYG (ORCPT ); Mon, 4 Dec 2017 05:24:06 -0500 Received: by mail-wr0-f194.google.com with SMTP id q9so16627145wre.7 for ; Mon, 04 Dec 2017 02:24:05 -0800 (PST) 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=0XhyR1UASuJ8L7pnK8ePgzf3K/mAtz1dG3Iqsd5Bb4k=; b=KyPyQsvvzX1/gldULVFs0GfIfU/49pIIdkOQqm5KcJuzWyYkgpe2M3xih4xkB+DFHM p3T7MloKnm65TDqMAB8M4ncc0dVr+yuDEvVDIXE14O+YsrwlhOw74lSS73jkzcDJ4CUh UONZeGPKMhRlxqTyOhR50cyCrQdG6/f8OASu9z6Rqerz1VxrErekus7WCMbGtg2AmW5i +ddZ/m7ZA841q0HKDfUYJ2Dp2SnFaz9JENaSEK5gmU9YuyHuQ0azNS2y47LdHKAgK52y W0Lvd9WJBsumNX70q8zys1DnP3XTuuhvRBgtdp1SHjhqcJjiaui0TrtWwsvbu+Z+0KQE bAJQ== X-Gm-Message-State: AJaThX5KG4Q6IvbDqe6459InBhzZsZ/e35COD2/9b1gspyEqVmf30vJ/ mz0MA6/H/T+ZLrR9vn3/4oHq8A== X-Received: by 10.223.170.143 with SMTP id h15mr13081351wrc.49.1512383044832; Mon, 04 Dec 2017 02:24:04 -0800 (PST) Received: from localhost.localdomain.com ([151.68.92.1]) by smtp.gmail.com with ESMTPSA id y2sm13542473wra.18.2017.12.04.02.24.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Dec 2017 02:24:04 -0800 (PST) From: Juri Lelli To: peterz@infradead.org, mingo@redhat.com, rjw@rjwysocki.net, viresh.kumar@linaro.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, tglx@linutronix.de, vincent.guittot@linaro.org, rostedt@goodmis.org, luca.abeni@santannapisa.it, claudio@evidence.eu.com, tommaso.cucinotta@santannapisa.it, bristot@redhat.com, mathieu.poirier@linaro.org, tkjos@android.com, joelaf@google.com, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, patrick.bellasi@arm.com, alessio.balsini@arm.com, juri.lelli@redhat.com, Juri Lelli , Ingo Molnar , "Rafael J . Wysocki" Subject: [RFC PATCH v2 1/8] sched/cpufreq_schedutil: make use of DEADLINE utilization signal Date: Mon, 4 Dec 2017 11:23:18 +0100 Message-Id: <20171204102325.5110-2-juri.lelli@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171204102325.5110-1-juri.lelli@redhat.com> References: <20171204102325.5110-1-juri.lelli@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juri Lelli SCHED_DEADLINE tracks active utilization signal with a per dl_rq variable named running_bw. Make use of that to drive cpu frequency selection: add up FAIR and DEADLINE contribution to get the required CPU capacity to handle both requirements (while RT still selects max frequency). Co-authored-by: Claudio Scordino Signed-off-by: Juri Lelli Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Rafael J. Wysocki Cc: Viresh Kumar Cc: Luca Abeni Acked-by: Viresh Kumar --- include/linux/sched/cpufreq.h | 2 -- kernel/sched/cpufreq_schedutil.c | 25 +++++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) -- 2.14.3 diff --git a/include/linux/sched/cpufreq.h b/include/linux/sched/cpufreq.h index d1ad3d825561..0b55834efd46 100644 --- a/include/linux/sched/cpufreq.h +++ b/include/linux/sched/cpufreq.h @@ -12,8 +12,6 @@ #define SCHED_CPUFREQ_DL (1U << 1) #define SCHED_CPUFREQ_IOWAIT (1U << 2) -#define SCHED_CPUFREQ_RT_DL (SCHED_CPUFREQ_RT | SCHED_CPUFREQ_DL) - #ifdef CONFIG_CPU_FREQ struct update_util_data { void (*func)(struct update_util_data *data, u64 time, unsigned int flags); diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 2f52ec0f1539..de1ad1fffbdc 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -179,12 +179,17 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, static void sugov_get_util(unsigned long *util, unsigned long *max, int cpu) { struct rq *rq = cpu_rq(cpu); - unsigned long cfs_max; + unsigned long dl_util = (rq->dl.running_bw * SCHED_CAPACITY_SCALE) + >> BW_SHIFT; - cfs_max = arch_scale_cpu_capacity(NULL, cpu); + *max = arch_scale_cpu_capacity(NULL, cpu); - *util = min(rq->cfs.avg.util_avg, cfs_max); - *max = cfs_max; + /* + * 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. + */ + *util = min(rq->cfs.avg.util_avg + dl_util, *max); } static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, @@ -272,7 +277,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, busy = sugov_cpu_is_busy(sg_cpu); - if (flags & SCHED_CPUFREQ_RT_DL) { + if (flags & SCHED_CPUFREQ_RT) { next_f = policy->cpuinfo.max_freq; } else { sugov_get_util(&util, &max, sg_cpu->cpu); @@ -317,7 +322,7 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time) j_sg_cpu->iowait_boost_pending = false; continue; } - if (j_sg_cpu->flags & SCHED_CPUFREQ_RT_DL) + if (j_sg_cpu->flags & SCHED_CPUFREQ_RT) return policy->cpuinfo.max_freq; j_util = j_sg_cpu->util; @@ -353,7 +358,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, sg_cpu->last_update = time; if (sugov_should_update_freq(sg_policy, time)) { - if (flags & SCHED_CPUFREQ_RT_DL) + if (flags & SCHED_CPUFREQ_RT) next_f = sg_policy->policy->cpuinfo.max_freq; else next_f = sugov_next_freq_shared(sg_cpu, time); @@ -383,9 +388,9 @@ static void sugov_irq_work(struct irq_work *irq_work) sg_policy = container_of(irq_work, struct sugov_policy, irq_work); /* - * For RT and deadline tasks, the schedutil governor shoots the - * frequency to maximum. Special care must be taken to ensure that this - * kthread doesn't result in the same behavior. + * For RT tasks, the schedutil governor shoots the frequency to maximum. + * Special care must be taken to ensure that this kthread doesn't result + * in the same behavior. * * This is (mostly) guaranteed by the work_in_progress flag. The flag is * updated only at the end of the sugov_work() function and before that