mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 20:32:04 +09:00
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> Reviewed-on: http://git-master/r/168749 Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
This commit is contained in:
committed by
Huang, Tao
parent
c516e3445c
commit
4643c04d29
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user