diff options
author | Peter De Schrijver <pdeschrijver@nvidia.com> | 2012-12-05 16:13:09 +0200 |
---|---|---|
committer | Mandar Padmawar <mpadmawar@nvidia.com> | 2013-03-15 07:12:38 -0700 |
commit | 14350f30939694468a581b805e4aa1baa3f51fa0 (patch) | |
tree | 46553a2b9c4a051db85ae2c55e3947147ab9ceee /drivers/cpuquiet | |
parent | 489424dc579e01e7958792f7629868fd6e9e0587 (diff) |
cpuquiet: Make stats optional
Make the per CPU statistics a configureable option.
bug 1049625
Change-Id: I28b248bbbad89a19e8d8d69400733dfd4a2cf052
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
(cherry picked from commit 94ade9be87aeda9353808d0f9331acf3e3639d3a)
Reviewed-on: http://git-master/r/#change,168749
Reviewed-on: http://git-master/r/206801
Tested-by: Ilan Aelion <iaelion@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
Diffstat (limited to 'drivers/cpuquiet')
-rw-r--r-- | drivers/cpuquiet/Kconfig | 9 | ||||
-rw-r--r-- | drivers/cpuquiet/driver.c | 80 |
2 files changed, 56 insertions, 33 deletions
diff --git a/drivers/cpuquiet/Kconfig b/drivers/cpuquiet/Kconfig index a2025baedf41..34416b1a227c 100644 --- a/drivers/cpuquiet/Kconfig +++ b/drivers/cpuquiet/Kconfig @@ -10,6 +10,15 @@ config CPUQUIET_FRAMEWORK if CPUQUIET_FRAMEWORK +config CPUQUIET_STATS + bool "per CPU statistics" + default n + help + Enable up/down count and total time plugged statistics per CPU. These + depend on correct driver input for reliability + + If in doubt say N. + config CPUQUIET_GOVERNOR_USERSPACE bool "userspace" default y diff --git a/drivers/cpuquiet/driver.c b/drivers/cpuquiet/driver.c index 4b888fa97be2..fc83fa8cd022 100644 --- a/drivers/cpuquiet/driver.c +++ b/drivers/cpuquiet/driver.c @@ -26,6 +26,9 @@ #include "cpuquiet.h" +static struct cpuquiet_driver *cpuquiet_curr_driver; + +#ifdef CONFIG_CPUQUIET_STATS struct cpuquiet_cpu_stat { cputime64_t time_up_total; u64 last_update; @@ -33,14 +36,13 @@ struct cpuquiet_cpu_stat { struct kobject cpu_kobject; }; +struct cpuquiet_cpu_stat *stats; + struct cpu_attribute { struct attribute attr; enum { up_down_count, time_up_total } type; }; -static struct cpuquiet_driver *cpuquiet_curr_driver; -struct cpuquiet_cpu_stat *stats; - #define CPU_ATTRIBUTE(_name) \ static struct cpu_attribute _name ## _attr = { \ .attr = {.name = __stringify(_name), .mode = 0444 }, \ @@ -70,34 +72,6 @@ static void stats_update(struct cpuquiet_cpu_stat *stat, bool up) stat->last_update = cur_jiffies; } -int cpuquiet_quiesence_cpu(unsigned int cpunumber) -{ - int err = -EPERM; - - if (cpuquiet_curr_driver && cpuquiet_curr_driver->quiesence_cpu) - err = cpuquiet_curr_driver->quiesence_cpu(cpunumber); - - if (!err) - stats_update(stats + cpunumber, 0); - - return err; -} -EXPORT_SYMBOL(cpuquiet_quiesence_cpu); - -int cpuquiet_wake_cpu(unsigned int cpunumber) -{ - int err = -EPERM; - - if (cpuquiet_curr_driver && cpuquiet_curr_driver->wake_cpu) - err = cpuquiet_curr_driver->wake_cpu(cpunumber); - - if (!err) - stats_update(stats + cpunumber, 1); - - return err; -} -EXPORT_SYMBOL(cpuquiet_wake_cpu); - static ssize_t stats_sysfs_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -130,31 +104,69 @@ static struct kobj_type ktype_cpu_stats = { .sysfs_ops = &stats_sysfs_ops, .default_attrs = cpu_attributes, }; +#endif + +int cpuquiet_quiesence_cpu(unsigned int cpunumber) +{ + int err = -EPERM; + + if (cpuquiet_curr_driver && cpuquiet_curr_driver->quiesence_cpu) + err = cpuquiet_curr_driver->quiesence_cpu(cpunumber); + +#ifdef CONFIG_CPUQUIET_STATS + if (!err) + stats_update(stats + cpunumber, 0); +#endif + + return err; +} +EXPORT_SYMBOL(cpuquiet_quiesence_cpu); + +int cpuquiet_wake_cpu(unsigned int cpunumber) +{ + int err = -EPERM; + + if (cpuquiet_curr_driver && cpuquiet_curr_driver->wake_cpu) + err = cpuquiet_curr_driver->wake_cpu(cpunumber); + +#ifdef CONFIG_CPUQUIET_STATS + if (!err) + stats_update(stats + cpunumber, 1); +#endif + + return err; +} +EXPORT_SYMBOL(cpuquiet_wake_cpu); int cpuquiet_register_driver(struct cpuquiet_driver *drv) { int err = -EBUSY; unsigned int cpu; struct device *dev; - u64 cur_jiffies; if (!drv) return -EINVAL; +#ifdef CONFIG_CPUQUIET_STATS stats = kzalloc(nr_cpu_ids * sizeof(*stats), GFP_KERNEL); if (!stats) return -ENOMEM; +#endif for_each_possible_cpu(cpu) { - cur_jiffies = get_jiffies_64(); +#ifdef CONFIG_CPUQUIET_STATS + u64 cur_jiffies = get_jiffies_64(); stats[cpu].last_update = cur_jiffies; if (cpu_online(cpu)) stats[cpu].up_down_count = 1; +#endif dev = get_cpu_device(cpu); if (dev) { cpuquiet_add_dev(dev, cpu); +#ifdef CONFIG_CPUQUIET_STATS cpuquiet_cpu_kobject_init(&stats[cpu].cpu_kobject, &ktype_cpu_stats, "stats", cpu); +#endif } } @@ -192,7 +204,9 @@ void cpuquiet_unregister_driver(struct cpuquiet_driver *drv) cpuquiet_curr_driver = NULL; for_each_possible_cpu(cpu) { +#ifdef CONFIG_CPUQUIET_STATS kobject_put(&stats[cpu].cpu_kobject); +#endif cpuquiet_remove_dev(cpu); } |