Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp887249imm; Tue, 5 Jun 2018 06:07:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLMI7G9sta2MjXOZ3qPfNSvh0HuFpxUmmJbx2RFPsg9mCrCCoBLFySyiTeUjtDHUybGMAL/ X-Received: by 2002:a17:902:aa95:: with SMTP id d21-v6mr25962768plr.73.1528204074133; Tue, 05 Jun 2018 06:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528204074; cv=none; d=google.com; s=arc-20160816; b=Cr7sy3eqWGJu+MuJPD9mLheD/LKigPnICaHkNhNcDNMX430XPwY/ZU4SRIRmkEyOPC AUQ/5h0aXE6oEmXrVcirGffgWt18icToSWUBaJ7XyEN0DUpRnxpMxv4K0eF29gYQ7Qt6 VnIekL5c85h2/rRLJ9sUc/c8jogoOZ4FD05RZ7xbCo6bH/o80nIGXe8TniAmethBqrbA DJe4V/M1pUMfWpOFQyb+rR48//qfdYIm5FZHzYCburIawJUWnW4ge/OOVl/5MZg7RdNR 7lwTIUWfUyCek02PJizPhqlWxulwlBac2yIuTJ2xSOOl7tMWMco2y5eyliUfJ8lCrB9s dxcg== 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=e8rezJlC5LiEof0l74VRvSBcMnaOeC3dUnH+G6JXrnU=; b=BHSLTu6fyZuQeI05NamGczuRM33jJV+WIhhvwsilqUnpkZYX43F89OkQPpVlwfgKGu COGmPJmADVOPNIzwSTd5Qzshd+ut4GRC8B13mVptb4q3feI96q5GIdr4adGspDMMdw5q lTfQnOBoJip2OE4bjZ/YwZcBygGotaf/GfHiJC6Oj/zGfHTUEpVewEHaeyXhDMcD370l v1LkHCJ46zA4Ox71F1v/E4Q62GiGuQ+hscM1f98ZqiDzQIjAg7lsjMYtv/Py4V6Z1JX+ yfSXRzwTRos3G3aoMOowPb6zhfSysSX5tsmxUe+15LOotWBtVJ+CpUG8ULld9fTa8xuJ Yo1g== 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 i73-v6si5100156pgd.691.2018.06.05.06.07.39; Tue, 05 Jun 2018 06:07:54 -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 S1751808AbeFENFx (ORCPT + 99 others); Tue, 5 Jun 2018 09:05:53 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:55642 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbeFENFw (ORCPT ); Tue, 5 Jun 2018 09:05:52 -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 915A51435; Tue, 5 Jun 2018 06:05:51 -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 C6EBD3F5A0; Tue, 5 Jun 2018 06:05:49 -0700 (PDT) Date: Tue, 5 Jun 2018 14:05:48 +0100 From: Quentin Perret To: Juri Lelli Cc: Vincent Guittot , Peter Zijlstra , Ingo Molnar , linux-kernel , "Rafael J. Wysocki" , Dietmar Eggemann , Morten Rasmussen , viresh kumar , Valentin Schneider Subject: Re: [PATCH v5 00/10] track CPU utilization Message-ID: <20180605130548.GB12193@e108498-lin.cambridge.arm.com> References: <1527253951-22709-1-git-send-email-vincent.guittot@linaro.org> <20180605105721.GA12193@e108498-lin.cambridge.arm.com> <20180605121153.GD16081@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180605121153.GD16081@localhost.localdomain> 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 On Tuesday 05 Jun 2018 at 14:11:53 (+0200), Juri Lelli wrote: > Hi Quentin, > > On 05/06/18 11:57, Quentin Perret wrote: > > [...] > > > What about the diff below (just a quick hack to show the idea) applied > > on tip/sched/core ? > > > > ---8<--- > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > > index a8ba6d1f262a..23a4fb1c2c25 100644 > > --- a/kernel/sched/cpufreq_schedutil.c > > +++ b/kernel/sched/cpufreq_schedutil.c > > @@ -180,9 +180,12 @@ static void sugov_get_util(struct sugov_cpu *sg_cpu) > > sg_cpu->util_dl = cpu_util_dl(rq); > > } > > > > +unsigned long scale_rt_capacity(int cpu); > > static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu) > > { > > struct rq *rq = cpu_rq(sg_cpu->cpu); > > + int cpu = sg_cpu->cpu; > > + unsigned long util, dl_bw; > > > > if (rq->rt.rt_nr_running) > > return sg_cpu->max; > > @@ -197,7 +200,14 @@ static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu) > > * 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. > > */ > > - return min(sg_cpu->max, (sg_cpu->util_dl + sg_cpu->util_cfs)); > > + util = arch_scale_cpu_capacity(NULL, cpu) * scale_rt_capacity(cpu); > > Sorry to be pedantinc, but this (ATM) includes DL avg contribution, so, > since we use max below, we will probably have the same problem that we > discussed on Vincent's approach (overestimation of DL contribution while > we could use running_bw). Ah no, you're right, this isn't great for long running deadline tasks. We should definitely account for the running_bw here, not the dl avg... I was trying to address the issue of RT stealing time from CFS here, but the DL integration isn't quite right which this patch as-is, I agree ... > > > + util >>= SCHED_CAPACITY_SHIFT; > > + util = arch_scale_cpu_capacity(NULL, cpu) - util; > > + util += sg_cpu->util_cfs; > > + dl_bw = (rq->dl.this_bw * SCHED_CAPACITY_SCALE) >> BW_SHIFT; > > Why this_bw instead of running_bw? So IIUC, this_bw should basically give you the absolute reservation (== the sum of runtime/deadline ratios of all DL tasks on that rq). The reason I added this max is because I'm still not sure to understand how we can safely drop the freq below that point ? If we don't guarantee to always stay at least at the freq required by DL, aren't we risking to start a deadline tasks stuck at a low freq because of rate limiting ? In this case, if that tasks uses all of its runtime then you might start missing deadlines ... My feeling is that the only safe thing to do is to guarantee to never go below the freq required by DL, and to optimistically add CFS tasks without raising the OPP if we have good reasons to think that DL is using less than it required (which is what we should get by using running_bw above I suppose). Does that make any sense ? Thanks ! Quentin