OpenVZ Forum


Home » Mailing lists » Devel » [PATCH] proc: use BUG_ON() in de_put()
[PATCH] proc: use BUG_ON() in de_put() [message #23339] Thu, 15 November 2007 16:12 Go to next message
Alexey Dobriyan is currently offline  Alexey Dobriyan
Messages: 195
Registered: August 2006
Senior Member
It's much more visible that some printk. I still has an unexplained oops
in proc, so let's leave it for a while.

Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
---

 fs/proc/inode.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -37,12 +37,7 @@ void de_put(struct proc_dir_entry *de)
 {
 	if (de) {	
 		lock_kernel();		
-		if (!atomic_read(&de->count)) {
-			printk("de_put: entry %s already free!\n", de->name);
-			unlock_kernel();
-			return;
-		}
-
+		BUG_ON(atomic_read(&de->count) == 0);
 		if (atomic_dec_and_test(&de->count)) {
 			if (de->deleted) {
 				printk("de_put: deferred delete of %s\n",
Re: [PATCH] proc: use BUG_ON() in de_put() [message #23449 is a reply to message #23339] Fri, 16 November 2007 21:46 Go to previous messageGo to next message
akpm is currently offline  akpm
Messages: 224
Registered: March 2007
Senior Member
On Thu, 15 Nov 2007 19:12:49 +0300
Alexey Dobriyan <adobriyan@sw.ru> wrote:

> It's much more visible that some printk. I still has an unexplained oops
> in proc, so let's leave it for a while.
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
> ---
> 
>  fs/proc/inode.c |    7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> --- a/fs/proc/inode.c
> +++ b/fs/proc/inode.c
> @@ -37,12 +37,7 @@ void de_put(struct proc_dir_entry *de)
>  {
>  	if (de) {	
>  		lock_kernel();		
> -		if (!atomic_read(&de->count)) {
> -			printk("de_put: entry %s already free!\n", de->name);
> -			unlock_kernel();
> -			return;
> -		}
> -
> +		BUG_ON(atomic_read(&de->count) == 0);
>  		if (atomic_dec_and_test(&de->count)) {
>  			if (de->deleted) {
>  				printk("de_put: deferred delete of %s\n",

I don't see that an error in here _requires_ that we nuke the machine. 
Surely we can emit a warning and then recover in some fashion?
Re: [PATCH] proc: use BUG_ON() in de_put() [message #23684 is a reply to message #23449] Thu, 22 November 2007 08:49 Go to previous message
Alexey Dobriyan is currently offline  Alexey Dobriyan
Messages: 195
Registered: August 2006
Senior Member
On Fri, Nov 16, 2007 at 01:46:42PM -0800, Andrew Morton wrote:
> On Thu, 15 Nov 2007 19:12:49 +0300
> Alexey Dobriyan <adobriyan@sw.ru> wrote:
> 
> > It's much more visible that some printk. I still has an unexplained oops
> > in proc, so let's leave it for a while.

> > --- a/fs/proc/inode.c
> > +++ b/fs/proc/inode.c
> > @@ -37,12 +37,7 @@ void de_put(struct proc_dir_entry *de)
> >  {
> >  	if (de) {	
> >  		lock_kernel();		
> > -		if (!atomic_read(&de->count)) {
> > -			printk("de_put: entry %s already free!\n", de->name);
> > -			unlock_kernel();
> > -			return;
> > -		}
> > -
> > +		BUG_ON(atomic_read(&de->count) == 0);
> >  		if (atomic_dec_and_test(&de->count)) {
> >  			if (de->deleted) {
> >  				printk("de_put: deferred delete of %s\n",
> 
> I don't see that an error in here _requires_ that we nuke the machine. 
> Surely we can emit a warning and then recover in some fashion?

Hmm... atomic_dec_and_test() in -mm already has diagnostics¹ when doing
0 => -1 transition, google says this check triggered only once. I think
we should just drop it.

¹ i386 only :^)
Previous Topic: [PATCH 1/1] capabilities: introduce per-process capability bounding set (v8)
Next Topic: [PATCH][IRDA] Compilation for CONFIG_INET=n case
Goto Forum:
  


Current Time: Sun Oct 13 04:23:35 GMT 2024

Total time taken to generate the page: 0.06382 seconds