Set userspace governor as default, which stays same effect as when cpufreq in xen is not enabled. As a result, enable cpufreq in xen by default to avoid reboot to activate cpufreq. Now it's always on but w/o performance impact if user doesn't tempt to change governor. We also add some warning info for debug. Signed-off-by: Liu, Jinsong diff -r e9e46a38ac0d xen/arch/x86/acpi/cpufreq/cpufreq.c --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c Fri Dec 19 15:09:33 2008 +0800 +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c Fri Dec 19 18:40:32 2008 +0800 @@ -393,8 +393,10 @@ static int acpi_cpufreq_target(struct cp drv_write(&cmd); - if (!check_freqs(cmd.mask, freqs.new, data)) + if (!check_freqs(cmd.mask, freqs.new, data)) { + printk(KERN_WARNING "Fail transfer to new freq %d\n", freqs.new); return -EAGAIN; + } for_each_cpu_mask(j, online_policy_cpus) cpufreq_statistic_update(j, perf->state, next_perf_state); diff -r e9e46a38ac0d xen/common/domain.c --- a/xen/common/domain.c Fri Dec 19 15:09:33 2008 +0800 +++ b/xen/common/domain.c Fri Dec 19 18:40:32 2008 +0800 @@ -32,13 +32,15 @@ /* Linux config option: propageted to domain0 */ /* xen_processor_pmbits: xen control Cx, Px, ... */ -unsigned int xen_processor_pmbits = 0; +unsigned int xen_processor_pmbits = XEN_PROCESSOR_PM_PX; /* opt_dom0_vcpus_pin: If true, dom0 VCPUs are pinned. */ static unsigned int opt_dom0_vcpus_pin; boolean_param("dom0_vcpus_pin", opt_dom0_vcpus_pin); -enum cpufreq_controller cpufreq_controller; +/* set Xen as default cpufreq */ +enum cpufreq_controller cpufreq_controller = FREQCTL_xen; + static void __init setup_cpufreq_option(char *str) { if ( !strcmp(str, "dom0-kernel") ) @@ -46,11 +48,6 @@ static void __init setup_cpufreq_option( xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX; cpufreq_controller = FREQCTL_dom0_kernel; opt_dom0_vcpus_pin = 1; - } - else if ( !strcmp(str, "xen") ) - { - xen_processor_pmbits |= XEN_PROCESSOR_PM_PX; - cpufreq_controller = FREQCTL_xen; } } custom_param("cpufreq", setup_cpufreq_option); diff -r e9e46a38ac0d xen/drivers/cpufreq/utility.c --- a/xen/drivers/cpufreq/utility.c Fri Dec 19 15:09:33 2008 +0800 +++ b/xen/drivers/cpufreq/utility.c Fri Dec 19 18:40:32 2008 +0800 @@ -360,10 +360,14 @@ int __cpufreq_set_policy(struct cpufreq_ /* start new governor */ data->governor = policy->governor; if (__cpufreq_governor(data, CPUFREQ_GOV_START)) { + printk(KERN_WARNING "Fail change to %s governor\n", + data->governor->name); /* new governor failed, so re-start old one */ if (old_gov) { data->governor = old_gov; __cpufreq_governor(data, CPUFREQ_GOV_START); + printk(KERN_WARNING "Still stay at %s governor\n", + data->governor->name); } return -EINVAL; } diff -r e9e46a38ac0d xen/include/acpi/cpufreq/cpufreq.h --- a/xen/include/acpi/cpufreq/cpufreq.h Fri Dec 19 15:09:33 2008 +0800 +++ b/xen/include/acpi/cpufreq/cpufreq.h Fri Dec 19 18:40:32 2008 +0800 @@ -10,6 +10,9 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ + +#ifndef __XEN_CPUFREQ_PM_H__ +#define __XEN_CPUFREQ_PM_H__ #include #include @@ -91,7 +94,7 @@ extern int cpufreq_register_governor(str extern int cpufreq_register_governor(struct cpufreq_governor *governor); extern int cpufreq_unregister_governor(struct cpufreq_governor *governor); extern struct cpufreq_governor *__find_governor(const char *governor); -#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_performance +#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_userspace /* pass a target to the cpufreq driver */ extern int __cpufreq_driver_target(struct cpufreq_policy *policy, @@ -218,3 +221,4 @@ int get_cpufreq_ondemand_para(uint32_t * uint32_t *up_threshold); int write_ondemand_sampling_rate(unsigned int sampling_rate); int write_ondemand_up_threshold(unsigned int up_threshold); +#endif /* __XEN_CPUFREQ_PM_H__ */