debuggers.hg
changeset 18988:5544a96572bf
cpufreq: xen is default cpufreq, userspace is default governor (override on cmdline)
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 attempt
to change governor.
Add governor option at cmdline, add some warning info for debug.
Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
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 attempt
to change governor.
Add governor option at cmdline, add some warning info for debug.
Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Mon Dec 29 14:08:46 2008 +0000 (2008-12-29) |
parents | e0301796fce8 |
children | de38a475ab9e |
files | xen/arch/ia64/xen/cpufreq/cpufreq.c xen/arch/x86/acpi/cpufreq/cpufreq.c xen/common/domain.c xen/drivers/cpufreq/cpufreq.c xen/drivers/cpufreq/utility.c xen/include/acpi/cpufreq/cpufreq.h |
line diff
1.1 --- a/xen/arch/ia64/xen/cpufreq/cpufreq.c Mon Dec 29 14:05:26 2008 +0000 1.2 +++ b/xen/arch/ia64/xen/cpufreq/cpufreq.c Mon Dec 29 14:08:46 2008 +0000 1.3 @@ -226,7 +226,8 @@ acpi_cpufreq_cpu_init (struct cpufreq_po 1.4 data->acpi_data->states[i].transition_latency * 1000; 1.5 } 1.6 } 1.7 - policy->governor = CPUFREQ_DEFAULT_GOVERNOR; 1.8 + 1.9 + policy->governor = cpufreq_opt_governor ? : CPUFREQ_DEFAULT_GOVERNOR; 1.10 1.11 policy->cur = acpi_cpufreq_get(policy->cpu); 1.12 printk(KERN_INFO "Current freq of CPU %u is %u\n", cpu, policy->cur);
2.1 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c Mon Dec 29 14:05:26 2008 +0000 2.2 +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c Mon Dec 29 14:08:46 2008 +0000 2.3 @@ -393,8 +393,10 @@ static int acpi_cpufreq_target(struct cp 2.4 2.5 drv_write(&cmd); 2.6 2.7 - if (!check_freqs(cmd.mask, freqs.new, data)) 2.8 + if (!check_freqs(cmd.mask, freqs.new, data)) { 2.9 + printk(KERN_WARNING "Fail transfer to new freq %d\n", freqs.new); 2.10 return -EAGAIN; 2.11 + } 2.12 2.13 for_each_cpu_mask(j, online_policy_cpus) 2.14 cpufreq_statistic_update(j, perf->state, next_perf_state); 2.15 @@ -508,7 +510,8 @@ acpi_cpufreq_cpu_init(struct cpufreq_pol 2.16 policy->cpuinfo.transition_latency = 2.17 perf->states[i].transition_latency * 1000; 2.18 } 2.19 - policy->governor = CPUFREQ_DEFAULT_GOVERNOR; 2.20 + 2.21 + policy->governor = cpufreq_opt_governor ? : CPUFREQ_DEFAULT_GOVERNOR; 2.22 2.23 data->max_freq = perf->states[0].core_frequency * 1000; 2.24 /* table init */
3.1 --- a/xen/common/domain.c Mon Dec 29 14:05:26 2008 +0000 3.2 +++ b/xen/common/domain.c Mon Dec 29 14:08:46 2008 +0000 3.3 @@ -33,13 +33,16 @@ 3.4 3.5 /* Linux config option: propageted to domain0 */ 3.6 /* xen_processor_pmbits: xen control Cx, Px, ... */ 3.7 -unsigned int xen_processor_pmbits = 0; 3.8 +unsigned int xen_processor_pmbits = XEN_PROCESSOR_PM_PX; 3.9 3.10 /* opt_dom0_vcpus_pin: If true, dom0 VCPUs are pinned. */ 3.11 static unsigned int opt_dom0_vcpus_pin; 3.12 boolean_param("dom0_vcpus_pin", opt_dom0_vcpus_pin); 3.13 3.14 -enum cpufreq_controller cpufreq_controller; 3.15 +/* set xen as default cpufreq */ 3.16 +enum cpufreq_controller cpufreq_controller = FREQCTL_xen; 3.17 +struct cpufreq_governor *cpufreq_opt_governor; 3.18 + 3.19 static void __init setup_cpufreq_option(char *str) 3.20 { 3.21 char *arg; 3.22 @@ -52,19 +55,35 @@ static void __init setup_cpufreq_option( 3.23 return; 3.24 } 3.25 3.26 + if ( !strcmp(str, "none") ) 3.27 + { 3.28 + xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX; 3.29 + cpufreq_controller = FREQCTL_none; 3.30 + return; 3.31 + } 3.32 + 3.33 if ( (arg = strpbrk(str, ",:")) != NULL ) 3.34 *arg++ = '\0'; 3.35 3.36 if ( !strcmp(str, "xen") ) 3.37 - { 3.38 - xen_processor_pmbits |= XEN_PROCESSOR_PM_PX; 3.39 - cpufreq_controller = FREQCTL_xen; 3.40 if ( arg && *arg ) 3.41 cpufreq_cmdline_parse(arg); 3.42 - } 3.43 } 3.44 custom_param("cpufreq", setup_cpufreq_option); 3.45 3.46 +static void __init setup_cpufreq_gov_option(char *str) 3.47 +{ 3.48 + if ( !strcmp(str, "userspace") ) 3.49 + cpufreq_opt_governor = &cpufreq_gov_userspace; 3.50 + else if ( !strcmp(str, "performance") ) 3.51 + cpufreq_opt_governor = &cpufreq_gov_performance; 3.52 + else if ( !strcmp(str, "powersave") ) 3.53 + cpufreq_opt_governor = &cpufreq_gov_powersave; 3.54 + else if ( !strcmp(str, "ondemand") ) 3.55 + cpufreq_opt_governor = &cpufreq_gov_dbs; 3.56 +} 3.57 +custom_param("cpufreq_governor", setup_cpufreq_gov_option); 3.58 + 3.59 /* Protect updates/reads (resp.) of domain_list and domain_hash. */ 3.60 DEFINE_SPINLOCK(domlist_update_lock); 3.61 DEFINE_RCU_READ_LOCK(domlist_read_lock);
4.1 --- a/xen/drivers/cpufreq/cpufreq.c Mon Dec 29 14:05:26 2008 +0000 4.2 +++ b/xen/drivers/cpufreq/cpufreq.c Mon Dec 29 14:08:46 2008 +0000 4.3 @@ -214,8 +214,20 @@ int cpufreq_add_cpu(unsigned int cpu) 4.4 memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); 4.5 policy->governor = NULL; 4.6 ret = __cpufreq_set_policy(policy, &new_policy); 4.7 - if (ret) 4.8 - goto err2; 4.9 + if (ret) { 4.10 + if (new_policy.governor == CPUFREQ_DEFAULT_GOVERNOR) 4.11 + /* if default governor fail, cpufreq really meet troubles */ 4.12 + goto err2; 4.13 + else { 4.14 + /* grub option governor fail */ 4.15 + /* give one more chance to default gov */ 4.16 + memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); 4.17 + new_policy.governor = CPUFREQ_DEFAULT_GOVERNOR; 4.18 + ret = __cpufreq_set_policy(policy, &new_policy); 4.19 + if (ret) 4.20 + goto err2; 4.21 + } 4.22 + } 4.23 } 4.24 4.25 return 0;
5.1 --- a/xen/drivers/cpufreq/utility.c Mon Dec 29 14:05:26 2008 +0000 5.2 +++ b/xen/drivers/cpufreq/utility.c Mon Dec 29 14:08:46 2008 +0000 5.3 @@ -360,10 +360,15 @@ int __cpufreq_set_policy(struct cpufreq_ 5.4 /* start new governor */ 5.5 data->governor = policy->governor; 5.6 if (__cpufreq_governor(data, CPUFREQ_GOV_START)) { 5.7 + printk(KERN_WARNING "Fail change to %s governor\n", 5.8 + data->governor->name); 5.9 + 5.10 /* new governor failed, so re-start old one */ 5.11 if (old_gov) { 5.12 data->governor = old_gov; 5.13 __cpufreq_governor(data, CPUFREQ_GOV_START); 5.14 + printk(KERN_WARNING "Still stay at %s governor\n", 5.15 + data->governor->name); 5.16 } 5.17 return -EINVAL; 5.18 }
6.1 --- a/xen/include/acpi/cpufreq/cpufreq.h Mon Dec 29 14:05:26 2008 +0000 6.2 +++ b/xen/include/acpi/cpufreq/cpufreq.h Mon Dec 29 14:08:46 2008 +0000 6.3 @@ -11,6 +11,9 @@ 6.4 * published by the Free Software Foundation. 6.5 */ 6.6 6.7 +#ifndef __XEN_CPUFREQ_PM_H__ 6.8 +#define __XEN_CPUFREQ_PM_H__ 6.9 + 6.10 #include <xen/types.h> 6.11 #include <xen/list.h> 6.12 #include <xen/cpumask.h> 6.13 @@ -85,6 +88,7 @@ struct cpufreq_governor { 6.14 struct list_head governor_list; 6.15 }; 6.16 6.17 +extern struct cpufreq_governor *cpufreq_opt_governor; 6.18 extern struct cpufreq_governor cpufreq_gov_dbs; 6.19 extern struct cpufreq_governor cpufreq_gov_userspace; 6.20 extern struct cpufreq_governor cpufreq_gov_performance; 6.21 @@ -93,7 +97,7 @@ extern struct cpufreq_governor cpufreq_g 6.22 extern int cpufreq_register_governor(struct cpufreq_governor *governor); 6.23 extern int cpufreq_unregister_governor(struct cpufreq_governor *governor); 6.24 extern struct cpufreq_governor *__find_governor(const char *governor); 6.25 -#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_performance 6.26 +#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_userspace 6.27 6.28 /* pass a target to the cpufreq driver */ 6.29 extern int __cpufreq_driver_target(struct cpufreq_policy *policy, 6.30 @@ -220,3 +224,4 @@ int get_cpufreq_ondemand_para(uint32_t * 6.31 uint32_t *up_threshold); 6.32 int write_ondemand_sampling_rate(unsigned int sampling_rate); 6.33 int write_ondemand_up_threshold(unsigned int up_threshold); 6.34 +#endif /* __XEN_CPUFREQ_PM_H__ */