From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH v8 04/16] sched/core: uclamp: Add system default clamps Date: Wed, 8 May 2019 21:15:29 +0200 Message-ID: <20190508191529.GA26813@worktop.programming.kicks-ass.net> References: <20190402104153.25404-1-patrick.bellasi@arm.com> <20190402104153.25404-5-patrick.bellasi@arm.com> <20190508190733.GC32547@worktop.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190508190733.GC32547@worktop.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org 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 List-Id: linux-api@vger.kernel.org On Wed, May 08, 2019 at 09:07:33PM +0200, Peter Zijlstra wrote: > On Tue, Apr 02, 2019 at 11:41:40AM +0100, Patrick Bellasi wrote: > > +static inline struct uclamp_se > > +uclamp_eff_get(struct task_struct *p, unsigned int clamp_id) > > +{ > > + struct uclamp_se uc_req = p->uclamp_req[clamp_id]; > > + struct uclamp_se uc_max = uclamp_default[clamp_id]; > > + > > + /* System default restrictions always apply */ > > + if (unlikely(uc_req.value > uc_max.value)) > > + return uc_max; > > + > > + return uc_req; > > +} > > + > > +static inline unsigned int > > +uclamp_eff_bucket_id(struct task_struct *p, unsigned int clamp_id) > > +{ > > + struct uclamp_se uc_eff; > > + > > + /* Task currently refcounted: use back-annotated (effective) bucket */ > > + if (p->uclamp[clamp_id].active) > > + return p->uclamp[clamp_id].bucket_id; > > + > > + uc_eff = uclamp_eff_get(p, clamp_id); > > + > > + return uc_eff.bucket_id; > > +} > > + > > +unsigned int uclamp_eff_value(struct task_struct *p, unsigned int clamp_id) > > +{ > > + struct uclamp_se uc_eff; > > + > > + /* Task currently refcounted: use back-annotated (effective) value */ > > + if (p->uclamp[clamp_id].active) > > + return p->uclamp[clamp_id].value; > > + > > + uc_eff = uclamp_eff_get(p, clamp_id); > > + > > + return uc_eff.value; > > +} > > This is 'wrong' because: > > uclamp_eff_value(p,id) := uclamp_eff(p,id).value Clearly I means to say the above does not hold with the given implementation, while the naming would suggest it does. > Which seems to suggest the uclamp_eff_*() functions want another name. > > Also, suppose the above would be true; does GCC really generate better > code for the LHS compared to the RHS?