[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] misc cpufreq cleanup



# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxxxx>
# Date 1304930762 -3600
# Node ID 82180954eda9cfe279e7ecf8c9ed4ffa29796bfb
# Parent  c822888f36568f26e95f9844c7f0c5e06df7aa20
misc cpufreq cleanup

- proper handling of governor command line options when using the
  default governor
- warning message for unrecognized command line options
- replacing a NR_CPUS sized array with per-CPU data
- a couple of __read_mostly annotations

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---


diff -r c822888f3656 -r 82180954eda9 xen/drivers/cpufreq/cpufreq.c
--- a/xen/drivers/cpufreq/cpufreq.c     Mon May 09 09:27:42 2011 +0100
+++ b/xen/drivers/cpufreq/cpufreq.c     Mon May 09 09:46:02 2011 +0100
@@ -47,7 +47,8 @@
 #include <acpi/acpi.h>
 #include <acpi/cpufreq/cpufreq.h>
 
-static unsigned int usr_max_freq, usr_min_freq;
+static unsigned int __read_mostly usr_min_freq;
+static unsigned int __read_mostly usr_max_freq;
 static void cpufreq_cmdline_common_para(struct cpufreq_policy *new_policy);
 
 struct cpufreq_dom {
@@ -55,10 +56,10 @@
     cpumask_t          map;
     struct list_head   node;
 };
-static LIST_HEAD(cpufreq_dom_list_head);
+static LIST_HEAD_READ_MOSTLY(cpufreq_dom_list_head);
 
-struct cpufreq_governor *cpufreq_opt_governor;
-LIST_HEAD(cpufreq_governor_list);
+struct cpufreq_governor *__read_mostly cpufreq_opt_governor;
+LIST_HEAD_READ_MOSTLY(cpufreq_governor_list);
 
 bool_t __read_mostly cpufreq_verbose;
 
@@ -525,6 +526,7 @@
 {
     static struct cpufreq_governor *__initdata cpufreq_governors[] =
     {
+        CPUFREQ_DEFAULT_GOVERNOR,
         &cpufreq_gov_userspace,
         &cpufreq_gov_dbs,
         &cpufreq_gov_performance,
@@ -558,8 +560,10 @@
         }
 
         if (str && !cpufreq_handle_common_option(str, val) &&
-            cpufreq_governors[gov_index]->handle_option)
-            cpufreq_governors[gov_index]->handle_option(str, val);
+            (!cpufreq_governors[gov_index]->handle_option ||
+             !cpufreq_governors[gov_index]->handle_option(str, val)))
+            printk(XENLOG_WARNING "cpufreq/%s: option '%s' not recognized\n",
+                   cpufreq_governors[gov_index]->name, str);
 
         str = end;
     } while (str);
diff -r c822888f3656 -r 82180954eda9 
xen/drivers/cpufreq/cpufreq_misc_governors.c
--- a/xen/drivers/cpufreq/cpufreq_misc_governors.c      Mon May 09 09:27:42 
2011 +0100
+++ b/xen/drivers/cpufreq/cpufreq_misc_governors.c      Mon May 09 09:46:02 
2011 +0100
@@ -14,14 +14,17 @@
  *
  */
 
+#include <xen/cpu.h>
 #include <xen/init.h>
+#include <xen/percpu.h>
 #include <xen/sched.h>
 #include <acpi/cpufreq/cpufreq.h>
 
 /*
  * cpufreq userspace governor
  */
-static unsigned int cpu_set_freq[NR_CPUS];
+static unsigned int __read_mostly userspace_cmdline_freq;
+static DEFINE_PER_CPU(unsigned int, cpu_set_freq);
 
 static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
                                       unsigned int event)
