From: Sebastian Andrzej Siewior <bige...@linutronix.de>

__napi_schedule_irqoff() is an optimized version of __napi_schedule()
which can be used where it is known that interrupts are disabled,
e.g. in interrupt-handlers, spin_lock_irq() sections or hrtimer
callbacks.

On PREEMPT_RT enabled kernels this assumptions is not true. Force-
threaded interrupt handlers and spinlocks are not disabling interrupts
and the NAPI hrtimer callback is forced into softirq context which runs
with interrupts enabled as well.

Chasing all usage sites of __napi_schedule_irqoff() is a whack-a-mole
game so make __napi_schedule_irqoff() invoke __napi_schedule() for
PREEMPT_RT kernels.

The callers of ____napi_schedule() in the networking core have been
audited and are correct on PREEMPT_RT kernels as well.

Reported-by: Juri Lelli <juri.le...@redhat.com>
Signed-off-by: Sebastian Andrzej Siewior <bige...@linutronix.de>

[RQ: Original patch taken from this linux kernel mailing list archive:
https://lore.kernel.org/lkml/20210512214324.hiaiw3e2tzmsy...@linutronix.de/]

Integrated-by: Ruiqiang Hao <ruiqiang....@windriver.com>
---
 net/core/dev.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 64f4c7ec729d..61f78290e590 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6414,11 +6414,18 @@ EXPORT_SYMBOL(napi_schedule_prep);
  * __napi_schedule_irqoff - schedule for receive
  * @n: entry to schedule
  *
- * Variant of __napi_schedule() assuming hard irqs are masked
+ * Variant of __napi_schedule() assuming hard irqs are masked.
+ *
+ * On PREEMPT_RT enabled kernels this maps to __napi_schedule()
+ * because the interrupt disabled assumption might not be true
+ * due to force-threaded interrupts and spinlock substitution.
  */
 void __napi_schedule_irqoff(struct napi_struct *n)
 {
-       ____napi_schedule(this_cpu_ptr(&softnet_data), n);
+       if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+               ____napi_schedule(this_cpu_ptr(&softnet_data), n);
+       else
+               __napi_schedule(n);
 }
 EXPORT_SYMBOL(__napi_schedule_irqoff);
 
-- 
2.29.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9869): 
https://lists.yoctoproject.org/g/linux-yocto/message/9869
Mute This Topic: https://lists.yoctoproject.org/mt/82790987/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to