diff mbox series

[RFC,02/10] sched: rt: save IRQ state during locking

Message ID 20210223023428.757694-3-volodymyr_babchuk@epam.com (mailing list archive)
State New
Headers show
Series Preemption in hypervisor (ARM only) | expand

Commit Message

Volodymyr Babchuk Feb. 23, 2021, 2:34 a.m. UTC
With XEN preemption enabled, scheduler functions can be called with
IRQs disabled (for example, at end of IRQ handler), so we should
save and restore IRQ state in schedulers code.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
---
 xen/common/sched/rt.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/xen/common/sched/rt.c b/xen/common/sched/rt.c
index c24cd2ac32..e1711a8edc 100644
--- a/xen/common/sched/rt.c
+++ b/xen/common/sched/rt.c
@@ -1318,7 +1318,8 @@  static void
 rt_context_saved(const struct scheduler *ops, struct sched_unit *unit)
 {
     struct rt_unit *svc = rt_unit(unit);
-    spinlock_t *lock = unit_schedule_lock_irq(unit);
+    unsigned long flags;
+    spinlock_t *lock = unit_schedule_lock_irqsave(unit, &flags);
 
     __clear_bit(__RTDS_scheduled, &svc->flags);
     /* not insert idle unit to runq */
@@ -1335,7 +1336,7 @@  rt_context_saved(const struct scheduler *ops, struct sched_unit *unit)
         replq_remove(ops, svc);
 
 out:
-    unit_schedule_unlock_irq(lock, unit);
+    unit_schedule_unlock_irqrestore(lock, flags, unit);
 }
 
 /*
@@ -1460,9 +1461,10 @@  static void repl_timer_handler(void *data){
     struct list_head *runq = rt_runq(ops);
     struct list_head *iter, *tmp;
     struct rt_unit *svc;
+    unsigned long flags;
     LIST_HEAD(tmp_replq);
 
-    spin_lock_irq(&prv->lock);
+    spin_lock_irqsave(&prv->lock, flags);
 
     now = NOW();
 
@@ -1525,7 +1527,7 @@  static void repl_timer_handler(void *data){
     if ( !list_empty(replq) )
         set_timer(&prv->repl_timer, replq_elem(replq->next)->cur_deadline);
 
-    spin_unlock_irq(&prv->lock);
+    spin_unlock_irqrestore(&prv->lock, flags);
 }
 
 static const struct scheduler sched_rtds_def = {