Skip to contentSkip to conversation

Fix XPC code which sleeps with spin_lock_irqsave().

PATCH In review Robin Holt 1 participant 2 messages Feb 1, 2006 – Feb 2, 2006

lore
Share & tools
lore

Robin Holt

author
#0 lore raw

PATCH 1/1 Fix XPC code which sleeps with spin_lock_irqsave().

During some testing, we got a warning about trying to allocate memory while holding a lock. This fixes that problem.

Index: linux-2.6/arch/ia64/sn/kernel/xpc_main.c
=================================--- linux-2.6.orig/arch/ia64/sn/kernel/xpc_main.c 2006-02-01 07:26:10.156287841 -0600
+++ linux-2.6/arch/ia64/sn/kernel/xpc_main.c 2006-02-01 07:29:04.463443840 -0600
@@ -575,14 +575,19 @@ xpc_activate_partition(struct xpc_partit

spin_lock_irqsave(&part->act_lock, irq_flags);

+ DBUG_ON(part->act_state != XPC_P_INACTIVE);
+
+ part->act_state = XPC_P_ACTIVATION_REQ;
+ XPC_SET_REASON(part, xpcCloneKThread, __LINE__);
+
+ spin_unlock_irqrestore(&part->act_lock, irq_flags);
+
pid = kernel_thread(xpc_activating, (void *) ((u64) partid), 0);

- DBUG_ON(part->act_state != XPC_P_INACTIVE);
+ spin_lock_irqsave(&part->act_lock, irq_flags);

- if (pid > 0) {
- part->act_state = XPC_P_ACTIVATION_REQ;
- XPC_SET_REASON(part, xpcCloneKThread, __LINE__);
- } else {
+ if (pid <= 0) {
+ part->act_state = XPC_P_INACTIVE;
XPC_SET_REASON(part, xpcCloneKThreadFailed, __LINE__);
}

author Acked-by Dean Nelson on v1 1/1
#1 lore raw

During some testing, we got a warning about trying to allocate memory while holding a lock. This fixes that problem.

----

This replaces the patch I sent yesterday. Dean pointed out that the spin_lock_irqsave does not need to happen when the kernel_thread succeeds. Tony, If you have not already taken either of the patches, please use this one instead.

Index: linux-2.6/arch/ia64/sn/kernel/xpc_main.c
=================================--- linux-2.6.orig/arch/ia64/sn/kernel/xpc_main.c 2006-02-01 07:26:10.156287841 -0600
+++ linux-2.6/arch/ia64/sn/kernel/xpc_main.c 2006-02-02 07:25:25.611646908 -0600
@@ -575,18 +575,21 @@ xpc_activate_partition(struct xpc_partit

spin_lock_irqsave(&part->act_lock, irq_flags);

- pid = kernel_thread(xpc_activating, (void *) ((u64) partid), 0);
-
DBUG_ON(part->act_state != XPC_P_INACTIVE);

- if (pid > 0) {
- part->act_state = XPC_P_ACTIVATION_REQ;
- XPC_SET_REASON(part, xpcCloneKThread, __LINE__);
- } else {
- XPC_SET_REASON(part, xpcCloneKThreadFailed, __LINE__);
- }
+ part->act_state = XPC_P_ACTIVATION_REQ;
+ XPC_SET_REASON(part, xpcCloneKThread, __LINE__);

spin_unlock_irqrestore(&part->act_lock, irq_flags);
+
+ pid = kernel_thread(xpc_activating, (void *) ((u64) partid), 0);
+
+ if (unlikely(pid <= 0)) {
+ spin_lock_irqsave(&part->act_lock, irq_flags);
+ part->act_state = XPC_P_INACTIVE;
+ XPC_SET_REASON(part, xpcCloneKThreadFailed, __LINE__);
+ spin_unlock_irqrestore(&part->act_lock, irq_flags);
+ }
}