linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	Len Brown <len.brown@intel.com>,
	Aubrey Li <aubrey.li@linux.intel.com>,
	Amit Kucheria <amitk@kernel.org>, Andi Kleen <ak@linux.intel.com>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	Lukasz Luba <lukasz.luba@arm.com>,
	"Ravi V. Shankar" <ravi.v.shankar@intel.com>,
	Ricardo Neri <ricardo.neri@intel.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 6/7] thermal: netlink: Add a new event to notify CPU capabilities change
Date: Wed, 12 Jan 2022 13:32:46 -0800	[thread overview]
Message-ID: <7dde8e84961e09066c6bf02198e429d3a702a496.camel@linux.intel.com> (raw)
In-Reply-To: <CAJZ5v0ioQ7UQt58NraPAG=M8k-joSy5pmszFjp=NcS6z==6RQg@mail.gmail.com>

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


  reply	other threads:[~2022-01-12 21:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06  2:50 [PATCH v3 0/7] Thermal: Introduce the Hardware Feedback Interface for thermal and performance management Ricardo Neri
2022-01-06  2:50 ` [PATCH v3 1/7] x86/Documentation: Describe the Intel Hardware Feedback Interface Ricardo Neri
2022-01-06  2:50 ` [PATCH v3 2/7] x86/cpu: Add definitions for " Ricardo Neri
2022-01-06  2:50 ` [PATCH v3 3/7] thermal: intel: hfi: Minimally initialize the " Ricardo Neri
2022-01-06  2:50 ` [PATCH v3 4/7] thermal: intel: hfi: Handle CPU hotplug events Ricardo Neri
2022-01-08  1:29   ` Ricardo Neri
2022-01-06  2:50 ` [PATCH v3 5/7] thermal: intel: hfi: Enable notification interrupt Ricardo Neri
2022-01-06  2:50 ` [PATCH v3 6/7] thermal: netlink: Add a new event to notify CPU capabilities change Ricardo Neri
2022-01-12 19:25   ` Rafael J. Wysocki
2022-01-12 21:32     ` Srinivas Pandruvada [this message]
2022-01-14 19:35       ` Rafael J. Wysocki
2022-01-06  2:50 ` [PATCH v3 7/7] thermal: intel: hfi: Notify user space for HFI events Ricardo Neri
2022-01-08  1:30 ` [PATCH v3 0/7] Thermal: Introduce the Hardware Feedback Interface for thermal and performance management Ricardo Neri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7dde8e84961e09066c6bf02198e429d3a702a496.camel@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=ak@linux.intel.com \
    --cc=amitk@kernel.org \
    --cc=aubrey.li@linux.intel.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=len.brown@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=ravi.v.shankar@intel.com \
    --cc=ricardo.neri-calderon@linux.intel.com \
    --cc=ricardo.neri@intel.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).