From: Jan Beulich <jbeulich@suse.com>
To: Jason Andryuk <jandryuk@gmail.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
"George Dunlap" <george.dunlap@citrix.com>,
"Julien Grall" <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v3 10/14 RESEND] xen: Add SET_CPUFREQ_HWP xen_sysctl_pm_op
Date: Mon, 22 May 2023 15:10:59 +0200 [thread overview]
Message-ID: <602ff9ef-e573-279e-441f-463ca7613fa6@suse.com> (raw)
In-Reply-To: <CAKf6xpti23_fmwVWOafjUU+OPHPOA7EWOfkShGT9Qqr9=mR9zQ@mail.gmail.com>
On 22.05.2023 14:45, Jason Andryuk wrote:
> On Mon, May 8, 2023 at 7:27 AM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> On 01.05.2023 21:30, Jason Andryuk wrote:
>>> @@ -531,6 +533,100 @@ int get_hwp_para(const struct cpufreq_policy *policy,
>>> return 0;
>>> }
>>>
>>> +int set_hwp_para(struct cpufreq_policy *policy,
>>> + struct xen_set_hwp_para *set_hwp)
>>
>> const?
>
> set_hwp can be const. policy is passed to hwp_cpufreq_target() &
> on_selected_cpus(), so it cannot readily be made const.
I was only meaning the 2nd parameter, yes.
>>> +{
>>> + unsigned int cpu = policy->cpu;
>>> + struct hwp_drv_data *data = per_cpu(hwp_drv_data, cpu);
>>> +
>>> + if ( data == NULL )
>>> + return -EINVAL;
>>> +
>>> + /* Validate all parameters first */
>>> + if ( set_hwp->set_params & ~XEN_SYSCTL_HWP_SET_PARAM_MASK )
>>> + return -EINVAL;
>>> +
>>> + if ( set_hwp->activity_window & ~XEN_SYSCTL_HWP_ACT_WINDOW_MASK )
>>> + return -EINVAL;
>>
>> Below you limit checks to when the respective control bit is set. I
>> think you want the same here.
>
> Not sure if you mean feature_hwp_activity_window or the bit in
> set_params as control bit. But, yes, they can both use some
> additional checking. IIRC, I wanted to always check
> ~XEN_SYSCTL_HWP_ACT_WINDOW_MASK, because bits should never be set
> whether or not the activity window is supported by hardware.
I took ...
>>> + if ( !feature_hwp_energy_perf &&
>>> + (set_hwp->set_params & XEN_SYSCTL_HWP_SET_ENERGY_PERF) &&
>>> + set_hwp->energy_perf > IA32_ENERGY_BIAS_MAX_POWERSAVE )
>>> + return -EINVAL;
>>> +
>>> + if ( (set_hwp->set_params & XEN_SYSCTL_HWP_SET_DESIRED) &&
>>> + set_hwp->desired != 0 &&
>>> + (set_hwp->desired < data->hw.lowest ||
>>> + set_hwp->desired > data->hw.highest) )
>>> + return -EINVAL;
... e.g. this for comparison, where you apply the range check only when
the XEN_SYSCTL_HWP_* bit is set. I think you want to be consistent in
such checking: Either you always allow the caller to not care about
fields that aren't going to be consumed when their controlling bit is
off, or you always check validity. Both approaches have their pros and
cons, I think.
Jan
next prev parent reply other threads:[~2023-05-22 13:11 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-01 19:30 [PATCH v3 00/14 RESEND] Intel Hardware P-States (HWP) support Jason Andryuk
2023-05-01 19:30 ` [PATCH v3 01/14 RESEND] cpufreq: Allow restricting to internal governors only Jason Andryuk
2023-05-01 19:30 ` [PATCH v3 02/14 RESEND] cpufreq: Add perf_freq to cpuinfo Jason Andryuk
2023-05-01 19:30 ` [PATCH v3 03/14 RESEND] cpufreq: Export intel_feature_detect Jason Andryuk
2023-05-04 11:16 ` Jan Beulich
2023-05-01 19:30 ` [PATCH v3 04/14 RESEND] cpufreq: Add Hardware P-State (HWP) driver Jason Andryuk
2023-05-04 13:11 ` Jan Beulich
2023-05-04 16:56 ` Jason Andryuk
2023-05-05 7:01 ` Jan Beulich
2023-05-05 15:35 ` Jason Andryuk
2023-05-08 6:33 ` Jan Beulich
2023-05-10 13:54 ` Jason Andryuk
2023-05-10 14:19 ` Jan Beulich
2023-05-12 1:02 ` Marek Marczykowski-Górecki
2023-05-12 6:28 ` Jan Beulich
2023-05-01 19:30 ` [PATCH v3 05/14 RESEND] xenpm: Change get-cpufreq-para output for internal Jason Andryuk
2023-05-04 14:35 ` Jan Beulich
2023-05-04 17:00 ` Jason Andryuk
2023-05-05 7:04 ` Jan Beulich
2023-05-05 15:40 ` Jason Andryuk
2023-05-01 19:30 ` [PATCH v3 06/14 RESEND] xen/x86: Tweak PDC bits when using HWP Jason Andryuk
2023-05-08 9:53 ` Jan Beulich
2023-05-10 14:08 ` Jason Andryuk
2023-05-01 19:30 ` [PATCH v3 07/14 RESEND] cpufreq: Export HWP parameters to userspace Jason Andryuk
2023-05-08 10:25 ` Jan Beulich
2023-05-08 10:46 ` Jan Beulich
2023-05-10 17:49 ` Jason Andryuk
2023-05-11 6:21 ` Jan Beulich
2023-05-11 13:49 ` Jason Andryuk
2023-05-11 14:10 ` Jan Beulich
2023-05-11 20:22 ` Jason Andryuk
2023-05-12 6:32 ` Jan Beulich
2023-05-01 19:30 ` [PATCH v3 08/14 RESEND] libxc: Include hwp_para in definitions Jason Andryuk
2023-05-19 13:53 ` Anthony PERARD
2023-05-01 19:30 ` [PATCH v3 09/14 RESEND] xenpm: Print HWP parameters Jason Andryuk
2023-05-08 10:43 ` Jan Beulich
2023-05-10 18:11 ` Jason Andryuk
2023-05-11 6:25 ` Jan Beulich
2023-05-01 19:30 ` [PATCH v3 10/14 RESEND] xen: Add SET_CPUFREQ_HWP xen_sysctl_pm_op Jason Andryuk
2023-05-08 11:27 ` Jan Beulich
2023-05-22 12:45 ` Jason Andryuk
2023-05-22 13:10 ` Jan Beulich [this message]
2023-05-22 14:43 ` Jason Andryuk
2023-05-01 19:30 ` [PATCH v3 11/14 RESEND] libxc: Add xc_set_cpufreq_hwp Jason Andryuk
2023-05-19 13:55 ` Anthony PERARD
2023-05-01 19:30 ` [PATCH v3 12/14 RESEND] xenpm: Factor out a non-fatal cpuid_parse variant Jason Andryuk
2023-05-08 12:01 ` Jan Beulich
2023-05-01 19:30 ` [PATCH v3 13/14 RESEND] xenpm: Add set-cpufreq-hwp subcommand Jason Andryuk
2023-05-08 11:56 ` Jan Beulich
2023-05-08 12:00 ` Jan Beulich
2023-05-22 12:59 ` Jason Andryuk
2023-05-22 13:20 ` Jan Beulich
2023-05-01 19:30 ` [PATCH v3 14/14 RESEND] CHANGELOG: Add Intel HWP entry Jason Andryuk
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=602ff9ef-e573-279e-441f-463ca7613fa6@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jandryuk@gmail.com \
--cc=julien@xen.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.