Skip to contentSkip to conversation

sched_rt: change spinlock primitive in post_schedule_rt()

PATCH New Jupyung Lee 1 participant 1 message Nov 16, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched_rt: change spinlock primitive in post_schedule_rt()

A problem is that after finishing post_schedule_rt(), interrupt is always re-enabled regardless of the previous condition. In practice, the function post_schedule_rt() is called by finish_task_switch() with the interrupt disabled. Thus, the interrupt should not be re-enabled at the moment.

The problem can simply be resolved by replacing atomic_spin_lock_irq() and atomic_spin_unlock_irq() with atomic_spin_lock_irqsave() and atomic_spin_unlock_irqrestore().

As a sidenote, the other way to resolve the problem might be to modify codes in accordance with commit 3f029d3c6d62068d59301d90c18dbde8ee402107, titled "sched: Enhance the pre/post scheduling logic", in the vanilla tree.

---
 kernel/sched_rt.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
kernel/sched_rt.c +3 -2
index 274c976..bd16998 100644
@@ -1536,9 +1536,10 @@ static void post_schedule_rt(struct rq *rq)
 	 * This is only called if needs_post_schedule_rt() indicates that
 	 * we need to push tasks away
 	 */
-	atomic_spin_lock_irq(&rq->lock);
+	unsigned long flags;
+	atomic_spin_lock_irqsave(&rq->lock, flags);
 	push_rt_tasks(rq);
-	atomic_spin_unlock_irq(&rq->lock);
+	atomic_spin_unlock_irqrestore(&rq->lock, flags);
 }
 
 /*
Signature · 1 line
1.6.5.GIT