Re: [PATCH 6/7] thermal: netlink: Add a new event to notify CPU capabilities change

From: Srinivas Pandruvada
Date: Tue Nov 09 2021 - 08:23:47 EST


Hi Lukasz,

On Tue, 2021-11-09 at 12:39 +0000, Lukasz Luba wrote:
> Hi Ricardo,
>
>
> On 11/6/21 1:33 AM, Ricardo Neri wrote:
> > From: Srinivas Pandruvada <srinivas.pandruvada@xxxxxxxxxxxxxxx>
> >
> > Add a new netlink event to notify change in CPU capabilities in
> > terms of
> > performance and efficiency.
>
> Is this going to be handled by some 'generic' tools? If yes, maybe
> the values for 'performance' might be aligned with capacity
> [0,1024] ? Or are they completely not related so the mapping is
> simply impossible?
>

That would have been very useful.

The problem is that we may not know the maximum performance as system
may be booting with few CPUs (using maxcpus kernel command line) and
then user hot adding them. So we may need to rescale when we get a new
maximum performance CPU and send to user space.

We can't just use max from HFI table at in instance as it is not
necessary that HFI table contains data for all CPUs.

If HFI max performance value of 255 is a scaled value to max
performance CPU value in the system, then this conversion would have
been easy. But that is not.



> >
> > 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.
> >
> > Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> > Cc: Aubrey Li <aubrey.li@xxxxxxxxxxxxxxx>
> > Cc: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>
> > Cc: "Ravi V. Shankar" <ravi.v.shankar@xxxxxxxxx>
> > Reviewed-by: Len Brown <len.brown@xxxxxxxxx>
> > Signed-off-by: Srinivas Pandruvada <
> > srinivas.pandruvada@xxxxxxxxxxxxxxx>
> > ---
> >   drivers/thermal/thermal_netlink.c | 52
> > +++++++++++++++++++++++++++++++
> >   drivers/thermal/thermal_netlink.h | 13 ++++++++
> >   include/uapi/linux/thermal.h      |  6 +++-
> >   3 files changed, 70 insertions(+), 1 deletion(-)
>
> [snip]
>
> >  
> > +struct cpu_capability {
> > +       int cpu;
> > +       int perf;
> > +       int eff;

Good idea.

Thanks,
Srinivas

>
> Why not use the full names, instead of thse shortcuts? We use full
> naming e.g. in cpufreq framework such as 'frequency' not 'freq'.
> The 'eff' is really not meaningful ('perf' a bit less but it has
> to meanings in kernel).
>
> Regards,
> Lukasz