All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/6] drivers/misc/sgi-xp: convert nested spin_lock_irqsave
@ 2009-07-18 15:23 ` Julia Lawall
  0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2009-07-18 15:23 UTC (permalink / raw)
  To: holt, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

If spin_lock_irqsave is called twice in a row with the same second
argument, the interrupt state at the point of the second call overwrites
the value saved by the first call.  Indeed, the second call does not need
to save the interrupt state, so it is changed to a simple spin_lock.

The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression lock1,lock2;
expression flags;
@@

*spin_lock_irqsave(lock1,flags)
... when != flags
*spin_lock_irqsave(lock2,flags)
// </smpl>

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

---
 drivers/misc/sgi-xp/xpc_uv.c        |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index c76677a..d0052ad 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -443,9 +443,9 @@ xpc_handle_activate_mq_msg_uv(struct xpc_partition *part,
 
 		if (msg->activate_gru_mq_desc_gpa ! 		    part_uv->activate_gru_mq_desc_gpa) {
-			spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
+			spin_lock(&part_uv->flags_lock);
 			part_uv->flags &= ~XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV;
-			spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags);
+			spin_unlock(&part_uv->flags_lock);
 			part_uv->activate_gru_mq_desc_gpa  			    msg->activate_gru_mq_desc_gpa;
 		}

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

* [PATCH 3/6] drivers/misc/sgi-xp: convert nested spin_lock_irqsave to spin_lock
@ 2009-07-18 15:23 ` Julia Lawall
  0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2009-07-18 15:23 UTC (permalink / raw)
  To: holt, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

If spin_lock_irqsave is called twice in a row with the same second
argument, the interrupt state at the point of the second call overwrites
the value saved by the first call.  Indeed, the second call does not need
to save the interrupt state, so it is changed to a simple spin_lock.

The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression lock1,lock2;
expression flags;
@@

*spin_lock_irqsave(lock1,flags)
... when != flags
*spin_lock_irqsave(lock2,flags)
// </smpl>

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

---
 drivers/misc/sgi-xp/xpc_uv.c        |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index c76677a..d0052ad 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -443,9 +443,9 @@ xpc_handle_activate_mq_msg_uv(struct xpc_partition *part,
 
 		if (msg->activate_gru_mq_desc_gpa !=
 		    part_uv->activate_gru_mq_desc_gpa) {
-			spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
+			spin_lock(&part_uv->flags_lock);
 			part_uv->flags &= ~XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV;
-			spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags);
+			spin_unlock(&part_uv->flags_lock);
 			part_uv->activate_gru_mq_desc_gpa =
 			    msg->activate_gru_mq_desc_gpa;
 		}

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

* Re: [PATCH 3/6] drivers/misc/sgi-xp: convert nested
  2009-07-18 15:23 ` [PATCH 3/6] drivers/misc/sgi-xp: convert nested spin_lock_irqsave to spin_lock Julia Lawall
@ 2009-07-18 23:20   ` Robin Holt
  -1 siblings, 0 replies; 6+ messages in thread
From: Robin Holt @ 2009-07-18 23:20 UTC (permalink / raw)
  To: Julia Lawall; +Cc: holt, linux-kernel, kernel-janitors

On Sat, Jul 18, 2009 at 05:23:57PM +0200, Julia Lawall wrote:
> -			spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
> +			spin_lock(&part_uv->flags_lock);
>  			part_uv->flags &= ~XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV;

Please do not change this.

I think this is a false positive to a automated script.  We are not
comparing against the processors irq flags, but rather against the
partitions flags.  Note above the difference between irq_flags and
part_uv->flags.

Maybe I misunderstand your point in this patch.

Robin

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

* Re: [PATCH 3/6] drivers/misc/sgi-xp: convert nested spin_lock_irqsave to spin_lock
@ 2009-07-18 23:20   ` Robin Holt
  0 siblings, 0 replies; 6+ messages in thread
From: Robin Holt @ 2009-07-18 23:20 UTC (permalink / raw)
  To: Julia Lawall; +Cc: holt, linux-kernel, kernel-janitors

On Sat, Jul 18, 2009 at 05:23:57PM +0200, Julia Lawall wrote:
> -			spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
> +			spin_lock(&part_uv->flags_lock);
>  			part_uv->flags &= ~XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV;

Please do not change this.

I think this is a false positive to a automated script.  We are not
comparing against the processors irq flags, but rather against the
partitions flags.  Note above the difference between irq_flags and
part_uv->flags.

Maybe I misunderstand your point in this patch.

Robin

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

* Re: [PATCH 3/6] drivers/misc/sgi-xp: convert nested
  2009-07-18 15:23 ` [PATCH 3/6] drivers/misc/sgi-xp: convert nested spin_lock_irqsave to spin_lock Julia Lawall
