ia64/xen-unstable
changeset 19149:efef232bbbdb
Consolidate cpufreq cmdline handling
... by moving as much of the option processing into cpufreq code as is
possible, by folding the cpufreq_governor option into the cpufreq one
(the governor name, if any, must be specified as the first thing after
the separator following "cpufreq=xen"), and by allowing each
governor to have an option processing routine.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
... by moving as much of the option processing into cpufreq code as is
possible, by folding the cpufreq_governor option into the cpufreq one
(the governor name, if any, must be specified as the first thing after
the separator following "cpufreq=xen"), and by allowing each
governor to have an option processing routine.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Tue Feb 03 18:12:51 2009 +0000 (2009-02-03) |
parents | aca402831ac1 |
children | 93d2193450c4 |
files | xen/common/domain.c xen/drivers/cpufreq/cpufreq.c xen/drivers/cpufreq/cpufreq_ondemand.c xen/include/acpi/cpufreq/cpufreq.h |
line diff
1.1 --- a/xen/common/domain.c Tue Feb 03 18:11:03 2009 +0000 1.2 +++ b/xen/common/domain.c Tue Feb 03 18:12:51 2009 +0000 1.3 @@ -41,7 +41,6 @@ boolean_param("dom0_vcpus_pin", opt_dom0 1.4 1.5 /* set xen as default cpufreq */ 1.6 enum cpufreq_controller cpufreq_controller = FREQCTL_xen; 1.7 -struct cpufreq_governor *cpufreq_opt_governor; 1.8 1.9 static void __init setup_cpufreq_option(char *str) 1.10 { 1.11 @@ -71,19 +70,6 @@ static void __init setup_cpufreq_option( 1.12 } 1.13 custom_param("cpufreq", setup_cpufreq_option); 1.14 1.15 -static void __init setup_cpufreq_gov_option(char *str) 1.16 -{ 1.17 - if ( !strcmp(str, "userspace") ) 1.18 - cpufreq_opt_governor = &cpufreq_gov_userspace; 1.19 - else if ( !strcmp(str, "performance") ) 1.20 - cpufreq_opt_governor = &cpufreq_gov_performance; 1.21 - else if ( !strcmp(str, "powersave") ) 1.22 - cpufreq_opt_governor = &cpufreq_gov_powersave; 1.23 - else if ( !strcmp(str, "ondemand") ) 1.24 - cpufreq_opt_governor = &cpufreq_gov_dbs; 1.25 -} 1.26 -custom_param("cpufreq_governor", setup_cpufreq_gov_option); 1.27 - 1.28 /* Protect updates/reads (resp.) of domain_list and domain_hash. */ 1.29 DEFINE_SPINLOCK(domlist_update_lock); 1.30 DEFINE_RCU_READ_LOCK(domlist_read_lock);
2.1 --- a/xen/drivers/cpufreq/cpufreq.c Tue Feb 03 18:11:03 2009 +0000 2.2 +++ b/xen/drivers/cpufreq/cpufreq.c Tue Feb 03 18:12:51 2009 +0000 2.3 @@ -53,6 +53,7 @@ struct cpufreq_dom { 2.4 }; 2.5 static LIST_HEAD(cpufreq_dom_list_head); 2.6 2.7 +struct cpufreq_governor *cpufreq_opt_governor; 2.8 LIST_HEAD(cpufreq_governor_list); 2.9 2.10 struct cpufreq_governor *__find_governor(const char *governor) 2.11 @@ -467,3 +468,47 @@ out: 2.12 return ret; 2.13 } 2.14 2.15 +void __init cpufreq_cmdline_parse(char *str) 2.16 +{ 2.17 + static struct cpufreq_governor *__initdata cpufreq_governors[] = 2.18 + { 2.19 + &cpufreq_gov_userspace, 2.20 + &cpufreq_gov_dbs, 2.21 + &cpufreq_gov_performance, 2.22 + &cpufreq_gov_powersave 2.23 + }; 2.24 + 2.25 + do { 2.26 + char *val, *end = strchr(str, ','); 2.27 + unsigned int i; 2.28 + 2.29 + if ( end ) 2.30 + *end++ = '\0'; 2.31 + val = strchr(str, '='); 2.32 + if ( val ) 2.33 + *val++ = '\0'; 2.34 + 2.35 + if ( !cpufreq_opt_governor ) 2.36 + { 2.37 + if ( !val ) 2.38 + { 2.39 + for ( i = 0; i < ARRAY_SIZE(cpufreq_governors); ++i ) 2.40 + if ( !strcmp(str, cpufreq_governors[i]->name) ) 2.41 + { 2.42 + cpufreq_opt_governor = cpufreq_governors[i]; 2.43 + str = NULL; 2.44 + break; 2.45 + } 2.46 + } 2.47 + else 2.48 + cpufreq_opt_governor = CPUFREQ_DEFAULT_GOVERNOR; 2.49 + } 2.50 + 2.51 + if ( str ) 2.52 + for ( i = 0; i < ARRAY_SIZE(cpufreq_governors); ++i ) 2.53 + if ( cpufreq_governors[i]->handle_option ) 2.54 + cpufreq_governors[i]->handle_option(str, val); 2.55 + 2.56 + str = end; 2.57 + } while ( str ); 2.58 +}
3.1 --- a/xen/drivers/cpufreq/cpufreq_ondemand.c Tue Feb 03 18:11:03 2009 +0000 3.2 +++ b/xen/drivers/cpufreq/cpufreq_ondemand.c Tue Feb 03 18:12:51 2009 +0000 3.3 @@ -281,9 +281,50 @@ int cpufreq_governor_dbs(struct cpufreq_ 3.4 return 0; 3.5 } 3.6 3.7 +static void __init cpufreq_dbs_handle_option(const char *name, const char *val) 3.8 +{ 3.9 + if ( !strcmp(name, "rate") && val ) 3.10 + { 3.11 + usr_sampling_rate = simple_strtoull(val, NULL, 0) * MICROSECS(1); 3.12 + } 3.13 + else if ( !strcmp(name, "threshold") && val ) 3.14 + { 3.15 + unsigned long tmp = simple_strtoul(val, NULL, 0); 3.16 + 3.17 + if ( tmp < MIN_FREQUENCY_UP_THRESHOLD ) 3.18 + { 3.19 + printk(XENLOG_WARNING "cpufreq/ondemand: " 3.20 + "specified threshold too low, using %d\n", 3.21 + MIN_FREQUENCY_UP_THRESHOLD); 3.22 + tmp = MIN_FREQUENCY_UP_THRESHOLD; 3.23 + } 3.24 + else if ( tmp > MAX_FREQUENCY_UP_THRESHOLD ) 3.25 + { 3.26 + printk(XENLOG_WARNING "cpufreq/ondemand: " 3.27 + "specified threshold too high, using %d\n", 3.28 + MAX_FREQUENCY_UP_THRESHOLD); 3.29 + tmp = MAX_FREQUENCY_UP_THRESHOLD; 3.30 + } 3.31 + dbs_tuners_ins.up_threshold = tmp; 3.32 + } 3.33 + else if ( !strcmp(name, "bias") && val ) 3.34 + { 3.35 + unsigned long tmp = simple_strtoul(val, NULL, 0); 3.36 + 3.37 + if ( tmp > 1000 ) 3.38 + { 3.39 + printk(XENLOG_WARNING "cpufreq/ondemand: " 3.40 + "specified bias too high, using 1000\n"); 3.41 + tmp = 1000; 3.42 + } 3.43 + dbs_tuners_ins.powersave_bias = tmp; 3.44 + } 3.45 +} 3.46 + 3.47 struct cpufreq_governor cpufreq_gov_dbs = { 3.48 .name = "ondemand", 3.49 .governor = cpufreq_governor_dbs, 3.50 + .handle_option = cpufreq_dbs_handle_option 3.51 }; 3.52 3.53 static int __init cpufreq_gov_dbs_init(void) 3.54 @@ -297,55 +338,3 @@ static void cpufreq_gov_dbs_exit(void) 3.55 cpufreq_unregister_governor(&cpufreq_gov_dbs); 3.56 } 3.57 __exitcall(cpufreq_gov_dbs_exit); 3.58 - 3.59 -void __init cpufreq_cmdline_parse(char *str) 3.60 -{ 3.61 - do { 3.62 - char *val, *end = strchr(str, ','); 3.63 - 3.64 - if ( end ) 3.65 - *end++ = '\0'; 3.66 - val = strchr(str, '='); 3.67 - if ( val ) 3.68 - *val++ = '\0'; 3.69 - 3.70 - if ( !strcmp(str, "rate") && val ) 3.71 - { 3.72 - usr_sampling_rate = simple_strtoull(val, NULL, 0) * MICROSECS(1); 3.73 - } 3.74 - else if ( !strcmp(str, "threshold") && val ) 3.75 - { 3.76 - unsigned long tmp = simple_strtoul(val, NULL, 0); 3.77 - 3.78 - if ( tmp < MIN_FREQUENCY_UP_THRESHOLD ) 3.79 - { 3.80 - printk(XENLOG_WARNING "cpufreq/ondemand: " 3.81 - "specified threshold too low, using %d\n", 3.82 - MIN_FREQUENCY_UP_THRESHOLD); 3.83 - tmp = MIN_FREQUENCY_UP_THRESHOLD; 3.84 - } 3.85 - else if ( tmp > MAX_FREQUENCY_UP_THRESHOLD ) 3.86 - { 3.87 - printk(XENLOG_WARNING "cpufreq/ondemand: " 3.88 - "specified threshold too high, using %d\n", 3.89 - MAX_FREQUENCY_UP_THRESHOLD); 3.90 - tmp = MAX_FREQUENCY_UP_THRESHOLD; 3.91 - } 3.92 - dbs_tuners_ins.up_threshold = tmp; 3.93 - } 3.94 - else if ( !strcmp(str, "bias") && val ) 3.95 - { 3.96 - unsigned long tmp = simple_strtoul(val, NULL, 0); 3.97 - 3.98 - if ( tmp > 1000 ) 3.99 - { 3.100 - printk(XENLOG_WARNING "cpufreq/ondemand: " 3.101 - "specified bias too high, using 1000\n"); 3.102 - tmp = 1000; 3.103 - } 3.104 - dbs_tuners_ins.powersave_bias = tmp; 3.105 - } 3.106 - 3.107 - str = end; 3.108 - } while ( str ); 3.109 -}
4.1 --- a/xen/include/acpi/cpufreq/cpufreq.h Tue Feb 03 18:11:03 2009 +0000 4.2 +++ b/xen/include/acpi/cpufreq/cpufreq.h Tue Feb 03 18:12:51 2009 +0000 4.3 @@ -87,6 +87,7 @@ struct cpufreq_governor { 4.4 char name[CPUFREQ_NAME_LEN]; 4.5 int (*governor)(struct cpufreq_policy *policy, 4.6 unsigned int event); 4.7 + void (*handle_option)(const char *name, const char *value); 4.8 struct list_head governor_list; 4.9 }; 4.10