x86/intel_pstate: the main boby of the intel_pstate driver
PATCH v4 7/11 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 order to port the Linux source file with minimal modifications, some of the variable types are kept intact (e.g. "int current_pstae", would otherwise be changed to "unsigned int").
In the kernel, a user can adjust the limits via sysfs (limits.min_sysfs_pct/max_sysfs_pct). In Xen, the policy->limits.min_perf_pct/max_perf_pct acts as the transit station. A user interacts with it via xenpm.
The new xen/include/asm-x86/cpufreq.h header file is added.
v4 changes:
1) changed the identation to be a "Tab" (same as Linux intel_pstate), instead of 4 "+$";
2) added a new header file, xen/include/asm-x86/cpufreq.h.
--- xen/arch/x86/acpi/cpufreq/Makefile | 1 + xen/arch/x86/acpi/cpufreq/intel_pstate.c | 870 +++++++++++++++++++++++++++++++ xen/include/asm-x86/cpufreq.h | 34 ++ xen/include/asm-x86/msr-index.h | 3 + 4 files changed, 908 insertions(+) create mode 100644 xen/arch/x86/acpi/cpufreq/intel_pstate.c create mode 100644 xen/include/asm-x86/cpufreq.h
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 +870 -0
870 lines not on this page · raw message
xen/include/asm-x86/cpufreq.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef _ASM_X86_CPUFREQ_H +#define _ASM_X86_CPUFREQ_H + +/* +* Copyright (C) 2015 Wei Wang <[email protected]> +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + +extern int intel_pstate_init (void ); + +/* +* Maximum transition latency is in nanoseconds - if it's unknown, +* CPUFREQ_ETERNAL shall be used. +*/ +#define CPUFREQ_ETERNAL (-1) + +#endif /* _ASM_X86_CPUFREQ_H */
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
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 25.06.15 at 13:16, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +24
-0+int __init intel_pstate_init (void ) +{ +int cpu, rc =0 ; +const struct x86_cpu_id *id; +struct cpu_defaults *cpu_info; + + 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 *, NR_CPUS); +if (!all_cpu_data) +return -ENOMEM ; + + rc =cpufreq_register_driver (&intel_pstate_driver); +if (rc)
xen/arch/x86/acpi/cpufreq/intel_pstate.c line 867
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+ goto out; + +return rc; +out: +for_each_online_cpu (cpu) { +if (all_cpu_data[cpu]) { +kill_timer (&all_cpu_data[cpu]->timer); +xfree (all_cpu_data[cpu]); + } + }
I have a hard time seeing where in this function the setup happens that is being undone here (keeping in mind that the notifier registration inside cpufreq_register_driver() doesn't actually call the notifier function).
And then, looking at the diff between this and what Linux 4.2-rc3 has (which admittedly looks a little newer than what you sent, so I already subtract some of the delta), it is significantly larger than the source file itself. That surely doesn't suggest a clone-with- minimal-delta. Yet as said before - either you do that, or you accept us picking at things you inherited from Linux.
Jan
Quoted 40 lines · Jan Beulich
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 25.06.15 at 13:16, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +24
-0+int __init intel_pstate_init (void ) +{ +int cpu, rc =0 ; +const struct x86_cpu_id *id; +struct cpu_defaults *cpu_info; + + 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 *, NR_CPUS); +if (!all_cpu_data) +return -ENOMEM ; + + rc =cpufreq_register_driver (&intel_pstate_driver); +if (rc)xen/arch/x86/acpi/cpufreq/intel_pstate.c line 867
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+ goto out; + +return rc; +out: +for_each_online_cpu (cpu) { +if (all_cpu_data[cpu]) { +kill_timer (&all_cpu_data[cpu]->timer); +xfree (all_cpu_data[cpu]); + } + }I have a hard time seeing where in this function the setup happens that is being undone here (keeping in mind that the notifier registration inside
cpufreq_register_driver()doesn't actually call the notifier function).
Quoted 5 lines
And then, looking at the diff between this and what Linux 4.2-rc3 has (which admittedly looks a little newer than what you sent, so I already subtract some of the delta), it is significantly larger than the source file itself. That surely doesn't suggest a clone-with- minimal-delta. Yet as said before - either you do that, or you accept us picking at things you inherited from Linux.
I think it's better to choose the latter - picking out things that are useful for us from Linux. Can you please take a look this patch and summarize the comments? Thanks.
Best,
Wei
Quoted 45 lines
Quoted 1 line
Quoted 1 line · On 27.07.15 at 11:30, <[email protected]> wrote:
Quoted 40 lines · Jan Beulich
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 25.06.15 at 13:16, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +24
-0+int __init intel_pstate_init (void ) +{ +int cpu, rc =0 ; +const struct x86_cpu_id *id; +struct cpu_defaults *cpu_info; + + 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 *, NR_CPUS); +if (!all_cpu_data) +return -ENOMEM ; + + rc =cpufreq_register_driver (&intel_pstate_driver); +if (rc)xen/arch/x86/acpi/cpufreq/intel_pstate.c line 867
Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c new file +10
-0+ goto out; + +return rc; +out: +for_each_online_cpu (cpu) { +if (all_cpu_data[cpu]) { +kill_timer (&all_cpu_data[cpu]->timer); +xfree (all_cpu_data[cpu]); + } + }I have a hard time seeing where in this function the setup happens that is being undone here (keeping in mind that the notifier registration inside
cpufreq_register_driver()doesn't actually call the notifier function).Quoted 3 lines
And then, looking at the diff between this and what Linux 4.2-rc3 has (which admittedly looks a little newer than what you sent, so I already subtract some of the delta), it is significantly larger than the source file itself.
Quoted 7 lines
That
Quoted 2 lines
surely doesn't suggest a clone-with- minimal-delta. Yet as said before - either you do that, or you accept us picking at things you inherited from Linux.
I think it's better to choose the latter - picking out things that are useful for us from Linux.
Can you please take a look this patch and summarize the comments? Thanks.
I'm sorry, but for a first round I'd rather expect _you_ to go through the code you intend to add and spot possible problems. Only then, on a submission where you state that you did so, would I want to invest time in sanity checking things.
And then I hope you realize that the clone-with-minimal-delta would have benefits on the maintenance side going forward (fewer manual adjustments needed due to non-applying Linux side changes).
Jan