Skip to contentSkip to conversation

nvram: Drop the bkl from nvram_llseek()

PATCH In review Frederic Weisbecker 2 participants 4 messages Oct 9, 2009 – Oct 14, 2009 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvram: Drop the bkl from nvram_llseek()

There is nothing to protect inside nvram_llseek(), the file offset doesn't need to be protected and nvram_len is only initialized from an __init path.

It's safe to remove the big kernel lock there.

(Is this file still used? I can't even build it, looks like it is built under CONFIG_GENERIC_NVRAM but this option is referenced nowhere except in powerpc defconfigs)

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc John Kacur <[email protected]>
Cc Sven-Thorsten Dietrich <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Alessio Igor Bogani <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Greg KH <[email protected]>
---
 drivers/char/generic_nvram.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
drivers/char/generic_nvram.c +3 -5
index ef31738..c49200e 100644
@@ -32,7 +32,6 @@ static ssize_t nvram_len;
 
 static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
 {
-	lock_kernel();
 	switch (origin) {
 	case 1:
 		offset += file->f_pos;
@@ -41,12 +40,11 @@ static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
 		offset += nvram_len;
 		break;
 	}
-	if (offset < 0) {
-		unlock_kernel();
+	if (offset < 0)
 		return -EINVAL;
-	}
+
 	file->f_pos = offset;
-	unlock_kernel();
+
 	return file->f_pos;
 }
 
Signature · 1 line
1.6.2.3
#1 lore raw
Quoted 9 lines · Frederic Weisbecker

There is nothing to protect inside nvram_llseek(), the file offset doesn't need to be protected and nvram_len is only initialized from an __init path.

It's safe to remove the big kernel lock there.

(Is this file still used? I can't even build it, looks like it is built under CONFIG_GENERIC_NVRAM but this option is referenced nowhere except in powerpc defconfigs)

Yes it is used. Look at arch/powerpc/Kconfig

config GENERIC_NVRAM
bool
default y if PPC32

But I have to admit that the GENERIC part is confusing :)

Quoted 9 lines
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc John Kacur <[email protected]>
Cc Sven-Thorsten Dietrich <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Alessio Igor Bogani <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Greg KH <[email protected]>

Added to the pile of pending BKL bashing. Thanks,

tglx

Quoted 35 lines
---
 drivers/char/generic_nvram.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
drivers/char/generic_nvram.c +3 -5
index ef31738..c49200e 100644
@@ -32,7 +32,6 @@ static ssize_t nvram_len;
 
 static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
 {
-	lock_kernel();
 	switch (origin) {
 	case 1:
 		offset += file->f_pos;
@@ -41,12 +40,11 @@ static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
 		offset += nvram_len;
 		break;
 	}
-	if (offset < 0) {
-		unlock_kernel();
+	if (offset < 0)
 		return -EINVAL;
-	}
+
 	file->f_pos = offset;
-	unlock_kernel();
+
 	return file->f_pos;
 }
 
Signature · 1 line
1.6.2.3
#2 lore raw
Quoted 12 lines · Thomas Gleixner
Quoted 9 lines · Frederic Weisbecker

There is nothing to protect inside nvram_llseek(), the file offset doesn't need to be protected and nvram_len is only initialized from an __init path.

It's safe to remove the big kernel lock there.

(Is this file still used? I can't even build it, looks like it is built under CONFIG_GENERIC_NVRAM but this option is referenced nowhere except in powerpc defconfigs)

Quoted 5 lines

Yes it is used. Look at arch/powerpc/Kconfig

config GENERIC_NVRAM
bool
default y if PPC32

Oh right, I missed it.

Quoted 1 line

But I have to admit that the GENERIC part is confusing :)

Yep :)

Quoted 10 lines
Quoted 9 lines
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc John Kacur <[email protected]>
Cc Sven-Thorsten Dietrich <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Alessio Igor Bogani <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Greg KH <[email protected]>
Quoted 3 lines

Added to the pile of pending BKL bashing. Thanks,

tglx

Ok. Be care I couldn't even build test this one.

Thanks.

#3 lore raw
In reply to Frederic Weisbecker
Commit-ID:  6783b9cd7104470a3afab51c205c5aea53a2858f
Gitweb:     http://git.kernel.org/tip/6783b9cd7104470a3afab51c205c5aea53a2858f
Author:     Frederic Weisbecker <[email protected]>
AuthorDate: Fri, 9 Oct 2009 21:20:30 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Wed, 14 Oct 2009 17:36:49 +0200

nvram: Drop the bkl from nvram_llseek()

There is nothing to protect inside nvram_llseek(), the file offset doesn't need to be protected and nvram_len is only initialized from an __init path.

It's safe to remove the big kernel lock there.

LKML-Reference: <[email protected]>

---
 drivers/char/generic_nvram.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/char/generic_nvram.c +3 -6
index ef31738..fda4181 100644
@@ -19,7 +19,6 @@
 #include <linux/miscdevice.h>
 #include <linux/fcntl.h>
 #include <linux/init.h>
-#include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <asm/nvram.h>
 #ifdef CONFIG_PPC_PMAC
@@ -32,7 +31,6 @@ static ssize_t nvram_len;
 
 static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
 {
-	lock_kernel();
 	switch (origin) {
 	case 1:
 		offset += file->f_pos;
@@ -41,12 +39,11 @@ static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
 		offset += nvram_len;
 		break;
 	}
-	if (offset < 0) {
-		unlock_kernel();
+	if (offset < 0)
 		return -EINVAL;
-	}
+
 	file->f_pos = offset;
-	unlock_kernel();
+
 	return file->f_pos;
 }