static int autohotplug_smart_trydown(struct auto_cpu_hotplug_loadinfo *load)
{
	int big_nr, little_nr;
	unsigned int first, to_down;

	get_cpus_online(load, &little_nr, &big_nr);
	if (get_cpus_under(load, load_try_down, &first) >= 2
				&& is_cpu_load_stable(first, STABLE_DOWN))
	{
		if (little_nr) {
			if (get_littles_under(load, load_try_down * 2, &to_down))
				return do_cpu_down(to_down);
		} else {
			return do_cpu_down(first);
		}
	}

	return 0;
}
static int autohotplug_smart_trydown(struct auto_cpu_hotplug_loadinfo *load)
{
	unsigned int first;

	if (get_cpus_under(load, load_try_down, &first) >= 2
				&& is_cpu_load_stable(first, STABLE_DOWN))
	{
		return do_cpu_down(first);
	}

	return 0;
}
static int autohotplug_smart_trydown(struct auto_cpu_hotplug_loadinfo *load)
{
	unsigned int to_down = CONFIG_NR_CPUS;
	unsigned int on_boost = CONFIG_NR_CPUS;

	if (get_cpus_stable_under(load, load_try_down, &to_down, 0) >= 2) {
		if (get_bigs_under(load, load_try_down, &to_down) >= 2)
			return do_cpu_down(to_down);
		else if (get_littles_under(load, load_try_down, &to_down) > 1)
			return do_cpu_down(to_down);
		else if (get_bigs_under(load, load_try_down, &to_down) == 1
				&& !(get_bigs_above(load, load_try_boost, &on_boost)
				&& is_cpu_load_stable(on_boost, STABLE_BOOST))
				&& (load->cpu_load[to_down] <= load->big_min_load)
				&& is_cpu_load_stable(to_down, STABLE_LAST_BIG))
			return do_cpu_down(to_down);
		else
			return 0;
	} else {
		return 0;
	}
}
Beispiel #4
0
static ssize_t write_cpuhp_target(struct device *dev,
				  struct device_attribute *attr,
				  const char *buf, size_t count)
{
	struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, dev->id);
	struct cpuhp_step *sp;
	int target, ret;

	ret = kstrtoint(buf, 10, &target);
	if (ret)
		return ret;

#ifdef CONFIG_CPU_HOTPLUG_STATE_CONTROL
	if (target < CPUHP_OFFLINE || target > CPUHP_ONLINE)
		return -EINVAL;
#else
	if (target != CPUHP_OFFLINE && target != CPUHP_ONLINE)
		return -EINVAL;
#endif

	ret = lock_device_hotplug_sysfs();
	if (ret)
		return ret;

	mutex_lock(&cpuhp_state_mutex);
	sp = cpuhp_get_step(target);
	ret = !sp->name || sp->cant_stop ? -EINVAL : 0;
	mutex_unlock(&cpuhp_state_mutex);
	if (ret)
		return ret;

	if (st->state < target)
		ret = do_cpu_up(dev->id, target);
	else
		ret = do_cpu_down(dev->id, target);

	unlock_device_hotplug();
	return ret ? ret : count;
}
Beispiel #5
0
int cpu_down(unsigned int cpu)
{
	return do_cpu_down(cpu, CPUHP_OFFLINE);
}