lkml.org 
[lkml]   [2022]   [Jan]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 6/7] thermal: netlink: Add a new event to notify CPU capabilities change
From
Date
On Wed, 2022-01-12 at 20:25 +0100, Rafael J. Wysocki wrote:
> On Thu, Jan 6, 2022 at 3:49 AM Ricardo Neri
> <ricardo.neri-calderon@linux.intel.com> wrote:
> > From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> >
> > Add a new netlink event to notify change in CPU capabilities in
> > terms of
> > performance and efficiency.
> >
> > Firmware may change CPU capabilities as a result of thermal events
> > in the
> > system or to account for changes in the TDP (thermal design power)
> > level.
> >
> > This notification type will allow user space to avoid running
> > workloads
> > on certain CPUs or proactively adjust power limits to avoid future
> > events.
> >
> > The netlink message consists of a nested attribute
> > (THERMAL_GENL_ATTR_CPU_CAPABILITY) with three attributes:
> >
> > * THERMAL_GENL_ATTR_CPU_CAPABILITY_ID (type u32):
> > -- logical CPU number
> > * THERMAL_GENL_ATTR_CPU_CAPABILITY_PERFORMANCE (type u32):
> > -- Scaled performance from 0-1023
> > * THERMAL_GENL_ATTR_CPU_CAPABILITY_EFFICIENCY (type u32):
> > -- Scaled efficiency from 0-1023
> >
> > Cc: Andi Kleen <ak@linux.intel.com>
> > Cc: Aubrey Li <aubrey.li@linux.intel.com>
> > Cc: Lukasz Luba <lukasz.luba@arm.com>
> > Cc: Tim Chen <tim.c.chen@linux.intel.com>
> > Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
> > Reviewed-by: Len Brown <len.brown@intel.com>
> > Signed-off-by: Srinivas Pandruvada <
> > srinivas.pandruvada@linux.intel.com>
>
> Of course, I need to know if Daniel and Lukasz agree with this patch.
>
I pinged Daniel offline. I accommodated comments from Lukasz.

> > ---
> >

[...]

> > +static int thermal_genl_event_cpu_capability_change(struct param
> > *p)
> > +{
> > + struct cpu_capability *cpu_cap = p->cpu_capabilities;
> > + struct sk_buff *msg = p->msg;
> > + struct nlattr *start_cap;
> > + int i, ret;
> > +
> > + start_cap = nla_nest_start(msg,
> > THERMAL_GENL_ATTR_CPU_CAPABILITY);
> > + if (!start_cap)
> > + return -EMSGSIZE;
> > +
> > + for (i = 0; i < p->cpu_capabilities_count; ++i) {
> > + if (nla_put_u32(msg,
> > THERMAL_GENL_ATTR_CPU_CAPABILITY_ID,
> > + cpu_cap->cpu)) {
> > + ret = -EMSGSIZE;
> > + goto out_cancel_nest;
> > + }
> > + if (nla_put_u32(msg,
> > THERMAL_GENL_ATTR_CPU_CAPABILITY_PERFORMANCE,
> > + cpu_cap->performance)) {
> > + ret = -EMSGSIZE;
> > + goto out_cancel_nest;
> > + }
> > + if (nla_put_u32(msg,
> > THERMAL_GENL_ATTR_CPU_CAPABILITY_EFFICIENCY,
> > + cpu_cap->efficiency)) {
> > + ret = -EMSGSIZE;
> > + goto out_cancel_nest;
> > + }
> > + ++cpu_cap;
> > + }
> > +
> > + nla_nest_end(msg, start_cap);
> > +
> > + return 0;
> > +out_cancel_nest:
> > + nla_nest_cancel(msg, start_cap);
> > +
> > + return ret;
>
> It looks like ret is never different from -EMSGSIZE here, so I'd just
> return that error and drop the ret variable.
>
ret is initialized for every case when it will be returned. But agree
that we can just return -EMSGSIZE as there is no other return value
here.

> > +}
> > +
> >

[...]

> > +struct cpu_capability {
>
> I'm wondering if the struct name is not too generic as the purpose it
> is used for is rather narrow and specific.
>
This was named something else before. What about cpu_energy_perf_cap?


> > + int cpu;
> > + int performance;
> > + int efficiency;
> > +};
> > +
> >
Thanks,
Srinivas

\
 
 \ /
  Last update: 2022-01-12 22:34    [W:0.127 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site