Skip to contentSkip to conversation

drivers/misc/sgi-xp/xpc_uv.c: convert nested spin_lock_irqsave to spin_lock

PATCH In review Julia Lawall 2 participants 2 messages Oct 19, 2010 – Oct 20, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/4 drivers/misc/sgi-xp/xpc_uv.c: convert nested spin_lock_irqsave to spin_lock

From: Julia Lawall <[email protected]>

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://coccinelle.lip6.fr/)

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

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

---
 drivers/misc/sgi-xp/xpc_uv.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/sgi-xp/xpc_uv.c +2 -2
index 1f59ee2..7aeaef7 100644
@@ -451,9 +451,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;
 		}
Acked-by on v1 4/4
#1 lore raw
Quoted 16 lines · Julia Lawall

From: Julia Lawall <[email protected]>

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://coccinelle.lip6.fr/)

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

Quoted 6 lines

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

Quoted 25 lines
---
 drivers/misc/sgi-xp/xpc_uv.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/sgi-xp/xpc_uv.c +2 -3
index 1f59ee2..7aeaef7 100644
@@ -451,9 +451,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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/