All of lore.kernel.org
 help / color / mirror / Atom feed
* 2.6.5-rc2-mm2 ipc hang fix
@ 2004-03-26  1:53 badari
  2004-03-26  5:57 ` Manfred Spraul
  0 siblings, 1 reply; 4+ messages in thread
From: badari @ 2004-03-26  1:53 UTC (permalink / raw)
  To: andrew, lkml, manfred

Hi Andrew,

I ran into ipc hang while trying to shutdown database. Problem seems
to be due to missing sem_unlock() in find_undo(). Here is the patch
to fix the problem.

Please apply.

Thanks,
Badari

--- linux/ipc/sem.c     2004-03-26 05:19:22.833959160 -0800
+++ linux.new/ipc/sem.c 2004-03-26 05:19:57.047757872 -0800
@@ -972,8 +972,10 @@ static struct sem_undo *find_undo(int se
        if(sma==NULL)
                goto out;
        un = ERR_PTR(-EIDRM);
-       if (sem_checkid(sma,semid))
+       if (sem_checkid(sma,semid)) {
+               sem_unlock(sma);
                goto out_unlock;
+       }
        nsems = sma->sem_nsems;
        sem_unlock(sma);




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 2.6.5-rc2-mm2 ipc hang fix
  2004-03-26  1:53 2.6.5-rc2-mm2 ipc hang fix badari
@ 2004-03-26  5:57 ` Manfred Spraul
  2004-03-26 17:16   ` Badari Pulavarty
  2004-03-26 17:36   ` 2.6.5-rc2-mm2 ipc hang fix (final version) Badari Pulavarty
  0 siblings, 2 replies; 4+ messages in thread
From: Manfred Spraul @ 2004-03-26  5:57 UTC (permalink / raw)
  To: badari; +Cc: andrew, lkml

badari wrote:

>--- linux/ipc/sem.c     2004-03-26 05:19:22.833959160 -0800
>+++ linux.new/ipc/sem.c 2004-03-26 05:19:57.047757872 -0800
>@@ -972,8 +972,10 @@ static struct sem_undo *find_undo(int se
>        if(sma==NULL)
>                goto out;
>        un = ERR_PTR(-EIDRM);
>-       if (sem_checkid(sma,semid))
>+       if (sem_checkid(sma,semid)) {
>+               sem_unlock(sma);
>                goto out_unlock;
>+       }
>        nsems = sma->sem_nsems;
>        sem_unlock(sma);
>  
>
[snip]

> out_unlock:
>         unlock_semundo();
> out:
>         return un;
> }

Thanks for finding the bug - out_unlock unlocks the wrong spinlock, 
that's why I didn't notice it while searching for the bug.
But I think your fix is wrong: the "goto out_unlock" must be replaced 
with "goto out": the semundo spinlock is not held.

--
    Manfred


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 2.6.5-rc2-mm2 ipc hang fix
  2004-03-26  5:57 ` Manfred Spraul
@ 2004-03-26 17:16   ` Badari Pulavarty
  2004-03-26 17:36   ` 2.6.5-rc2-mm2 ipc hang fix (final version) Badari Pulavarty
  1 sibling, 0 replies; 4+ messages in thread
From: Badari Pulavarty @ 2004-03-26 17:16 UTC (permalink / raw)
  To: Manfred Spraul; +Cc: andrew, lkml

[-- Attachment #1: Type: text/plain, Size: 1060 bytes --]

On Thursday 25 March 2004 09:57 pm, Manfred Spraul wrote:
> badari wrote:
> >--- linux/ipc/sem.c     2004-03-26 05:19:22.833959160 -0800
> >+++ linux.new/ipc/sem.c 2004-03-26 05:19:57.047757872 -0800
> >@@ -972,8 +972,10 @@ static struct sem_undo *find_undo(int se
> >        if(sma==NULL)
> >                goto out;
> >        un = ERR_PTR(-EIDRM);
> >-       if (sem_checkid(sma,semid))
> >+       if (sem_checkid(sma,semid)) {
> >+               sem_unlock(sma);
> >                goto out_unlock;
> >+       }
> >        nsems = sma->sem_nsems;
> >        sem_unlock(sma);
>
> [snip]
>
> > out_unlock:
> >         unlock_semundo();
> > out:
> >         return un;
> > }
>
> Thanks for finding the bug - out_unlock unlocks the wrong spinlock,
> that's why I didn't notice it while searching for the bug.
> But I think your fix is wrong: the "goto out_unlock" must be replaced
> with "goto out": the semundo spinlock is not held.

Yes. You are correct. semundo lock is not held. 
Here is the updated patch.

Thanks,
Badari

[-- Attachment #2: undo.patch --]
[-- Type: text/x-diff, Size: 397 bytes --]

--- linux/ipc/sem.c	2004-03-26 05:19:22.833959160 -0800
+++ linux.new/ipc/sem.c	2004-03-26 20:59:46.496258680 -0800
@@ -972,8 +972,10 @@ static struct sem_undo *find_undo(int se
 	if(sma==NULL)
 		goto out;
 	un = ERR_PTR(-EIDRM);
-	if (sem_checkid(sma,semid))
-		goto out_unlock;
+	if (sem_checkid(sma,semid)) {
+		sem_unlock(sma);
+		goto out;
+	}
 	nsems = sma->sem_nsems;
 	sem_unlock(sma);
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 2.6.5-rc2-mm2 ipc hang fix (final version)
  2004-03-26  5:57 ` Manfred Spraul
  2004-03-26 17:16   ` Badari Pulavarty
@ 2004-03-26 17:36   ` Badari Pulavarty
  1 sibling, 0 replies; 4+ messages in thread
From: Badari Pulavarty @ 2004-03-26 17:36 UTC (permalink / raw)
  To: Manfred Spraul; +Cc: andrew, lkml

[-- Attachment #1: Type: text/plain, Size: 130 bytes --]

Hi,

Here is the final version. I missed a compile warning before.
out_unlock label is no longer needed.

Thanks,
Badari


[-- Attachment #2: undo.patch --]
[-- Type: text/x-diff, Size: 562 bytes --]

--- linux/ipc/sem.c	2004-03-26 05:19:22.833959160 -0800
+++ linux.new/ipc/sem.c	2004-03-26 21:18:28.424699632 -0800
@@ -972,8 +972,10 @@ static struct sem_undo *find_undo(int se
 	if(sma==NULL)
 		goto out;
 	un = ERR_PTR(-EIDRM);
-	if (sem_checkid(sma,semid))
-		goto out_unlock;
+	if (sem_checkid(sma,semid)) {
+		sem_unlock(sma);
+		goto out;
+	}
 	nsems = sma->sem_nsems;
 	sem_unlock(sma);
 
@@ -1004,7 +1006,6 @@ static struct sem_undo *find_undo(int se
 	sma->undo = new;
 	sem_unlock(sma);
 	un = new;
-out_unlock:
 	unlock_semundo();
 out:
 	return un;

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-03-26 17:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-26  1:53 2.6.5-rc2-mm2 ipc hang fix badari
2004-03-26  5:57 ` Manfred Spraul
2004-03-26 17:16   ` Badari Pulavarty
2004-03-26 17:36   ` 2.6.5-rc2-mm2 ipc hang fix (final version) Badari Pulavarty

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.