@ 2009-07-18 23:33   ` Robin Holt
  -1 siblings, 0 replies; 6+ messages in thread
From: Robin Holt @ 2009-07-18 23:33 UTC (permalink / raw)
  To: Julia Lawall; +Cc: holt, linux-kernel, kernel-janitors

You reason description confused me at first.  After looking closer at
the code, I understand and agree.

Acked-by: Robin Holt <holt@sgi.com>

On Sat, Jul 18, 2009 at 05:23:57PM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> If spin_lock_irqsave is called twice in a row with the same second
> argument, the interrupt state at the point of the second call overwrites
> the value saved by the first call.  Indeed, the second call does not need
> to save the interrupt state, so it is changed to a simple spin_lock.
> 
> The semantic match that finds this problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
> 
> // <smpl>
> @@
> expression lock1,lock2;
> expression flags;
> @@
> 
> *spin_lock_irqsave(lock1,flags)
> ... when != flags
> *spin_lock_irqsave(lock2,flags)
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 
> ---
>  drivers/misc/sgi-xp/xpc_uv.c        |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
> index c76677a..d0052ad 100644
> --- a/drivers/misc/sgi-xp/xpc_uv.c
> +++ b/drivers/misc/sgi-xp/xpc_uv.c
> @@ -443,9 +443,9 @@ xpc_handle_activate_mq_msg_uv(struct xpc_partition *part,
>  
>  		if (msg->activate_gru_mq_desc_gpa !>  		    part_uv->activate_gru_mq_desc_gpa) {
> -			spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
> +			spin_lock(&part_uv->flags_lock);
>  			part_uv->flags &= ~XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV;
> -			spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags);
> +			spin_unlock(&part_uv->flags_lock);
>  			part_uv->activate_gru_mq_desc_gpa >  			    msg->activate_gru_mq_desc_gpa;
>  		}
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 3/6] drivers/misc/sgi-xp: convert nested spin_lock_irqsave to spin_lock
@ 2009-07-18 23:33   ` Robin Holt
  0 siblings, 0 replies; 6+ messages in thread
From: Robin Holt @ 2009-07-18 23:33 UTC (permalink / raw)
  To: Julia Lawall; +Cc: holt, linux-kernel, kernel-janitors

You reason description confused me at first.  After looking closer at
the code, I understand and agree.

Acked-by: Robin Holt <holt@sgi.com>

On Sat, Jul 18, 2009 at 05:23:57PM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> If spin_lock_irqsave is called twice in a row with the same second
> argument, the interrupt state at the point of the second call overwrites
> the value saved by the first call.  Indeed, the second call does not need
> to save the interrupt state, so it is changed to a simple spin_lock.
> 
> The semantic match that finds this problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
> 
> // <smpl>
> @@
> expression lock1,lock2;
> expression flags;
> @@
> 
> *spin_lock_irqsave(lock1,flags)
> ... when != flags
> *spin_lock_irqsave(lock2,flags)
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 
> ---
>  drivers/misc/sgi-xp/xpc_uv.c        |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
> index c76677a..d0052ad 100644
> --- a/drivers/misc/sgi-xp/xpc_uv.c
> +++ b/drivers/misc/sgi-xp/xpc_uv.c
> @@ -443,9 +443,9 @@ xpc_handle_activate_mq_msg_uv(struct xpc_partition *part,
>  
>  		if (msg->activate_gru_mq_desc_gpa !=
>  		    part_uv->activate_gru_mq_desc_gpa) {
> -			spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
> +			spin_lock(&part_uv->flags_lock);
>  			part_uv->flags &= ~XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV;
> -			spin_unlock_irqrestore(&part_uv->flags_lock, irq_flags);
> +			spin_unlock(&part_uv->flags_lock);
>  			part_uv->activate_gru_mq_desc_gpa =
>  			    msg->activate_gru_mq_desc_gpa;
>  		}
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

end of thread, other threads:[~2009-07-18 23:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-18 15:23 [PATCH 3/6] drivers/misc/sgi-xp: convert nested spin_lock_irqsave Julia Lawall
2009-07-18 15:23 ` [PATCH 3/6] drivers/misc/sgi-xp: convert nested spin_lock_irqsave to spin_lock Julia Lawall
2009-07-18 23:20 ` [PATCH 3/6] drivers/misc/sgi-xp: convert nested Robin Holt
2009-07-18 23:20   ` [PATCH 3/6] drivers/misc/sgi-xp: convert nested spin_lock_irqsave to spin_lock Robin Holt
2009-07-18 23:33 ` [PATCH 3/6] drivers/misc/sgi-xp: convert nested Robin Holt
2009-07-18 23:33   ` [PATCH 3/6] drivers/misc/sgi-xp: convert nested spin_lock_irqsave to spin_lock Robin Holt

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.