Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3251534imc; Wed, 13 Mar 2019 12:47:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzr88qQsmhjSvqYu8ZYAV2yh/inJtpMgXUAn1Ur/8LB7/p2nZI5KxeIlR7kkOIggN80mu5e X-Received: by 2002:a17:902:822:: with SMTP id 31mr47347761plk.290.1552506455720; Wed, 13 Mar 2019 12:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552506455; cv=none; d=google.com; s=arc-20160816; b=DYzqjkfG/2R9Yt/XonapHyGuzHW8ye6d1nCAtyKuNBGSRB4/CgYlH6KJ3ZXr9WYHWo YcBvmlMGWHhgNhmA52QYyqq6y/JEfhZ+IR7Ch6bojYkTkh392MedPLv/X5EFCL/cVpOK IcBrlg+kwDWTF3syOom/3q4HnUXCxRMkwmkEa3nRdLkCujk09NRJbuKAsDDMlMGXHqCn 0C1sLfwlpX5AHm/cA1dvasZphJmYxI5SYguh0FoORyrLZY2TppepIc9f40OrzCevF38N Yrt+lNeVpX3qtMH2Osjlc1+2fU5SvczeDmezLC2+lmruh8OsJLLYreAJjsP0O67/icsk R3hQ== 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=A6s9/htiIv/3TV7CEQdjo1YKJWC3g9qNU18XwRg5TLA=; b=iDsILWHhUHorOfYuOBIpUaDu80cxF8TQYRFDbUMKxC7kAaGO+LadicTya5CJFpTmiJ TCaIXq5hd+SNivpXGo+XGu1EVB3Ntlv3RlwiD5MZlf8xs2Ed+vIT3YBACR72dNmiDDG0 PDgGC52SNncpuwltf3yVtVmGFss8pzi4Fm85kfCnSrinbRBbkep3ajOJGYihLsyp2p3c j9IidAZP5u3Zg5a4iMyodQ1sMWYPBh7ubsgwVtf7RQV1wzt3LNHMnDNkESBTpeKXEBCt aeN9H5oLM1p9qZFdpu5w01+aU552bFibbczfinRs03MKtkCkvCHozM2M/7XEHhaLKukC amVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=2efAug8e; 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 f8si4731175plr.44.2019.03.13.12.47.19; Wed, 13 Mar 2019 12:47:35 -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=merlin.20170209 header.b=2efAug8e; 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 S1727062AbfCMTql (ORCPT + 99 others); Wed, 13 Mar 2019 15:46:41 -0400 Received: from merlin.infradead.org ([205.233.59.134]:54264 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbfCMTql (ORCPT ); Wed, 13 Mar 2019 15:46:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=A6s9/htiIv/3TV7CEQdjo1YKJWC3g9qNU18XwRg5TLA=; b=2efAug8e0gqj0ZHi0kFbeRFS7 wLksMRNFYKBQ5tM+eWSqEc16UnHa8pW9oRehedJpjcuti/qi5w0pl31iF1bGNrpocz+Y1jkc6yUpi x03AUVH4ZD9yrenvecQSvO9jJuV8DmnGCL69SBV6tyK4NhJeI996DcyzWM9XsI8jG1digvy6YFq0m OCoArxcFX4z5cfU6zpSdRr3pTApbqhCYJ3H0/KLg+wsUDtEjGI0pEguZ9no9WGLXzKiuhV5g5Uzwa FV7Z3zCGKy2iqSD6vX3spgCaWUwbleIaQmz7QHjyZ5jrjLj6ZNU672tYdheStSGIWLTRC7tJE42v+ QSjPJSkcw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h49pV-00085Z-Sr; Wed, 13 Mar 2019 19:46:22 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 2566E9826C0; Wed, 13 Mar 2019 20:46:19 +0100 (CET) Date: Wed, 13 Mar 2019 20:46:19 +0100 From: Peter Zijlstra To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-api@vger.kernel.org, Ingo Molnar , Tejun Heo , "Rafael J . Wysocki" , Vincent Guittot , Viresh Kumar , Paul Turner , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan Subject: Re: [PATCH v7 01/15] sched/core: uclamp: Add CPU's clamp buckets refcounting Message-ID: <20190313194619.GR2482@worktop.programming.kicks-ass.net> References: <20190208100554.32196-1-patrick.bellasi@arm.com> <20190208100554.32196-2-patrick.bellasi@arm.com> <20190313140925.GE5922@hirez.programming.kicks-ass.net> <20190313152359.lkyzel7fakjoi5hu@e110439-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190313152359.lkyzel7fakjoi5hu@e110439-lin> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 13, 2019 at 03:23:59PM +0000, Patrick Bellasi wrote: > On 13-Mar 15:09, Peter Zijlstra wrote: > > On Fri, Feb 08, 2019 at 10:05:40AM +0000, Patrick Bellasi wrote: > > > +static inline void uclamp_rq_update(struct rq *rq, unsigned int clamp_id) > > > +{ > > > + struct uclamp_bucket *bucket = rq->uclamp[clamp_id].bucket; > > > + unsigned int max_value = uclamp_none(clamp_id); > > > > That's 1024 for uclamp_max > > > > > + unsigned int bucket_id; > > > + > > > + /* > > > + * Both min and max clamps are MAX aggregated, thus the topmost > > > + * bucket with some tasks defines the rq's clamp value. > > > + */ > > > + bucket_id = UCLAMP_BUCKETS; > > > + do { > > > + --bucket_id; > > > + if (!rq->uclamp[clamp_id].bucket[bucket_id].tasks) > > > + continue; > > > + max_value = bucket[bucket_id].value; > > > > but this will then _lower_ it. That's not a MAX aggregate. > > For uclamp_max we want max_value=1024 when there are no active tasks, > which means: no max clamp enforced on CFS/RT "idle" cpus. > > If instead there are active RT/CFS tasks then we want the clamp value > of the max group, which means: MAX aggregate active clamps. > > That's what the code above does and the comment says. That's (obviously) not how I read it... maybe something like: static inline void uclamp_rq_update(struct rq *rq, unsigned int clamp_id) { struct uclamp_bucket *bucket = rq->uclamp[clamp_id].bucket; int i; /* * Since both min and max clamps are max aggregated, find the * top most bucket with tasks in. */ for (i = UCLMAP_BUCKETS-1; i>=0; i--) { if (!bucket[i].tasks) continue; return bucket[i].value; } /* No tasks -- default clamp values */ return uclamp_none(clamp_id); } would make it clearer?