Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b06ac86 authored by H. Peter Anvin's avatar H. Peter Anvin Committed by Ingo Molnar
Browse files

x86: cpuid, msr: use inode mutex instead of big kernel lock



Instead of grabbing the BKL on seek, use the inode mutex in the style
of generic_file_llseek().

Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 2347d933
Loading
Loading
Loading
Loading
+3 −4
Original line number Original line Diff line number Diff line
@@ -62,9 +62,9 @@ static void cpuid_smp_cpuid(void *cmd_block)
static loff_t cpuid_seek(struct file *file, loff_t offset, int orig)
static loff_t cpuid_seek(struct file *file, loff_t offset, int orig)
{
{
	loff_t ret;
	loff_t ret;
	struct inode *inode = file->f_mapping->host;


	lock_kernel();
	mutex_lock(&inode->i_mutex);

	switch (orig) {
	switch (orig) {
	case 0:
	case 0:
		file->f_pos = offset;
		file->f_pos = offset;
@@ -77,8 +77,7 @@ static loff_t cpuid_seek(struct file *file, loff_t offset, int orig)
	default:
	default:
		ret = -EINVAL;
		ret = -EINVAL;
	}
	}

	mutex_unlock(&inode->i_mutex);
	unlock_kernel();
	return ret;
	return ret;
}
}


+9 −5
Original line number Original line Diff line number Diff line
/* ----------------------------------------------------------------------- *
/* ----------------------------------------------------------------------- *
 *
 *
 *   Copyright 2000 H. Peter Anvin - All Rights Reserved
 *   Copyright 2000-2008 H. Peter Anvin - All Rights Reserved
 *
 *
 *   This program is free software; you can redistribute it and/or modify
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   it under the terms of the GNU General Public License as published by
@@ -45,9 +45,10 @@ static struct class *msr_class;


static loff_t msr_seek(struct file *file, loff_t offset, int orig)
static loff_t msr_seek(struct file *file, loff_t offset, int orig)
{
{
	loff_t ret = -EINVAL;
	loff_t ret;
	struct inode *inode = file->f_mapping->host;


	lock_kernel();
	mutex_lock(&inode->i_mutex);
	switch (orig) {
	switch (orig) {
	case 0:
	case 0:
		file->f_pos = offset;
		file->f_pos = offset;
@@ -56,8 +57,11 @@ static loff_t msr_seek(struct file *file, loff_t offset, int orig)
	case 1:
	case 1:
		file->f_pos += offset;
		file->f_pos += offset;
		ret = file->f_pos;
		ret = file->f_pos;
		break;
	default:
		ret = -EINVAL;
	}
	}
	unlock_kernel();
	mutex_unlock(&inode->i_mutex);
	return ret;
	return ret;
}
}