Exemplo n.º 1
0
void cpuquiet_unregister_driver(struct cpuquiet_driver *drv)
{
	unsigned int cpu;

	if (drv != cpuquiet_curr_driver) {
		WARN(1, "invalid cpuquiet_unregister_driver(%s)\n",
			drv->name);
		return;
	}

	mutex_lock(&cpuquiet_lock);

	/* Stop current governor first */
	cpuquiet_switch_governor(NULL);
	cpuquiet_curr_driver = NULL;

	for_each_possible_cpu(cpu) {
#ifdef CONFIG_CPUQUIET_STATS
		kobject_put(&stats[cpu].cpu_kobject);
#endif
		cpuquiet_remove_dev(cpu);
	}

	mutex_unlock(&cpuquiet_lock);
}
Exemplo n.º 2
0
/*
 * only after register we can check for the kernel
 * config default governor and set it
 */
void cpuquiet_set_default_governor(struct cpuquiet_governor* gov)
{
#ifdef CONFIG_CPUQUIET_DEFAULT_GOV_BALANCED
	if (!strnicmp("balanced", gov->name, CPUQUIET_NAME_LEN))
		default_gov = gov;
#endif
#ifdef CONFIG_CPUQUIET_DEFAULT_GOV_RQ_STATS
	if (!strnicmp("rq_stats", gov->name, CPUQUIET_NAME_LEN))
		default_gov = gov;
#endif
#ifdef CONFIG_CPUQUIET_DEFAULT_GOV_RUNNABLE
	if (!strnicmp("runnable", gov->name, CPUQUIET_NAME_LEN))
		default_gov = gov;
#endif
#ifdef CONFIG_CPUQUIET_DEFAULT_GOV_MAKO_HOTPLUG
	if (!strnicmp("mako_hotplug", gov->name, CPUQUIET_NAME_LEN))
		default_gov = gov;
#endif
#ifdef CONFIG_CPUQUIET_DEFAULT_GOV_LOAD_STATS
	if (!strnicmp("load_stats", gov->name, CPUQUIET_NAME_LEN))
		default_gov = gov;
#endif
	if (default_gov != NULL)
		cpuquiet_switch_governor(default_gov); 
}
Exemplo n.º 3
0
int cpuquiet_register_driver(struct cpuquiet_driver *drv)
{
	int err = -EBUSY;
	unsigned int cpu;
	struct device *dev;

	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) {
#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
		}
	}

	mutex_lock(&cpuquiet_lock);
	if (!cpuquiet_curr_driver) {
		err = 0;
		cpuquiet_curr_driver = drv;
		cpuquiet_switch_governor(cpuquiet_get_first_governor());
	}
	mutex_unlock(&cpuquiet_lock);

	return err;
}