x86/intel_pstate: the main boby of the intel_pstate driver
PATCH v2 6/9 x86/intel_pstate: the main boby of the intel_pstate driver
The intel_pstate driver is ported following its kernel code logic (commit: 93f0822d).
In the kernel, a user can adjust the limits via sysfs (limits.min_sysfs_pct/max_sysfs_pct). In Xen, the policy->min_perf_pct/max_perf_pct acts as the transit station. A user interacts with it via xenpm.
--- xen/arch/x86/acpi/cpufreq/Makefile | 1 + xen/arch/x86/acpi/cpufreq/intel_pstate.c | 852 +++++++++++++++++++++++++++++++ xen/include/acpi/cpufreq/cpufreq.h | 6 + xen/include/asm-x86/acpi.h | 2 + xen/include/asm-x86/cpufeature.h | 1 + xen/include/asm-x86/msr-index.h | 3 + 6 files changed, 865 insertions(+) create mode 100644 xen/arch/x86/acpi/cpufreq/intel_pstate.c
xen/arch/x86/acpi/cpufreq/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-y += cpufreq.o +obj-y += intel_pstate.o obj-y += powernow.o
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +852 -0
852 lines not on this page · raw message
xen/include/acpi/cpufreq/cpufreq.h +6 -0
@@ -34,6 +34,12 @@ struct acpi_cpufreq_data {extern struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS ]; +/* +* Maximum transition latency is in nanoseconds - if it's unknown, +* CPUFREQ_ETERNAL shall be used. +*/ +#define CPUFREQ_ETERNAL (-1) +struct cpufreq_cpuinfo {unsigned int max_freq;unsigned int second_max_freq;/* P1 if Turbo Mode is on */
xen/include/asm-x86/acpi.h +2 -0
@@ -32,6 +32,8 @@#define COMPILER_DEPENDENT_INT64 long long#define COMPILER_DEPENDENT_UINT64 unsigned long long +extern int intel_pstate_init (void ); +/* * Calling conventions: *
xen/include/asm-x86/cpufeature.h +1 -0
@@ -69,6 +69,7 @@#define X86_FEATURE_XTOPOLOGY (3*32+13)/* cpu topology enum extensions */ #define X86_FEATURE_CPUID_FAULTING (3*32+14)/* cpuid faulting */ #define X86_FEATURE_CLFLUSH_MONITOR (3*32+15)/* clflush reqd with monitor */ +#define X86_FEATURE_APERFMPERF (3*32+28)/* APERFMPERF */ /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ #define X86_FEATURE_XMM3 (4*32+ 0)/* Streaming SIMD Extensions-3 */
xen/include/asm-x86/msr-index.h +3 -0
@@ -52,6 +52,8 @@#define MSR_IA32_MCG_STATUS 0x0000017a#define MSR_IA32_MCG_CTL 0x0000017b +#define MSR_NHM_TURBO_RATIO_LIMIT 0x000001ad +#define MSR_IA32_PEBS_ENABLE 0x000003f1#define MSR_IA32_DS_AREA 0x00000600#define MSR_IA32_PERF_CAPABILITIES 0x00000345
@@ -319,6 +321,7 @@#define MSR_IA32_MISC_ENABLE_MONITOR_ENABLE (1<<18)#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1<<22)#define MSR_IA32_MISC_ENABLE_XTPR_DISABLE (1<<23) +#define MSR_IA32_MISC_ENABLE_TURBO_DISABLE (1ULL<<38)#define MSR_IA32_TSC_DEADLINE 0x000006E0#define MSR_IA32_ENERGY_PERF_BIAS 0x000001b0
Signature · 1 line
1.9.1
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 34
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +3
-0+static inline int ceiling_fp (int32_t x) +{ +int mask, ret;
Please here and below, consider whether types really need to be signed. One exception: If you intend to import the Linux source file with minimal modifications, and if that indeed results in only very few differences, then keeping the types as they are is probably fine. But in that case you should extend the patch description to say that the goal is to have minimal changes. All comments below are to be taken with the possible minimal change goal in mind.
Quoted 23 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +23
-0+static int byt_get_min_pstate (void ) +{ +u64 value; + +rdmsrl (BYT_RATIOS , value); +return (value >>8 ) &0x7F ; +} + +static int byt_get_max_pstate (void ) +{ +u64 value; + +rdmsrl (BYT_RATIOS , value); +return (value >>16 ) &0x7F ; +} + +static int byt_get_turbo_pstate (void ) +{ +u64 value; + +rdmsrl (BYT_TURBO_RATIOS , value); +return value &0x7F ; +}
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 264
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+ +static void byt_set_pstate (struct cpudata *cpudata,int pstate) +{ +u64 val; +int32_t vid_fp; +u32 vid; + + val = pstate <<8 ; +if (limits.no_turbo && !limits.turbo_disabled) + val |= (u64 )1 <<32 ;
All of the literal numbers above (and there are more further down) would better become self-documenting manifest constants.
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 282
Quoted 2 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +2
-0+#define BYT_BCLK_FREQS 5 +static int byt_freq_table[BYT_BCLK_FREQS ] = {833 ,1000 ,1333 ,1167 ,800 };
This can be both const and local to the only function it's being used by.
Quoted 1 line
+static struct
cpu_defaultscore_params= {
const? __initconst?
Quoted 1 line
+static struct
cpu_defaultsbyt_params= {
Same here.
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 556
Quoted 3 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +3
-0+static void intel_pstate_timer_func (void *__data) +{ +struct cpudata *cpu = (struct cpudata *) __data;
Double underscores are completely unnecessary here.
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 569
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+#define ICPU (model, policy) \ + { X86_VENDOR_INTEL, 6, model, X86_FEATURE_APERFMPERF,\ + (unsigned long)&policy } + +static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
__initconst
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+ICPU (0x2a , core_params), +ICPU (0x2d , core_params), +ICPU (0x37 , byt_params), +ICPU (0x3a , core_params), + ICPU(0x3c, core_params),
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 584
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+ICPU (0x3d , core_params), +ICPU (0x3e , core_params), +ICPU (0x3f , core_params), +ICPU (0x45 , core_params), +ICPU (0x46 , core_params), +ICPU (0x47 , core_params), +ICPU (0x4c , byt_params), +ICPU (0x4e , core_params), +ICPU (0x4f , core_params), + ICPU(0x56, core_params),
Please handle the _params name tag inside ICPU().
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 619
Quoted 6 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +6
-0+static int intel_pstate_set_policy (struct cpufreq_policy *policy) +{ +if (!policy->cpuinfo.max_freq) +return -ENODEV ; + +if (policy->policy ==CPUFREQ_POLICY_PERFORMANCE ) {
switch(policy->policy) please.
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 627
Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +8
-0+ limits.no_turbo =0 ; + limits.max_perf_pct =100 ; + limits.max_perf =int_tofp (1 ); + limits.min_perf_pct =100 ; + limits.min_perf =int_tofp (1 ); + policy->max_perf_pct =100 ; + policy->min_perf_pct =100 ; +return 0 ;
And no need for identical return statement in all four branches.
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 638
Quoted 3 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +3
-0+ }else if (policy->policy ==CPUFREQ_POLICY_USERSPACE ) { + limits.max_perf_pct =max (limits.min_policy_pct, policy->max_perf_pct); + limits.max_perf_pct =min (limits.max_policy_pct, limits.max_perf_pct);
Why are you not using clamp() here?
Quoted 1 line
+ } else {
This should at least have a comment saying CPUFREQ_POLICY_ONDEMAND.
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 664
Quoted 9 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +9
-0+static int intel_pstate_verify_policy (struct cpufreq_policy *policy) +{ +cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, + policy->cpuinfo.max_freq); + +if ( policy->policy !=CPUFREQ_POLICY_POWERSAVE && + policy->policy !=CPUFREQ_POLICY_PERFORMANCE && + policy->policy !=CPUFREQ_POLICY_USERSPACE && + policy->policy !=CPUFREQ_POLICY_ONDEMAND )
switch()
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 726
Quoted 6 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +6
-0+static int intel_pstate_cpu_init (struct cpufreq_policy *policy) +{ +struct cpudata *cpu; +int rc; + + rc =intel_pstate_init_cpu (policy->cpu);
Having both intel_pstate_cpu_init() and intel_pstate_init_cpu() is at least odd, the more that the latter is being called from only here.
Quoted 14 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +14
-0+if (rc) +return rc; + + cpu = all_cpu_data[policy->cpu]; +if (limits.min_perf_pct ==100 && limits.max_perf_pct ==100 ) + policy->policy =CPUFREQ_POLICY_PERFORMANCE ; +else + policy->policy =CPUFREQ_POLICY_ONDEMAND ; + + policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling; + policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling; + policy->min_perf_pct =0 ; + policy->max_perf_pct =100 ; + policy->turbo_pct =get_turbo_pct ();
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 750
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+ +/* cpuinfo and default policy values */ + policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; + policy->cpuinfo.max_freq = + cpu->pstate.turbo_pstate * cpu->pstate.scaling; + policy->cpuinfo.transition_latency =CPUFREQ_ETERNAL ; +cpumask_set_cpu (policy->cpu, policy->cpus); + +/* the first cpu do the init work for limits.min/max_policy_pct */ +if (cpu->cpu ==0 ) {
cpu->cpu == 0 doesn't mean this is the first CPU to come here.
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+static int intel_pstate_msrs_not_valid (void ) +{ +/* Check that all the msr's we are using are valid. */ +u64 aperf, mperf, tmp; +
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 783
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+rdmsrl (MSR_IA32_APERF , aperf); +rdmsrl (MSR_IA32_MPERF , mperf); + +if (!pstate_funcs.get_max () || + !pstate_funcs.get_min () || + !pstate_funcs.get_turbo ()) +return -ENODEV ; + +rdmsrl (MSR_IA32_APERF , tmp); +if (!(tmp - aperf))
Why not "if(tmp == aperf)"? And - is it guaranteed that APERF (and MPERF below) incremented in the meantime?
Quoted 1 line
+static void
copy_pid_params(struct pstate_adjust_policy *policy)
__init
Quoted 1 line
+static void
copy_cpu_funcs(struct pstate_funcs *funcs)
Again.
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 820
Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +8
-0+int __init intel_pstate_init (void ) +{ +int cpu, rc =0 ; +const struct x86_cpu_id *id; +struct cpu_defaults *cpu_info; + +if (cpuid_ecx (6 ) &0x1 ) +set_bit (X86_FEATURE_APERFMPERF , &boot_cpu_data.x86_capability);
This should be consolidated out of the other cpufreq drivers into cpu/common.c.
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 834
Quoted 13 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +13
-0+ + id =x86_match_cpu (intel_pstate_cpu_ids); +if (!id) +return -ENODEV ; + + cpu_info = (struct cpu_defaults *)id->driver_data; + +copy_pid_params (&cpu_info->pid_policy); +copy_cpu_funcs (&cpu_info->funcs); +if (intel_pstate_msrs_not_valid ()) +return -ENODEV ; + + all_cpu_data = xzalloc_array(struct cpudata *, num_online_cpus());
This looks suspicious considering CPU hotplug, the more that this is the only place it gets allocated.
Also please get this file formatted properly - either in Linux style or in Xen style, but not an arbitrary mixture of both.
xen/include/asm-x86/acpi.h line 35
Quoted 7 lines
xen/include/asm-x86/acpi.h +1
-0@@ -32,6 +32,8 @@#define COMPILER_DEPENDENT_INT64 long long#define COMPILER_DEPENDENT_UINT64 unsigned long long +extern int intel_pstate_init (void );
Why in acpi.h?
Jan
On 26/05/2015 21:58, Jan Beulich wrote
Quoted 123 lines
Review
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
(quoted diff) +2
-0+static inline int ceiling_fp(int32_t x) { + int mask, ret;Please here and below, consider whether types really need to be signed. One exception: If you intend to import the Linux source file with minimal modifications, and if that indeed results in only very few differences, then keeping the types as they are is probably fine. But in that case you should extend the patch description to say that the goal is to have minimal changes. All comments below are to be taken with the possible minimal change goal in mind.
Quoted 21 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +21
-0+static int byt_get_min_pstate (void ) +{ +u64 value; + +rdmsrl (BYT_RATIOS , value); +return (value >>8 ) &0x7F ; +} + +static int byt_get_max_pstate (void ) +{ +u64 value; + +rdmsrl (BYT_RATIOS , value); +return (value >>16 ) &0x7F ; +} + +static int byt_get_turbo_pstate (void ) { +u64 value; + +rdmsrl (BYT_TURBO_RATIOS , value); +return value &0x7F ;xen/arch/x86/acpi/cpufreq/intel_pstate.c line 264
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+} + +static void byt_set_pstate (struct cpudata *cpudata,int pstate) { +u64 val; +int32_t vid_fp; +u32 vid; + + val = pstate <<8 ; +if (limits.no_turbo && !limits.turbo_disabled) + val |= (u64 )1 <<32 ;All of the literal numbers above (and there are more further down) would better become self-documenting manifest constants.
Review
Quoted 3 lines
(quoted diff) +3
-0+#define BYT_BCLK_FREQS 5 +static int byt_freq_table[BYT_BCLK_FREQS] = { 833, 1000, 1333, 1167, +800};This can be both const and local to the only function it's being used by.
Quoted 1 line
+static struct
cpu_defaultscore_params= {const?
__initconst?Quoted 1 line
+static struct
cpu_defaultsbyt_params= {Same here.
Review
Quoted 2 lines
(quoted diff) +2
-0+static void intel_pstate_timer_func(void *__data) { + struct cpudata *cpu = (struct cpudata *) __data;Double underscores are completely unnecessary here.
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 569
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+#define ICPU (model, policy) \ + { X86_VENDOR_INTEL, 6, model, X86_FEATURE_APERFMPERF,\ + (unsigned long)&policy } + +static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
__initconstQuoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+ICPU (0x2a , core_params), +ICPU (0x2d , core_params), +ICPU (0x37 , byt_params), +ICPU (0x3a , core_params), + ICPU(0x3c, core_params),xen/arch/x86/acpi/cpufreq/intel_pstate.c line 584
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+ICPU (0x3d , core_params), +ICPU (0x3e , core_params), +ICPU (0x3f , core_params), +ICPU (0x45 , core_params), +ICPU (0x46 , core_params), +ICPU (0x47 , core_params), +ICPU (0x4c , byt_params), +ICPU (0x4e , core_params), +ICPU (0x4f , core_params), + ICPU(0x56, core_params),Please handle the
_paramsname tag insideICPU().xen/arch/x86/acpi/cpufreq/intel_pstate.c line 619
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+static int intel_pstate_set_policy (struct cpufreq_policy *policy) { +if (!policy->cpuinfo.max_freq) +return -ENODEV ; + +if (policy->policy ==CPUFREQ_POLICY_PERFORMANCE ) {
switch(policy->policy)please.xen/arch/x86/acpi/cpufreq/intel_pstate.c line 627
Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +8
-0+ limits.no_turbo =0 ; + limits.max_perf_pct =100 ; + limits.max_perf =int_tofp (1 ); + limits.min_perf_pct =100 ; + limits.min_perf =int_tofp (1 ); + policy->max_perf_pct =100 ; + policy->min_perf_pct =100 ; +return 0 ;And no need for identical return statement in all four branches.
Quoted 5 lines
(quoted diff) +2
-0+ } else if (policy->policy == CPUFREQ_POLICY_USERSPACE) { + limits.max_perf_pct = max(limits.min_policy_pct, policy-
max_perf_pct);
+ limits.max_perf_pct = min(limits.max_policy_pct,
+ limits.max_perf_pct);Why are you not using
clamp()here?Quoted 1 line
+ } else {
This should at least have a comment saying
CPUFREQ_POLICY_ONDEMAND.
Quoted 11 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 664
Quoted 9 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +9
-0+static int intel_pstate_verify_policy (struct cpufreq_policy *policy) +{ +cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, + policy->cpuinfo.max_freq); + +if ( policy->policy !=CPUFREQ_POLICY_POWERSAVE && + policy->policy !=CPUFREQ_POLICY_PERFORMANCE && + policy->policy !=CPUFREQ_POLICY_USERSPACE && + policy->policy !=CPUFREQ_POLICY_ONDEMAND )
switch()
How would we use switch() here?
Quoted 9 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 726
Quoted 6 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+static int intel_pstate_cpu_init (struct cpufreq_policy *policy) { +struct cpudata *cpu; +int rc; + + rc =intel_pstate_init_cpu (policy->cpu);Having both
intel_pstate_cpu_init()andintel_pstate_init_cpu()is at least odd, the more that the latter is being called from only here.
Are you suggesting to change the function name? If so, how about changing intel_pstate_cpu_init() to intel_pstate_setup()?
Quoted 20 lines
Quoted 20 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +17
-0+if (rc) +return rc; + + cpu = all_cpu_data[policy->cpu]; +if (limits.min_perf_pct ==100 && limits.max_perf_pct ==100 ) + policy->policy =CPUFREQ_POLICY_PERFORMANCE ; +else + policy->policy =CPUFREQ_POLICY_ONDEMAND ; + + policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling; + policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling; + policy->min_perf_pct =0 ; + policy->max_perf_pct =100 ; + policy->turbo_pct =get_turbo_pct (); + +/* cpuinfo and default policy values */ + policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu-pstate.scaling;
+policy->cpuinfo.max_freq=
Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 750
Quoted 6 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +6
-0+ cpu->pstate.turbo_pstate * cpu->pstate.scaling; + policy->cpuinfo.transition_latency =CPUFREQ_ETERNAL ; +cpumask_set_cpu (policy->cpu, policy->cpus); + +/* the first cpu do the init work for limits.min/max_policy_pct */ +if (cpu->cpu ==0 ) {
cpu->cpu== 0 doesn't mean this is the first CPU to come here.
How about this one:
If (limits.min_policy_pct == 0) {
limits.min_policy_pct = ....
limits.xx = ....
}limits.min_policy_pct won't be 0 if it is initialized.
Quoted 9 lines
Quoted 9 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +9
-0+static int intel_pstate_msrs_not_valid (void ) { +/* Check that all the msr's we are using are valid. */ +u64 aperf, mperf, tmp; + +rdmsrl (MSR_IA32_APERF , aperf); +rdmsrl (MSR_IA32_MPERF , mperf); + + if (!pstate_funcs.get_max() || + !pstate_funcs.get_min() ||
Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 783
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+ !pstate_funcs.get_turbo()) +return -ENODEV ; + +rdmsrl (MSR_IA32_APERF , tmp); +if (!(tmp - aperf))Why not "if(tmp == aperf)"? And - is it guaranteed that APERF (and MPERF below) incremented in the meantime?
Will change it to "if (tmp == aperf)".
According to the SDM, IA32_MPERF MSR (E7H) increments in proportion to a fixed frequency, and IA32_APERF MSR increments in proportion to actual performance. So, as long as the two MSRs are valid, their values will be increased.
Quoted 9 lines
Quoted 2 lines
+static void
copy_pid_params(struct pstate_adjust_policy *policy)
__initQuoted 1 line
+static void
copy_cpu_funcs(struct pstate_funcs *funcs)Again.
Quoted 12 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c
Quoted 9 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +9
-0+int __init intel_pstate_init (void ) +{ +int cpu, rc =0 ; +const struct x86_cpu_id *id; +struct cpu_defaults *cpu_info; + +if (cpuid_ecx (6 ) &0x1 ) +set_bit (X86_FEATURE_APERFMPERF , + &boot_cpu_data.x86_capability);This should be consolidated out of the other cpufreq drivers into
cpu/common.c.
How about moving it to the bottom of init_intel() in cpu/intel.c ?
Quoted 10 lines
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +9
-0+ + id =x86_match_cpu (intel_pstate_cpu_ids); +if (!id) +return -ENODEV ; + + cpu_info = (struct cpu_defaults *)id->driver_data; + +copy_pid_params (&cpu_info->pid_policy); +copy_cpu_funcs (&cpu_info->funcs);
Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+if (intel_pstate_msrs_not_valid ()) +return -ENODEV ; + + all_cpu_data = xzalloc_array(struct cpudata *, +num_online_cpus ());This looks suspicious considering CPU hotplug, the more that this is the only place it gets allocated.
Will change it to " all_cpu_data = xzalloc_array(struct cpudata *, num_possible_cpus())"
Quoted 10 lines
Also please get this file formatted properly - either in Linux style or in Xen style, but not an arbitrary mixture of both.
Quoted 6 lines
xen/include/asm-x86/acpi.h +0
-0@@ -32,6 +32,8 @@#define COMPILER_DEPENDENT_INT64 long long#define COMPILER_DEPENDENT_UINT64 unsigned long long
Quoted 3 lines
xen/include/asm-x86/acpi.h line 35
Quoted 1 line
xen/include/asm-x86/acpi.h +1
-0+extern int intel_pstate_init (void );Why in
acpi.h?
I was thinking that p-state is part of ACPI. Do you prefer to create a new .h called cpufreq.h, just like the cpuidle.h there?
Best,
Wei
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 29.05.15 at 10:19, <[email protected]> wrote:
On 26/05/2015 21:58, Jan Beulich wrote
Quoted 12 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 664
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +9
-0+static int intel_pstate_verify_policy (struct cpufreq_policy *policy) +{ +cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, + policy->cpuinfo.max_freq); + +if ( policy->policy !=CPUFREQ_POLICY_POWERSAVE && + policy->policy !=CPUFREQ_POLICY_PERFORMANCE && + policy->policy !=CPUFREQ_POLICY_USERSPACE && + policy->policy !=CPUFREQ_POLICY_ONDEMAND )
switch()
Quoted 1 line
How would we use
switch()here?
switch ( policy->policy )
{
case CPUFREQ_POLICY_POWERSAVE:etc. But I thought that to be obvious, so I'm not sure I understand what you don't understand.
Quoted 11 lines
Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 726
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+static int intel_pstate_cpu_init (struct cpufreq_policy *policy) { +struct cpudata *cpu; +int rc; + + rc =intel_pstate_init_cpu (policy->cpu);Having both
intel_pstate_cpu_init()andintel_pstate_init_cpu()is at least odd, the more that the latter is being called from only here.Are you suggesting to change the function name? If so, how about changing
intel_pstate_cpu_init()tointel_pstate_setup()?
Either that, or fold the called function into the caller.
Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +17
-0+if (rc) +return rc; + + cpu = all_cpu_data[policy->cpu]; +if (limits.min_perf_pct ==100 && limits.max_perf_pct ==100 ) + policy->policy =CPUFREQ_POLICY_PERFORMANCE ; +else + policy->policy =CPUFREQ_POLICY_ONDEMAND ; + + policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling; + policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling; + policy->min_perf_pct =0 ; + policy->max_perf_pct =100 ; + policy->turbo_pct =get_turbo_pct (); + +/* cpuinfo and default policy values */ + policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu-pstate.scaling;
+policy->cpuinfo.max_freq=Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 750
Quoted 6 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +6
-0+ cpu->pstate.turbo_pstate * cpu->pstate.scaling; + policy->cpuinfo.transition_latency =CPUFREQ_ETERNAL ; +cpumask_set_cpu (policy->cpu, policy->cpus); + +/* the first cpu do the init work for limits.min/max_policy_pct */ +if (cpu->cpu ==0 ) {
cpu->cpu== 0 doesn't mean this is the first CPU to come here.
Quoted 8 lines
How about this one:
If (limits.min_policy_pct == 0) { limits.min_policy_pct = .... limits.xx = .... }limits.min_policy_pct won't be 0 if it is initialized.
If that's guaranteed - fine with me.
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +9
-0+static int intel_pstate_msrs_not_valid (void ) { +/* Check that all the msr's we are using are valid. */ +u64 aperf, mperf, tmp; + +rdmsrl (MSR_IA32_APERF , aperf); +rdmsrl (MSR_IA32_MPERF , mperf); + + if (!pstate_funcs.get_max() || + !pstate_funcs.get_min() ||Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 783
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+ !pstate_funcs.get_turbo()) +return -ENODEV ; + +rdmsrl (MSR_IA32_APERF , tmp); +if (!(tmp - aperf))Why not "if(tmp == aperf)"? And - is it guaranteed that APERF (and MPERF below) incremented in the meantime?
Quoted 5 lines
Will change it to "if (tmp == aperf)".
According to the SDM,IA32_MPERFMSR (E7H) increments in proportion to a fixed frequency, andIA32_APERFMSR increments in proportion to actual performance. So, as long as the two MSRs are valid, their values will be increased.
The "in proportion" is what makes me nervous: What if the proportion is 1 in every 1000 cycles?
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +4
-0+int __init intel_pstate_init (void ) +{ +int cpu, rc =0 ; +const struct x86_cpu_id *id;Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+struct cpu_defaults *cpu_info; + +if (cpuid_ecx (6 ) &0x1 ) +set_bit (X86_FEATURE_APERFMPERF , + &boot_cpu_data.x86_capability);This should be consolidated out of the other cpufreq drivers into
cpu/common.c.
Quoted 1 line
How about moving it to the bottom of
init_intel()incpu/intel.c?
It's not Intel specific, so it belongs in cpu/common.c.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
xen/include/asm-x86/acpi.h +0
-0@@ -32,6 +32,8 @@#define COMPILER_DEPENDENT_INT64 long long#define COMPILER_DEPENDENT_UINT64 unsigned long long
Quoted 6 lines
Quoted 3 lines
xen/include/asm-x86/acpi.h line 35
Quoted 1 line
xen/include/asm-x86/acpi.h +1
-0+extern int intel_pstate_init (void );Why in
acpi.h?I was thinking that p-state is part of ACPI. Do you prefer to create a new .h called
cpufreq.h, just like thecpuidle.hthere?
ACPI is a way to convey information about P- (and C- and T-) states, but the latter are imo not tied to ACPI. In fact your patch series here proves the opposite: You add code dealing with P-states without using information coming from ACPI. I think this should go into what currently is acpi/cpufreq/cpufreq.h, which is expected to be moved out of acpi/ anyway (I seem to even recall an ARM side series aiming at doing that).
Jan
On 29/05/2015 16:46, Jan Beulich wrote
Quoted 15 lines
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 29.05.15 at 10:19, <[email protected]> wrote:
On 26/05/2015 21:58, Jan Beulich wrote
Quoted 12 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 664
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +9
-0+static int intel_pstate_verify_policy (struct cpufreq_policy +*policy) { +cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, + policy->cpuinfo.max_freq); + +if ( policy->policy !=CPUFREQ_POLICY_POWERSAVE && + policy->policy !=CPUFREQ_POLICY_PERFORMANCE && + policy->policy !=CPUFREQ_POLICY_USERSPACE && + policy->policy !=CPUFREQ_POLICY_ONDEMAND )
switch()
Quoted 8 lines
Quoted 1 line
How would we use
switch()here?switch ( policy->policy ) { case CPUFREQ_POLICY_POWERSAVE:etc. But I thought that to be obvious, so I'm not sure I understand what you don't understand.
I thought there would be a special usage of switch() here, but no. So, using switch, we will have
switch ( policy->policy )
{
case CPUFREQ_POLICY_POWERSAVE:
case CPUFREQ_POLICY_PERFORMANCE:
case CPUFREQ_POLICY_USERSPACE:
case CPUFREQ_POLICY_ONDEMAND:
return 0;
case default:
return -EINVAL
}
Is there a particular reason why we need to change to this style? I think using if() looks more straightforward, since this is just a condition check.
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +4
-0+static int intel_pstate_msrs_not_valid (void ) { +/* Check that all the msr's we are using are valid. */ +u64 aperf, mperf, tmp; +xen/arch/x86/acpi/cpufreq/intel_pstate.c line 783
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+rdmsrl (MSR_IA32_APERF , aperf); +rdmsrl (MSR_IA32_MPERF , mperf); + +if (!pstate_funcs.get_max () || + !pstate_funcs.get_min () || + !pstate_funcs.get_turbo ()) +return -ENODEV ; + +rdmsrl (MSR_IA32_APERF , tmp); +if (!(tmp - aperf))Why not "if(tmp == aperf)"? And - is it guaranteed that APERF (and MPERF
below) incremented in the meantime?
Quoted 8 lines
Quoted 5 lines
Will change it to "if (tmp == aperf)".
According to the SDM,IA32_MPERFMSR (E7H) increments in proportion to a fixed frequency, andIA32_APERFMSR increments in proportion to actual performance. So, as long as the two MSRs are valid, their values will be increased.The "in proportion" is what makes me nervous: What if the proportion is 1 in every 1000 cycles?
Right, this may cause a problem. I will remove that part. Then, it will be:
static int intel_pstate_msrs_not_valid(void)
{
if ( !pstate_funcs.get_max() ||
!pstate_funcs.get_min() ||
!pstate_funcs.get_turbo())
return -ENODEV;
return 0;
}Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c
Quoted 9 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +8
-0+int __init intel_pstate_init (void ) { +int cpu, rc =0 ; +const struct x86_cpu_id *id; +struct cpu_defaults *cpu_info; + +if (cpuid_ecx (6 ) &0x1 ) +set_bit (X86_FEATURE_APERFMPERF , + &boot_cpu_data.x86_capability);This should be consolidated out of the other cpufreq drivers into
cpu/common.c.
Quoted 3 lines
Quoted 1 line
How about moving it to the bottom of
init_intel()incpu/intel.c?It's not Intel specific, so it belongs in
cpu/common.c.
Ok, I will put it into the cpu_init() function there.
Quoted 14 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
xen/include/asm-x86/acpi.h +0
-0@@ -32,6 +32,8 @@#define COMPILER_DEPENDENT_INT64 long long#define COMPILER_DEPENDENT_UINT64 unsigned long longQuoted 6 lines
Quoted 3 lines
xen/include/asm-x86/acpi.h line 35
Quoted 1 line
xen/include/asm-x86/acpi.h +1
-0+extern int intel_pstate_init (void );Why in
acpi.h?I was thinking that p-state is part of ACPI. Do you prefer to create a new .h called
cpufreq.h, just like thecpuidle.hthere?
Quoted 6 lines
ACPI is a way to convey information about P- (and C- and T-) states, but the latter are imo not tied to ACPI. In fact your patch series here proves the
opposite: You add code dealing with P-states without using information coming from ACPI. I think this should go into what currently isacpi/cpufreq/cpufreq.h, which is expected to be moved out of acpi/ anyway (I seem to even recall an ARM side series aiming at doing that).
Ok, I will move it back to acpi/cpufreq/cpufreq.h.
Best,
Wei
Quoted 39 lines
Quoted 1 line
Quoted 1 line · On 01.06.15 at 11:12, <[email protected]> wrote:
On 29/05/2015 16:46, Jan Beulich wrote
Quoted 15 lines
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 29.05.15 at 10:19, <[email protected]> wrote:
On 26/05/2015 21:58, Jan Beulich wrote
Quoted 12 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 664
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +9
-0+static int intel_pstate_verify_policy (struct cpufreq_policy +*policy) { +cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, + policy->cpuinfo.max_freq); + +if ( policy->policy !=CPUFREQ_POLICY_POWERSAVE && + policy->policy !=CPUFREQ_POLICY_PERFORMANCE && + policy->policy !=CPUFREQ_POLICY_USERSPACE && + policy->policy !=CPUFREQ_POLICY_ONDEMAND )
switch()Quoted 8 lines
Quoted 1 line
How would we use
switch()here?switch ( policy->policy ) { case CPUFREQ_POLICY_POWERSAVE:etc. But I thought that to be obvious, so I'm not sure I understand what you don't understand.
I thought there would be a special usage of
switch()here, but no. So, using switch, we will have
switch (policy->policy){ case CPUFREQ_POLICY_POWERSAVE: case CPUFREQ_POLICY_PERFORMANCE: case CPUFREQ_POLICY_USERSPACE: case CPUFREQ_POLICY_ONDEMAND: return 0; case default: return -EINVAL }
Quoted 2 lines
Is there a particular reason why we need to change to this style? I think using
if()looks more straightforward, since this is just a condition check.
Well, a good compiler will avoid fetching policy->policy anyway at least when optimizing, but I consider it good practice to guide the compiler in the right direction (including non-optimized builds).
Jan
On 26/05/2015 21:58, Jan Beulich wrote
Quoted 17 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +3
-0+ id =x86_match_cpu (intel_pstate_cpu_ids); +if (!id) +return -ENODEV ;xen/arch/x86/acpi/cpufreq/intel_pstate.c
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+ + cpu_info = (struct cpu_defaults *)id->driver_data; + +copy_pid_params (&cpu_info->pid_policy); +copy_cpu_funcs (&cpu_info->funcs); +if (intel_pstate_msrs_not_valid ()) +return -ENODEV ; + + all_cpu_data = xzalloc_array(struct cpudata *, +num_online_cpus ());This looks suspicious considering CPU hotplug, the more that this is the only place it gets allocated.
I just found that "num_possible_cpus()" is currently not usable for the x86 code. Can we use the Xen supported max possible CPUs - NR_CPUS (usually it's 256), i.e. all_cpu_data = xzalloc_array(struct cpudata *, NR_CPUS) ? Since each entry is just a pointer, this won't waste too much memory.
Best,
Wei
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 02.06.15 at 05:23, <[email protected]> wrote:
On 26/05/2015 21:58, Jan Beulich wrote
Quoted 17 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +3
-0+ id =x86_match_cpu (intel_pstate_cpu_ids); +if (!id) +return -ENODEV ;xen/arch/x86/acpi/cpufreq/intel_pstate.c
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+ + cpu_info = (struct cpu_defaults *)id->driver_data; + +copy_pid_params (&cpu_info->pid_policy); +copy_cpu_funcs (&cpu_info->funcs); +if (intel_pstate_msrs_not_valid ()) +return -ENODEV ; + + all_cpu_data = xzalloc_array(struct cpudata *, +num_online_cpus ());This looks suspicious considering CPU hotplug, the more that this is the only place it gets allocated.
Quoted 4 lines
I just found that "
num_possible_cpus()" is currently not usable for the x86 code. Can we use the Xen supported max possible CPUs -NR_CPUS(usually it's 256), i.e.all_cpu_data=xzalloc_array(struct cpudata *, NR_CPUS)? Since each entry is just a pointer, this won't waste too much memory.
If anything it would be nr_cpu_ids that you'd want to use here. (And no, assuming NR_CPUS to "usually" be 256 is wrong - this is merely the default, no more and no less).
Jan
On 26/05/2015 21:58, Jan Beulich wrote
Quoted 27 lines
Quoted 27 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +26
-0+static int byt_get_min_pstate (void ) +{ +u64 value; + +rdmsrl (BYT_RATIOS , value); +return (value >>8 ) &0x7F ; +} + +static int byt_get_max_pstate (void ) +{ +u64 value; + +rdmsrl (BYT_RATIOS , value); +return (value >>16 ) &0x7F ; +} + +static int byt_get_turbo_pstate (void ) { +u64 value; + +rdmsrl (BYT_TURBO_RATIOS , value); +return value &0x7F ; +} + +static void byt_set_pstate (struct cpudata *cpudata,int pstate) { +u64 val; +int32_t vid_fp;
Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 264
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+u32 vid; + + val = pstate <<8 ; +if (limits.no_turbo && !limits.turbo_disabled) + val |= (u64 )1 <<32 ;All of the literal numbers above (and there are more further down) would better become self-documenting manifest constants.
I just realized that it would be better to remove these bay trail platform related code. What do you think?
Best,
Wei
Quoted 38 lines
Quoted 1 line
Quoted 1 line · On 08.06.15 at 03:47, <[email protected]> wrote:
On 26/05/2015 21:58, Jan Beulich wrote
Quoted 27 lines
Quoted 27 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +26
-0+static int byt_get_min_pstate (void ) +{ +u64 value; + +rdmsrl (BYT_RATIOS , value); +return (value >>8 ) &0x7F ; +} + +static int byt_get_max_pstate (void ) +{ +u64 value; + +rdmsrl (BYT_RATIOS , value); +return (value >>16 ) &0x7F ; +} + +static int byt_get_turbo_pstate (void ) { +u64 value; + +rdmsrl (BYT_TURBO_RATIOS , value); +return value &0x7F ; +} + +static void byt_set_pstate (struct cpudata *cpudata,int pstate) { +u64 val; +int32_t vid_fp;Quoted 8 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 264
Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +5
-0+u32 vid; + + val = pstate <<8 ; +if (limits.no_turbo && !limits.turbo_disabled) + val |= (u64 )1 <<32 ;All of the literal numbers above (and there are more further down) would better become self-documenting manifest constants.
Quoted 2 lines
I just realized that it would be better to remove these bay trail platform related code. What do you think?
First of all - why? Unless these are 32-bit only systems, I don't see why we wouldn't want to support Atoms at least on a best effort basis. And if you consider removal of code present in Linux, then this also needs to be done with the earlier mentioned "as little changes as possible compared to the Linux original" in mind.
Jan
Quoted 36 lines · Jan Beulich
Quoted 36 lines
Quoted 1 line
Quoted 1 line · On 08.06.15 at 03:47, <[email protected]> wrote:
On 26/05/2015 21:58, Jan Beulich wrote
Quoted 33 lines
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +19
-0+static int byt_get_min_pstate (void ) { +u64 value; + +rdmsrl (BYT_RATIOS , value); +return (value >>8 ) &0x7F ; +} + +static int byt_get_max_pstate (void ) { +u64 value; + +rdmsrl (BYT_RATIOS , value); +return (value >>16 ) &0x7F ; +} + +static int byt_get_turbo_pstate (void ) { +u64 value; + +rdmsrl (BYT_TURBO_RATIOS , value); +return value &0x7F ;xen/arch/x86/acpi/cpufreq/intel_pstate.c line 264
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+} + +static void byt_set_pstate (struct cpudata *cpudata,int pstate) { +u64 val; +int32_t vid_fp; +u32 vid; + + val = pstate <<8 ; +if (limits.no_turbo && !limits.turbo_disabled) + val |= (u64 )1 <<32 ;All of the literal numbers above (and there are more further down) would better become self-documenting manifest constants.
Quoted 8 lines
Quoted 2 lines
I just realized that it would be better to remove these bay trail platform related code. What do you think?
First of all - why? Unless these are 32-bit only systems, I don't see why we wouldn't want to support Atoms at least on a best effort basis. And if you consider removal of code present in Linux, then this also needs to be done with the earlier mentioned "as little changes as possible compared to the Linux original" in mind.
I don't have an objection to keeping it. Probably, some people are running Xen on tablets.
Regarding the self-documenting related comment here, which of the following do you think is better?
1)
#define BYT_MIN_PSTATE_SHIFT 8
#define BYT_MAX_PSTATE_SHIFT 16
#define BYT_PSTATE_MASK 0x7f
#define BYT_TURBO_CONTROL_BIT 32
2)
#define BYT_MIN_PSTATE(value) (((value) >> 8) & 0x7F)
#define BYT_MAX_PSTATE(value) (((value) >> 16) & 0x7F)
#define BYT_SET_TURBO_CONTROL_BIT(value) ((val) |= (u64)1 << 32)
Best,
Wei
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 08.06.15 at 10:18, <[email protected]> wrote:
Regarding the self-documenting related comment here, which of the following do you think is better?
1)
#defineBYT_MIN_PSTATE_SHIFT8
#defineBYT_MAX_PSTATE_SHIFT16
#defineBYT_PSTATE_MASK0x7f
#defineBYT_TURBO_CONTROL_BIT32
Quoted 4 lines
2)
#defineBYT_MIN_PSTATE(value)(((value) >> 8) &0x7F)
#defineBYT_MAX_PSTATE(value)(((value) >> 16) &0x7F)
#defineBYT_SET_TURBO_CONTROL_BIT(value)((val) |= (u64)1 << 32)
I think the first two of 2) and the fourth one of 1) are the best combination, but I'd really leave it up to you (with, if using it, the val vs value issue fixed in the last one).
Jan
On 26/05/2015 21:58, Jan Beulich wrote
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 627
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +9
-0+if (policy->policy ==CPUFREQ_POLICY_PERFORMANCE ) { + limits.no_turbo =0 ; + limits.max_perf_pct =100 ; + limits.max_perf =int_tofp (1 ); + limits.min_perf_pct =100 ; + limits.min_perf =int_tofp (1 ); + policy->max_perf_pct =100 ; + policy->min_perf_pct =100 ; +return 0 ;
Hi Jan,
I noticed another issue. The intel_pstate driver originally manages all the CPUs using the global "limit" structure (e.g. if one CPU is set to be in the Performance mode, min_perf=max_perf , then all the CPUs will run in the Performance mode). This will generate confusing status info to users in our case. For example, if we set CPU0 in Powersave, then set CPU1 in Performance. We will see CPU0 in the Powersave mode, but it's actually running in the Performance mode.
How do you think if we move the global "limit" structure to the per-cpu policy structure, so that each CPU can be configured individually?
Best,
Wei
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 10.06.15 at 07:20, <[email protected]> wrote:
On 26/05/2015 21:58, Jan Beulich wrote
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 627
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +9
-0+if (policy->policy ==CPUFREQ_POLICY_PERFORMANCE ) { + limits.no_turbo =0 ; + limits.max_perf_pct =100 ; + limits.max_perf =int_tofp (1 ); + limits.min_perf_pct =100 ; + limits.min_perf =int_tofp (1 ); + policy->max_perf_pct =100 ; + policy->min_perf_pct =100 ; +return 0 ;I noticed another issue. The
intel_pstatedriver originally manages all the CPUs using the global "limit" structure (e.g. if one CPU is set to be in the Performance mode, min_perf=max_perf , then all the CPUs will run in the Performance mode). This will generate confusing status info to users in our case. For example, if we set CPU0 in Powersave, then set CPU1 in Performance. We will see CPU0 in the Powersave mode, but it's actually running in the Performance mode.
Quoted 2 lines
How do you think if we move the global "limit" structure to the per-cpu policy structure, so that each CPU can be configured individually?
Sounds reasonable; I don't recall having asked for that structure to be global...
Jan