From: "Jan Beulich" Subject: Re: [PATCH v2 4/9] x86/intel_pstate: add new policy fields and a new driver interface Date: Tue, 26 May 2015 13:59:28 +0100 Message-ID: <55648A50020000780007DE83@mail.emea.novell.com> References: <1463125818-13779-1-git-send-email-wei.w.wang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1463125818-13779-1-git-send-email-wei.w.wang@intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Wang Cc: jinsong.liu@alibaba-inc.com, xen-devel@lists.xen.org, wei.liu2@citrix.com, ian.campbell@citrix.com, andrew.cooper3@citrix.com List-Id: xen-devel@lists.xenproject.org >>> On 13.05.16 at 09:50, wrote: > --- a/xen/drivers/cpufreq/utility.c > +++ b/xen/drivers/cpufreq/utility.c > @@ -456,6 +456,11 @@ int __cpufreq_set_policy(struct cpufreq_policy *data, > > data->min = policy->min; > data->max = policy->max; > + data->min_perf_pct = policy->min_perf_pct; > + data->max_perf_pct = policy->max_perf_pct; Shouldn't you do similar sanity checks on them as are being done on ->min and ->max? (Admittedly they look a little strange, but I'm not asking you to copy what is there without sanity checking the original). > + if (cpufreq_driver->setpolicy) Also I wonder whether the additions shouldn't move into this if()'s body. > --- a/xen/include/acpi/cpufreq/cpufreq.h > +++ b/xen/include/acpi/cpufreq/cpufreq.h > @@ -52,6 +52,10 @@ struct cpufreq_policy { > unsigned int max; /* in kHz */ > unsigned int cur; /* in kHz, only needed if cpufreq > * governors are used */ > + int min_perf_pct; /* min performance in percentage */ > + int max_perf_pct; /* max performance in percentage */ > + int turbo_pct; Can any of these legitimately be negative? If not, they should be of unsigned int type. > @@ -87,6 +91,12 @@ struct cpufreq_freqs { > * CPUFREQ GOVERNORS * > *********************************************************************/ > > +/* the four internal governors used in intel_pstate */ > +#define CPUFREQ_POLICY_POWERSAVE (1) > +#define CPUFREQ_POLICY_PERFORMANCE (2) > +#define CPUFREQ_POLICY_USERSPACE (3) > +#define CPUFREQ_POLICY_ONDEMAND (4) Why are they being added in this header and at this point in the sequence of patches? If they're local to intel_pstate, they should go there. If they're needed by multiple files, they should be added when needed, so that one can easily judge whether their addition is indeed necessary. Jan