Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4675532imm; Wed, 30 May 2018 09:47:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKg8NRh0qdrEMFql6l5l1bSpAjgrknJH439DxIF37QLMVgQ69tjr0V/MsH4Dv4EBlfMjImV X-Received: by 2002:a17:902:3f81:: with SMTP id a1-v6mr3498291pld.29.1527698878570; Wed, 30 May 2018 09:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527698878; cv=none; d=google.com; s=arc-20160816; b=o2h0/baWPhpbJ7Rfr+SUYyhilVlTqxAhG6+aF6ibb2mU++Z3ilnYMmfdfNCHy/UdOK GSqPXhshb9suaBQrq25X31NmNpjGAtzLHfI+VXzPxdgNqSdA6UpECJ/NrsG0AAsa5AEa p2x9vyKDX+05xCT3N3CfH9XSvmrJilcclFO6t2uf90e+581Lp85hbOTa93Mf0FZXFlvY +SDlKo4fIwiBJcDhhprSLl50ocWBadDc7jI5rjjTxUOkO3h5GjZ2HCaMub5Ei+bvSqlC FDDOjZxSQk6L6MMBhW7S299pLulsRs8P6/l4ErN7X8crUO91YdY+QVf49MbfMIezvy4P V6gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=bxkrA+VeWC80UAjd7grTWjTXuZDc3Y9re/S4KZUcxbM=; b=QmlqGglHweZfMU/M9SCuamWCE5vDNKS6lxM8gvreQxB5uxid41EZgaSVpflIjX1PFw 3Qg+fS4QfOOTUKWBwZmgKTseNs/62WdLaxolbxUS4EBkgeFYjF+2/v9kKTe1YC5ahwOS 5MebE0T321GtHFaTJrlDSgzmoxgkK6u+F+KiAqSfy8xCw2QsenGuWAbC3wW1nhgWniP3 /D2UwKVx8B/ytdYE3MKVM6mft/XBxDO7W7Duy9ITEyPHCISnl9Nicbv3OqGlsXK5mW1V 9CFbsxxfmHbiKCqJiDE8nbs3WC6BQSYHSfLhJs6EGnpOq419oq/nDo0FJfQZux2xeKLp YW+w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b70-v6si11923352pga.536.2018.05.30.09.47.44; Wed, 30 May 2018 09:47:58 -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 S1753982AbeE3QqJ (ORCPT + 99 others); Wed, 30 May 2018 12:46:09 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59468 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753816AbeE3QqF (ORCPT ); Wed, 30 May 2018 12:46:05 -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 3F97115AD; Wed, 30 May 2018 09:46:05 -0700 (PDT) Received: from e108498-lin.cambridge.arm.com (e108498-lin.cambridge.arm.com [10.1.210.84]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 75E6D3F25D; Wed, 30 May 2018 09:46:03 -0700 (PDT) Date: Wed, 30 May 2018 17:46:01 +0100 From: Quentin Perret To: Vincent Guittot Cc: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, rjw@rjwysocki.net, juri.lelli@redhat.com, dietmar.eggemann@arm.com, Morten.Rasmussen@arm.com, viresh.kumar@linaro.org, valentin.schneider@arm.com Subject: Re: [PATCH v5 03/10] cpufreq/schedutil: add rt utilization tracking Message-ID: <20180530164601.GC2174@e108498-lin.cambridge.arm.com> References: <1527253951-22709-1-git-send-email-vincent.guittot@linaro.org> <1527253951-22709-4-git-send-email-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1527253951-22709-4-git-send-email-vincent.guittot@linaro.org> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vincent, On Friday 25 May 2018 at 15:12:24 (+0200), Vincent Guittot wrote: > Add both cfs and rt utilization when selecting an OPP for cfs tasks as rt > can preempt and steal cfs's running time. > > Signed-off-by: Vincent Guittot > --- > kernel/sched/cpufreq_schedutil.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > index 28592b6..a84b5a5 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 util_rt; > unsigned long max; > > /* The field below is for single-CPU policies only: */ > @@ -178,14 +179,21 @@ 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->util_rt = cpu_util_rt(rq); > } > > static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu) > { > struct rq *rq = cpu_rq(sg_cpu->cpu); > + unsigned long util; > > - if (rq->rt.rt_nr_running) > - return sg_cpu->max; > + if (rq->rt.rt_nr_running) { > + util = sg_cpu->max; So I understand why we want to got to max freq when a RT task is running, but I think there are use cases where we might want to be more conservative and use the util_avg of the RT rq instead. The first use case is battery-powered devices where going to max isn't really affordable from an energy standpoint. Android, for example, has been using a RT utilization signal to select OPPs for quite a while now, because going to max blindly is _very_ expensive. And the second use-case is thermal pressure. On some modern CPUs, going to max freq can lead to stringent thermal capping very quickly, at the point where your CPUs might not have enough capacity to serve your tasks properly. And that can ultimately hurt the very RT tasks you originally tried to run fast. In these systems, in the long term, you'd be better off not asking for more than what you really need ... So what about having a sched_feature to select between going to max and using the RT util_avg ? Obviously the default should keep the current behaviour. Thanks, Quentin