Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp544355imm; Fri, 14 Sep 2018 02:33:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbIu3rJtQEvAEmpAmn32aMToOa0Bfquv7RRF7kUfs+HS2AOLltlN/H6nCjgAmlh4C7TO+J1 X-Received: by 2002:a17:902:5a06:: with SMTP id q6-v6mr11460948pli.330.1536917591475; Fri, 14 Sep 2018 02:33:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536917591; cv=none; d=google.com; s=arc-20160816; b=Ij+Q7O3Zo50fAdxakTk58eNp1s2KkKaLC+mTHzFNk8PjqtQCeNr7idiPUhzDvOwSmY 6CPYEg6FQPl8CUTWoQIvbYfyW39o+U/gT2oMr+S4jR2MrNxwfxm9MODzhmroaKsP2tzE wmlYs5m21+yHtF5WTbIFosODHbjmFFPOZuvMnY21pSmC59C5RrttTr8vhId8CtnUlrk8 tDtbxC8IR3gyiON727UwV30yx8x6lFM1x8rIUysG7y280Fl3Tt3uPkb24aCnEZpJ91Aa G4upqtUwqXJSuULrreYJXjxsbqME19ozxQp9O/A4ptAgiSIWONEXXxbAh3CLi4qXepaZ QU8g== 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:dkim-signature; bh=BcAHQIzeGGRnVsD7g3gsfynUSoS0HwcCFco1ifaChNQ=; b=zPAkWeO2fcwlckNbWcAKUlmbhG3QnYsiHKjXPAUMD/7xXOCHAQ4HUqMBN61IXL3fYb AO6uJfGZULG1GfRydqD/od3mMkB5yWw4Ljzc4zlTYdlNpJl3aU2bMNlNBTeqBfjSiE0A meQentQrqfG43/noiTFu9T1/OVUdFuKrx0nd1sJXqSqfSSGQjQjGjYfL1Gd75vOJJb25 xNAehFfEYQGa977nmLGNIjuaDI9HUnMTag9Z6UBbMgqA9asVv+jLq0znE5XBDw04YkXd ZFD904W45jgiX4qx188iU3z7uuDaBM52MN00Ez4ZCb/ilpyY5llxeyICHdcxtmY6Jvag DPRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ddpBAPxM; 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 u2-v6si6286422pge.585.2018.09.14.02.32.55; Fri, 14 Sep 2018 02:33:11 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ddpBAPxM; 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 S1728005AbeINOq3 (ORCPT + 99 others); Fri, 14 Sep 2018 10:46:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44852 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727670AbeINOq3 (ORCPT ); Fri, 14 Sep 2018 10:46:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=BcAHQIzeGGRnVsD7g3gsfynUSoS0HwcCFco1ifaChNQ=; b=ddpBAPxMJV0h4xKdFO4ezwmW+ LeCjPZdwFzLQa98+H4p/39WWvZ/7PLPL5lPgKCsj8mjcmYDdViDmFK9aBFCFLVUC5MeXoYb+1huEs JYSHoLKmeEOeNEDAXgBd7Nrm2xpI4oGx9xnIRvG07PjoD5V1eRZ/rJZXzXgdMj49qY9jq7Rz1p4Rs N0ueroo6twWZ6Pz6j9XHmBmmpBeKUzpNIm4J9CfU/RXnXdZu2DtL0AIMJdiPaMmZ2NPhnQQSJU0pd wXv+b1zaoxaHE4nHQUlUMeswZ0QUvWUGUoRbedWpbrCHhVZm3k4PpH3OxzGtGRT1uiUspXj4Xjjyg GZKrxALIw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g0kSw-0006Ai-LR; Fri, 14 Sep 2018 09:32:42 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 51C35202C1A32; Fri, 14 Sep 2018 11:32:40 +0200 (CEST) Date: Fri, 14 Sep 2018 11:32:40 +0200 From: Peter Zijlstra To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Tejun Heo , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Paul Turner , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan Subject: Re: [PATCH v4 06/16] sched/cpufreq: uclamp: add utilization clamping for FAIR tasks Message-ID: <20180914093240.GB24082@hirez.programming.kicks-ass.net> References: <20180828135324.21976-1-patrick.bellasi@arm.com> <20180828135324.21976-7-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180828135324.21976-7-patrick.bellasi@arm.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 28, 2018 at 02:53:14PM +0100, Patrick Bellasi wrote: > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > index 3fffad3bc8a8..949082555ee8 100644 > --- a/kernel/sched/cpufreq_schedutil.c > +++ b/kernel/sched/cpufreq_schedutil.c > @@ -222,8 +222,13 @@ static unsigned long sugov_get_util(struct sugov_cpu *sg_cpu) > * CFS tasks and we use the same metric to track the effective > * utilization (PELT windows are synchronized) we can directly add them > * to obtain the CPU's actual utilization. > + * > + * CFS utilization can be boosted or capped, depending on utilization > + * clamp constraints configured for currently RUNNABLE tasks. > */ > util = cpu_util_cfs(rq); > + if (util) > + util = uclamp_util(rq, util); Should that not be: util = clamp_util(rq, cpu_util_cfs(rq)); Because if !util might we not still want to enforce the min clamp? > util += cpu_util_rt(rq); > > /* > @@ -322,11 +328,24 @@ static void sugov_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, > return; > sg_cpu->iowait_boost_pending = true; > > + /* > + * Boost FAIR tasks only up to the CPU clamped utilization. > + * > + * Since DL tasks have a much more advanced bandwidth control, it's > + * safe to assume that IO boost does not apply to those tasks. > + * Instead, since RT tasks are not utiliation clamped, we don't want > + * to apply clamping on IO boost while there is blocked RT > + * utilization. > + */ > + max_boost = sg_cpu->iowait_boost_max; > + if (!cpu_util_rt(cpu_rq(sg_cpu->cpu))) > + max_boost = uclamp_util(cpu_rq(sg_cpu->cpu), max_boost); OK I suppose. > + > /* Double the boost at each request */ > if (sg_cpu->iowait_boost) { > sg_cpu->iowait_boost <<= 1; > - if (sg_cpu->iowait_boost > sg_cpu->iowait_boost_max) > - sg_cpu->iowait_boost = sg_cpu->iowait_boost_max; > + if (sg_cpu->iowait_boost > max_boost) > + sg_cpu->iowait_boost = max_boost; > return; > } > > +static inline unsigned int uclamp_value(struct rq *rq, int clamp_id) > +{ > + struct uclamp_cpu *uc_cpu = &rq->uclamp; > + > + if (uc_cpu->value[clamp_id] == UCLAMP_NOT_VALID) > + return uclamp_none(clamp_id); > + > + return uc_cpu->value[clamp_id]; > +} Would that not be more readable as: static inline unsigned int uclamp_value(struct rq *rq, int clamp_id) { unsigned int val = rq->uclamp.value[clamp_id]; if (unlikely(val == UCLAMP_NOT_VALID)) val = uclamp_none(clamp_id); return val; } And how come NOT_VALID is possible? I thought the idea was to always have all things a valid value.