irq_work: Also rcuwait for !IRQ_WORK_HARD_IRQ on PREEMPT_RT
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 6 Oct 2021 11:18:52 +0000 (13:18 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 15 Oct 2021 09:25:18 +0000 (11:25 +0200)
On PREEMPT_RT most items are processed as LAZY via softirq context.
Avoid to spin-wait for them because irq_work_sync() could have higher
priority and not allow the irq-work to be completed.

Wait additionally for !IRQ_WORK_HARD_IRQ irq_work items on PREEMPT_RT.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20211006111852.1514359-5-bigeasy@linutronix.de
include/linux/irq_work.h
kernel/irq_work.c

index b48955e9c920e32e09fcf9c0041cc720dbebe819..8cd11a2232605557353ed22a8a00d59729d5f97d 100644 (file)
@@ -49,6 +49,11 @@ static inline bool irq_work_is_busy(struct irq_work *work)
        return atomic_read(&work->node.a_flags) & IRQ_WORK_BUSY;
 }
 
+static inline bool irq_work_is_hard(struct irq_work *work)
+{
+       return atomic_read(&work->node.a_flags) & IRQ_WORK_HARD_IRQ;
+}
+
 bool irq_work_queue(struct irq_work *work);
 bool irq_work_queue_on(struct irq_work *work, int cpu);
 
index 90b6b56f92e9599e2149228a188229d932bc11f3..f7df715ec28e6de930c7b00d7f2789801761c07a 100644 (file)
@@ -217,7 +217,8 @@ void irq_work_single(void *arg)
         */
        (void)atomic_cmpxchg(&work->node.a_flags, flags, flags & ~IRQ_WORK_BUSY);
 
-       if (!arch_irq_work_has_interrupt())
+       if ((IS_ENABLED(CONFIG_PREEMPT_RT) && !irq_work_is_hard(work)) ||
+           !arch_irq_work_has_interrupt())
                rcuwait_wake_up(&work->irqwait);
 }
 
@@ -277,7 +278,8 @@ void irq_work_sync(struct irq_work *work)
        lockdep_assert_irqs_enabled();
        might_sleep();
 
-       if (!arch_irq_work_has_interrupt()) {
+       if ((IS_ENABLED(CONFIG_PREEMPT_RT) && !irq_work_is_hard(work)) ||
+           !arch_irq_work_has_interrupt()) {
                rcuwait_wait_event(&work->irqwait, !irq_work_is_busy(work),
                                   TASK_UNINTERRUPTIBLE);
                return;