Re: [PATCH v8 04/16] sched/core: uclamp: Add system default clamps
From: Patrick Bellasi <hidden>
Date: 2019-05-09 09:11:05
Also in:
linux-pm, lkml
On 08-May 21:15, Peter Zijlstra wrote:
On Wed, May 08, 2019 at 09:07:33PM +0200, Peter Zijlstra wrote:quoted
On Tue, Apr 02, 2019 at 11:41:40AM +0100, Patrick Bellasi wrote:quoted
+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).valueClearly I means to say the above does not hold with the given implementation, while the naming would suggest it does.
Not sure to completely get your point... AFAIU, what you call uclamp_eff(p, id).value is the "value" member of the struct returned by uclamp_eff_get(p,id), which is back annotate by uclamp_rq_inc_id(p, rq, id) in: p->uclamp[clamp_id].value when a task becomes RUNNABLE.
quoted
Which seems to suggest the uclamp_eff_*() functions want another name.
That function returns the effective value of a task, which is either:
1. the back annotated value for a RUNNABLE task
or
2. the aggregation of task-specific, system-default and cgroup values
for a non RUNNABLE task.
quoted
Also, suppose the above would be true; does GCC really generate better code for the LHS compared to the RHS?
It generate "sane" code which implements the above logic and allows
to know that whenever we call uclamp_eff_value(p,id) we get the most
updated effective value for a task, independently from its {!}RUNNABLE
state.
I would keep the function but, since Suren also complained also about
the name... perhaps I should come up with a better name? Proposals?
--
#include <best/regards.h>
Patrick Bellasi