From mboxrd@z Thu Jan 1 00:00:00 1970 From: Patrick Bellasi Subject: Re: [PATCH v8 04/16] sched/core: uclamp: Add system default clamps Date: Tue, 7 May 2019 11:38:45 +0100 Message-ID: <20190507103845.tejg55wfsu3l3jwh@e110439-lin> References: <20190402104153.25404-1-patrick.bellasi@arm.com> <20190402104153.25404-5-patrick.bellasi@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Suren Baghdasaryan Cc: LKML , linux-pm@vger.kernel.org, linux-api@vger.kernel.org, Ingo Molnar , Peter Zijlstra , 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 List-Id: linux-api@vger.kernel.org On 17-Apr 17:51, Suren Baghdasaryan wrote: > On Tue, Apr 2, 2019 at 3:42 AM Patrick Bellasi wrote: [...] > > +/* > > + * The effective clamp bucket index of a task depends on, by increasing > > + * priority: > > + * - the task specific clamp value, when explicitly requested from userspace > > + * - the system default clamp value, defined by the sysadmin > > + */ > > +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) > > This function is not used anywhere AFAIKT. Right, this is the dual of uclamp_eff_value() but, since we don't actually use it in the corrent code, let's remove it and keep only the latter. > uclamp_eff_bucket_id() and > uclamp_eff_value() look very similar, maybe they can be combined into > one function returning struct uclamp_se? I would prefer not since at the callsites of uclamp_eff_value() we actually need just the value. > > +{ > > + 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; > > +} > > + -- #include Patrick Bellasi