lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 12 Jan 2022 13:32:46 -0800
From:   Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>
To:     "Rafael J. Wysocki" <rafael@...nel.org>,
        Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
Cc:     "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Linux PM <linux-pm@...r.kernel.org>,
        the arch/x86 maintainers <x86@...nel.org>,
        "open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
        Len Brown <len.brown@...el.com>,
        Aubrey Li <aubrey.li@...ux.intel.com>,
        Amit Kucheria <amitk@...nel.org>,
        Andi Kleen <ak@...ux.intel.com>,
        Tim Chen <tim.c.chen@...ux.intel.com>,
        Lukasz Luba <lukasz.luba@....com>,
        "Ravi V. Shankar" <ravi.v.shankar@...el.com>,
        Ricardo Neri <ricardo.neri@...el.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 6/7] thermal: netlink: Add a new event to notify CPU
 capabilities change

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@...ux.intel.com> wrote:
> > From: Srinivas Pandruvada <srinivas.pandruvada@...ux.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@...ux.intel.com>
> > Cc: Aubrey Li <aubrey.li@...ux.intel.com>
> > Cc: Lukasz Luba <lukasz.luba@....com>
> > Cc: Tim Chen <tim.c.chen@...ux.intel.com>
> > Cc: "Ravi V. Shankar" <ravi.v.shankar@...el.com>
> > Reviewed-by: Len Brown <len.brown@...el.com>
> > Signed-off-by: Srinivas Pandruvada <
> > srinivas.pandruvada@...ux.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