Esempio n. 1
0
static ssize_t
perflock_store(struct kobject *kobj, struct kobj_attribute *attr,
		const char *buf, size_t n)
{
	int val , ret = -EINVAL;

	if (sscanf(buf, "%d", &val) > 0) {
		if (val == 11 && !is_perf_lock_active(&user_cpu_perf_lock)) {
			perf_lock(&user_cpu_perf_lock);
			ret = n;
		} else if (val == 10 && is_perf_lock_active(&user_cpu_perf_lock)) {
			perf_unlock(&user_cpu_perf_lock);
			ret = n;
		} else {
			switch (val) {
			perf_level_wrapper(0, 1, PERF_LOCK_LOWEST);
			perf_level_wrapper(2, 3, PERF_LOCK_LOW);
			perf_level_wrapper(4, 5, PERF_LOCK_MEDIUM);
			perf_level_wrapper(6, 7, PERF_LOCK_HIGH);
			perf_level_wrapper(8, 9, PERF_LOCK_HIGHEST);
			default:
				
				break;
			}
			return n;
		}
	}
	return ret;
}
Esempio n. 2
0
static ssize_t
perflock_store(struct kobject *kobj, struct kobj_attribute *attr,
		const char *buf, size_t n)
{
	int val;

	if (sscanf(buf, "%d", &val) > 0) {
		switch (val){
		perf_level_wrapper(0, 1, PERF_LOCK_LOWEST);
		perf_level_wrapper(2, 3, PERF_LOCK_LOW);
		perf_level_wrapper(4, 5, PERF_LOCK_MEDIUM);
		perf_level_wrapper(6, 7, PERF_LOCK_HIGH);
		perf_level_wrapper(8, 9, PERF_LOCK_HIGHEST);
		default:
			/* no matching level found */
			break;
		}
		return n;
	}
	return -EINVAL;
}