@@ -35,21 +38,21 @@
 
     switch (event) {
     case CPUFREQ_GOV_START:
-        if (!cpu_set_freq[cpu])
-            cpu_set_freq[cpu] = policy->cur;
+        if (!per_cpu(cpu_set_freq, cpu))
+            per_cpu(cpu_set_freq, cpu) = policy->cur;
         break;
     case CPUFREQ_GOV_STOP:
-        cpu_set_freq[cpu] = 0;
+        per_cpu(cpu_set_freq, cpu) = 0;
         break;
     case CPUFREQ_GOV_LIMITS:
-        if (policy->max < cpu_set_freq[cpu])
+        if (policy->max < per_cpu(cpu_set_freq, cpu))
             ret = __cpufreq_driver_target(policy, policy->max,
                         CPUFREQ_RELATION_H);
-        else if (policy->min > cpu_set_freq[cpu])
+        else if (policy->min > per_cpu(cpu_set_freq, cpu))
             ret = __cpufreq_driver_target(policy, policy->min,
                         CPUFREQ_RELATION_L);
         else
-            ret = __cpufreq_driver_target(policy, cpu_set_freq[cpu],
+            ret = __cpufreq_driver_target(policy, per_cpu(cpu_set_freq, cpu),
                         CPUFREQ_RELATION_L);
 
         break;
@@ -68,7 +71,7 @@
     if (!cpu_online(cpu) || !(policy = per_cpu(cpufreq_cpu_policy, cpu)))
         return -EINVAL;
 
-    cpu_set_freq[cpu] = freq;
+    per_cpu(cpu_set_freq, cpu) = freq;
 
     if (freq < policy->min)
         freq = policy->min;
@@ -78,19 +81,35 @@
     return __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L);
 }
 
-static void __init 
+static bool_t __init
 cpufreq_userspace_handle_option(const char *name, const char *val)
 {
     if (!strcmp(name, "speed") && val) {
-        unsigned int usr_cmdline_freq;
-        unsigned int cpu;
+        userspace_cmdline_freq = simple_strtoul(val, NULL, 0);
+        return 1;
+    }
+    return 0;
+}
 
-        usr_cmdline_freq = simple_strtoul(val, NULL, 0);
-        for (cpu = 0; cpu < NR_CPUS; cpu++)
-            cpu_set_freq[cpu] = usr_cmdline_freq;
+static int cpufreq_userspace_cpu_callback(
+    struct notifier_block *nfb, unsigned long action, void *hcpu)
+{
+    unsigned int cpu = (unsigned long)hcpu;
+
+    switch (action)
+    {
+    case CPU_UP_PREPARE:
+        per_cpu(cpu_set_freq, cpu) = userspace_cmdline_freq;
+        break;
     }
+
+    return NOTIFY_DONE;
 }
 
+static struct notifier_block cpufreq_userspace_cpu_nfb = {
+    .notifier_call = cpufreq_userspace_cpu_callback
+};
+
 struct cpufreq_governor cpufreq_gov_userspace = {
     .name = "userspace",
     .governor = cpufreq_governor_userspace,
@@ -99,6 +118,11 @@
 
 static int __init cpufreq_gov_userspace_init(void)
 {
+    unsigned int cpu;
+
+    for_each_online_cpu(cpu)
+        per_cpu(cpu_set_freq, cpu) = userspace_cmdline_freq;
+    register_cpu_notifier(&cpufreq_userspace_cpu_nfb);
     return cpufreq_register_governor(&cpufreq_gov_userspace);
 }
 __initcall(cpufreq_gov_userspace_init);
diff -r c822888f3656 -r 82180954eda9 xen/drivers/cpufreq/cpufreq_ondemand.c
--- a/xen/drivers/cpufreq/cpufreq_ondemand.c    Mon May 09 09:27:42 2011 +0100
+++ b/xen/drivers/cpufreq/cpufreq_ondemand.c    Mon May 09 09:46:02 2011 +0100
@@ -296,7 +296,7 @@
     return 0;
 }
 
-static void __init cpufreq_dbs_handle_option(const char *name, const char *val)
+static bool_t __init cpufreq_dbs_handle_option(const char *name, const char 
*val)
 {
     if ( !strcmp(name, "rate") && val )
     {
@@ -334,6 +334,9 @@
         }
         dbs_tuners_ins.powersave_bias = tmp;
     }
+    else
+        return 0;
+    return 1;
 }
 
 struct cpufreq_governor cpufreq_gov_dbs = {
diff -r c822888f3656 -r 82180954eda9 xen/include/acpi/cpufreq/cpufreq.h
--- a/xen/include/acpi/cpufreq/cpufreq.h        Mon May 09 09:27:42 2011 +0100
+++ b/xen/include/acpi/cpufreq/cpufreq.h        Mon May 09 09:46:02 2011 +0100
@@ -93,7 +93,7 @@
     char    name[CPUFREQ_NAME_LEN];
     int     (*governor)(struct cpufreq_policy *policy,
                         unsigned int event);
-    void    (*handle_option)(const char *name, const char *value);
+    bool_t  (*handle_option)(const char *name, const char *value);
     struct list_head governor_list;
 };
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.