linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] arch/sh/mm: Eliminate a double lock
@ 2010-06-20 11:24 Julia Lawall
  2010-06-20 13:51 ` Matt Fleming
  2010-06-21  3:58 ` Paul Mundt
  0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2010-06-20 11:24 UTC (permalink / raw)
  To: Paul Mundt, linux-sh, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

The function begins and ends with a read_lock.  The latter is changed to a
read_unlock.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@locked@
expression E1;
position p;
@@

read_lock(E1@p,...);

@r exists@
expression x <= locked.E1;
expression locked.E1;
expression E2;
identifier lock;
position locked.p,p1,p2;
@@

*lock@p1 (E1@p,...);
... when != E1
    when != \(x = E2\|&x\)
*lock@p2 (E1,...);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
Not tested

 arch/sh/mm/pmb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sh/mm/pmb.c b/arch/sh/mm/pmb.c
index 18623ba..6379091 100644
--- a/arch/sh/mm/pmb.c
+++ b/arch/sh/mm/pmb.c
@@ -770,7 +770,7 @@ static void __init pmb_resize(void)
 		spin_unlock_irqrestore(&pmbe->lock, flags);
 	}
 
-	read_lock(&pmb_rwlock);
+	read_unlock(&pmb_rwlock);
 }
 #endif
 

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

* Re: [PATCH 2/2] arch/sh/mm: Eliminate a double lock
  2010-06-20 11:24 [PATCH 2/2] arch/sh/mm: Eliminate a double lock Julia Lawall
@ 2010-06-20 13:51 ` Matt Fleming
  2010-06-21  3:58 ` Paul Mundt
  1 sibling, 0 replies; 3+ messages in thread
From: Matt Fleming @ 2010-06-20 13:51 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Paul Mundt, linux-sh, linux-kernel, kernel-janitors

On Sun, 20 Jun 2010 13:24:54 +0200 (CEST), Julia Lawall <julia@diku.dk> wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> The function begins and ends with a read_lock.  The latter is changed to a
> read_unlock.

I think we've been quite lucky here so far, in that no one takes a
write_lock after we've double-read-locked pmb_rwlock.

Acked-by: Matt Fleming <matt@console-pimps.org>

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

* Re: [PATCH 2/2] arch/sh/mm: Eliminate a double lock
  2010-06-20 11:24 [PATCH 2/2] arch/sh/mm: Eliminate a double lock Julia Lawall
  2010-06-20 13:51 ` Matt Fleming
@ 2010-06-21  3:58 ` Paul Mundt
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Mundt @ 2010-06-21  3:58 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-sh, linux-kernel, kernel-janitors

On Sun, Jun 20, 2010 at 01:24:54PM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> The function begins and ends with a read_lock.  The latter is changed to a
> read_unlock.
> 
Indeed, good catch. Applied, thanks.

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

end of thread, other threads:[~2010-06-21  3:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-20 11:24 [PATCH 2/2] arch/sh/mm: Eliminate a double lock Julia Lawall
2010-06-20 13:51 ` Matt Fleming
2010-06-21  3:58 ` Paul Mundt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).