Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp899377imm; Tue, 5 Jun 2018 06:17:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK4irRcWWBG71z8vw1iw0d+PgldyHsE1DbNt3PkSzDv4DuUwEaScVOXhyBK/j4uOeTQE4bF X-Received: by 2002:a63:7b51:: with SMTP id k17-v6mr20852909pgn.55.1528204651431; Tue, 05 Jun 2018 06:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528204651; cv=none; d=google.com; s=arc-20160816; b=rLrzhan6l1OC2Y01cFa1I/IFRoI9aJy2Rh1jpRyoulGiDSt4XmaKp1HyljSgYqvcfG 0ddyvxxlRpS71FgbjKW5mZdJkMva4qdy0zXa31x1XHjXK2LYq+16yQKSdWUEijZWfKcS CsMzAPbOK0IqrrTWNv62q21+esDzwUUooauNp4qA0Z7TJmneV1lM+hxfH8dcSNaLMWNo XiFK6+Tt7c6BZJlNIJTxVi/SuFwduyVQn8ULQgGEzd2/7OpgmyVfRyGenNCpVahaDB7r LE55CwTQCnxnreFgAxnFEH1t3zKVSYs8CnjjcpPTdolTEad+uiGQnaXPAvRZwjhKdbHv BqAw== 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=X7I7PD9Bt8nvtS0uY+TH3mWwQ5OES8HgaE4HFpWxa7s=; b=UXVlNqlRPFNccvIiPQiRPrNPLSw4F/J9/65V0+cH754Znfu8k58l2PAjW68FdG7tpe YjRAHT6XzikOPcAHytMr0em1E5AvxifnnEf+oQGmgw5xAKNTQtaBp+qgxV93wXPZn1F5 x6R+287D3xv09l9qu8woGsjy8E1jsqaboEU1J1DS8s0JQMt7yr6JK+MblaM2ZTqqPEVV SlVRBuzOhtEpAeoC2BFNUKUfzrfERWbn1tKWaJzwyWBHLT/hEvPeM7Pumpn6NgBS7gDd knnvMfnHkXWKxI9EscTOYT4QQg+eay94Q31Hf7LUq81QD6RL5wcQzmg41Oa9RsNkkG77 MLqA== 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 x6-v6si17943629pgo.448.2018.06.05.06.17.13; Tue, 05 Jun 2018 06:17:31 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751901AbeFENPX (ORCPT + 99 others); Tue, 5 Jun 2018 09:15:23 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:38381 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbeFENPW (ORCPT ); Tue, 5 Jun 2018 09:15:22 -0400 Received: by mail-wr0-f193.google.com with SMTP id 94-v6so2393821wrf.5 for ; Tue, 05 Jun 2018 06:15:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=X7I7PD9Bt8nvtS0uY+TH3mWwQ5OES8HgaE4HFpWxa7s=; b=jz7v5qc+iqK7ktZdYJvqzbPAgjvs7NVgjwGNR7Ed487wIc2froUJNrefgXtMjLwbGO 3CDrEtPT1SQwB7CkKVgh9DX6FDoJyRdFQcmh30YAILJwaqTs3K2FGP4Y8Klj6wAgMrsu Smqxcaj6v290J5/ODb0yN0zrhvKPZq4xxYJwkhU69r8zhNWJltx/9J6SEm4nVDrE54XS VZb+w8eXRkYLvWMEshfkLx8Kmz0NBI2FP24BisM4hqOnD2IQ3QQGORMJAybBrX02vye9 iYrUDpXwNvzpqSyzRflyYqEjNi+wipGKjF3yE+n5ySof4BN3LTtU9JoDhwyW5T0POW6W 44DQ== X-Gm-Message-State: ALKqPwdzUUN1IZ1ChVLyGfggtMeh3ay7FHTZ6nZv3ud+1GdL+Pn0Uhkn lmwrbnjqeERfuPL923NM6WXTzg== X-Received: by 2002:adf:94e3:: with SMTP id 90-v6mr15166150wrr.110.1528204520902; Tue, 05 Jun 2018 06:15:20 -0700 (PDT) Received: from localhost.localdomain ([151.15.207.242]) by smtp.gmail.com with ESMTPSA id r5-v6sm30536323wrp.59.2018.06.05.06.15.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 06:15:20 -0700 (PDT) Date: Tue, 5 Jun 2018 15:15:18 +0200 From: Juri Lelli To: Quentin Perret 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: <20180605131518.GG16081@localhost.localdomain> References: <1527253951-22709-1-git-send-email-vincent.guittot@linaro.org> <20180605105721.GA12193@e108498-lin.cambridge.arm.com> <20180605121153.GD16081@localhost.localdomain> <20180605130548.GB12193@e108498-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180605130548.GB12193@e108498-lin.cambridge.arm.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/06/18 14:05, Quentin Perret wrote: > 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). Yep. > 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 ... We decided to avoid (software) rate limiting for DL with e97a90f7069b ("sched/cpufreq: Rate limits for SCHED_DEADLINE"). > 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 ? Then we can't still avoid the hardware limits, so using running_bw is a trade off between safety (especially considering soft real-time scenarios) and energy consumption (which seems to be working in practice). Thanks, - Juri