2020-10-12 12:52:06 +00:00
|
|
|
From 6a6cb0fc2f428550eb6dca1204695cc7f0e00a54 Mon Sep 17 00:00:00 2001
|
|
|
|
Message-Id: <6a6cb0fc2f428550eb6dca1204695cc7f0e00a54.1601675152.git.zanussi@kernel.org>
|
|
|
|
In-Reply-To: <5b5a156f9808b1acf1205606e03da117214549ea.1601675151.git.zanussi@kernel.org>
|
|
|
|
References: <5b5a156f9808b1acf1205606e03da117214549ea.1601675151.git.zanussi@kernel.org>
|
2018-08-27 14:32:32 +00:00
|
|
|
From: Steven Rostedt <rostedt@goodmis.org>
|
|
|
|
Date: Tue, 6 Dec 2016 17:50:30 -0500
|
2020-09-04 20:10:21 +00:00
|
|
|
Subject: [PATCH 204/333] net: Have __napi_schedule_irqoff() disable interrupts
|
2019-04-08 23:49:20 +00:00
|
|
|
on RT
|
2020-10-12 12:52:06 +00:00
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.148-rt64.tar.xz
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
A customer hit a crash where the napi sd->poll_list became corrupted.
|
|
|
|
The customer had the bnx2x driver, which does a
|
|
|
|
__napi_schedule_irqoff() in its interrupt handler. Unfortunately, when
|
|
|
|
running with CONFIG_PREEMPT_RT_FULL, this interrupt handler is run as a
|
|
|
|
thread and is preemptable. The call to ____napi_schedule() must be done
|
|
|
|
with interrupts disabled to protect the per cpu softnet_data's
|
|
|
|
"poll_list, which is protected by disabling interrupts (disabling
|
|
|
|
preemption is enough when all interrupts are threaded and
|
|
|
|
local_bh_disable() can't preempt)."
|
|
|
|
|
|
|
|
As bnx2x isn't the only driver that does this, the safest thing to do
|
|
|
|
is to make __napi_schedule_irqoff() call __napi_schedule() instead when
|
|
|
|
CONFIG_PREEMPT_RT_FULL is enabled, which will call local_irq_save()
|
|
|
|
before calling ____napi_schedule().
|
|
|
|
|
|
|
|
Cc: stable-rt@vger.kernel.org
|
|
|
|
Signed-off-by: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
|
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
---
|
2019-04-08 23:49:20 +00:00
|
|
|
include/linux/netdevice.h | 12 ++++++++++++
|
|
|
|
net/core/dev.c | 2 ++
|
2018-08-27 14:32:32 +00:00
|
|
|
2 files changed, 14 insertions(+)
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
|
2020-07-15 20:05:29 +00:00
|
|
|
index 7bf58533f955..0e34e8051ac2 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/include/linux/netdevice.h
|
|
|
|
+++ b/include/linux/netdevice.h
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -422,7 +422,19 @@ typedef enum rx_handler_result rx_handler_result_t;
|
2018-08-27 14:32:32 +00:00
|
|
|
typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb);
|
|
|
|
|
|
|
|
void __napi_schedule(struct napi_struct *n);
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * When PREEMPT_RT_FULL is defined, all device interrupt handlers
|
|
|
|
+ * run as threads, and they can also be preempted (without PREEMPT_RT
|
|
|
|
+ * interrupt threads can not be preempted). Which means that calling
|
|
|
|
+ * __napi_schedule_irqoff() from an interrupt handler can be preempted
|
|
|
|
+ * and can corrupt the napi->poll_list.
|
|
|
|
+ */
|
|
|
|
+#ifdef CONFIG_PREEMPT_RT_FULL
|
|
|
|
+#define __napi_schedule_irqoff(n) __napi_schedule(n)
|
|
|
|
+#else
|
|
|
|
void __napi_schedule_irqoff(struct napi_struct *n);
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
static inline bool napi_disable_pending(struct napi_struct *n)
|
|
|
|
{
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/net/core/dev.c b/net/core/dev.c
|
2020-10-12 12:52:06 +00:00
|
|
|
index 9b15c663b3f8..b73cbe6c8096 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/net/core/dev.c
|
|
|
|
+++ b/net/core/dev.c
|
2020-09-04 20:10:21 +00:00
|
|
|
@@ -5941,6 +5941,7 @@ bool napi_schedule_prep(struct napi_struct *n)
|
2018-08-27 14:32:32 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(napi_schedule_prep);
|
|
|
|
|
|
|
|
+#ifndef CONFIG_PREEMPT_RT_FULL
|
|
|
|
/**
|
|
|
|
* __napi_schedule_irqoff - schedule for receive
|
|
|
|
* @n: entry to schedule
|
2020-09-04 20:10:21 +00:00
|
|
|
@@ -5952,6 +5953,7 @@ void __napi_schedule_irqoff(struct napi_struct *n)
|
2018-08-27 14:32:32 +00:00
|
|
|
____napi_schedule(this_cpu_ptr(&softnet_data), n);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(__napi_schedule_irqoff);
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
bool napi_complete_done(struct napi_struct *n, int work_done)
|
|
|
|
{
|
2020-01-03 23:36:11 +00:00
|
|
|
--
|
2020-06-22 13:14:16 +00:00
|
|
|
2.17.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|