* [PATCH net RFC 0/2] Series short description
@ 2013-09-17 0:59 Jacob Keller
2013-09-17 0:59 ` [PATCH net RFC 1/2] netdevice: add might_sleep() call to napi_disable Jacob Keller
2013-09-17 0:59 ` [PATCH net RFC 2/2] ixgbe: fix sleep bug caused by napi_disable inside local_bh_disable()d context Jacob Keller
0 siblings, 2 replies; 3+ messages in thread
From: Jacob Keller @ 2013-09-17 0:59 UTC (permalink / raw)
To: netdev
This series contains patches which help resolve a 'sleeping function called
from invalid context' bug introduced by the busy polling code. The first patch
simply adds a might_sleep() call to napi_disable. The second patch provides the
actual fix for the sleeping during a local_bh_disable()d section of code. I
tried to Cc everyone that might be interested in the solution, as I am unsure
if my solution of moving the local_bh_disable() call is correct.
---
Jacob Keller (2):
netdevice: add might_sleep() call to napi_disable
ixgbe: fix sleep bug caused by napi_disable inside local_bh_disable()d context
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 ++--
include/linux/netdevice.h | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
--
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net RFC 1/2] netdevice: add might_sleep() call to napi_disable
2013-09-17 0:59 [PATCH net RFC 0/2] Series short description Jacob Keller
@ 2013-09-17 0:59 ` Jacob Keller
2013-09-17 0:59 ` [PATCH net RFC 2/2] ixgbe: fix sleep bug caused by napi_disable inside local_bh_disable()d context Jacob Keller
1 sibling, 0 replies; 3+ messages in thread
From: Jacob Keller @ 2013-09-17 0:59 UTC (permalink / raw)
To: netdev
napi_disable potentially calls msleep(1) if the NAPI_STATE_SCHED bit is
previously set by something else. Because it does not always call msleep, it
was difficult to track down a bug related to calling napi_disable within
local_bh_disable()d context. This patch adds a might_sleep() call to the
napi_disable routine in order to aid in the future debugging of similar issues.
This will cause a BUG in drivers which have implemented busy polling in a
similar fashion to ixgbe, and which call napi_disable inside the
local_bh_disable()d section where the vector napi lock is taken.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Cc: Eliezer Tamir <eliezer.tamir@linux.intel.com>
Cc: Alex Duyck <alexander.h.duyck@intel.com>
Cc: Hyong-Youb Kim <hykim@myri.com>
Cc: Amir Vadai <amirv@mellanox.com>
Cc: Dmitry Kravkov <dmitry@broadcom.com>
---
include/linux/netdevice.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 041b42a..5e3ef61 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -483,6 +483,8 @@ extern void napi_hash_del(struct napi_struct *napi);
*/
static inline void napi_disable(struct napi_struct *n)
{
+ might_sleep();
+
set_bit(NAPI_STATE_DISABLE, &n->state);
while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
msleep(1);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH net RFC 2/2] ixgbe: fix sleep bug caused by napi_disable inside local_bh_disable()d context
2013-09-17 0:59 [PATCH net RFC 0/2] Series short description Jacob Keller
2013-09-17 0:59 ` [PATCH net RFC 1/2] netdevice: add might_sleep() call to napi_disable Jacob Keller
@ 2013-09-17 0:59 ` Jacob Keller
1 sibling, 0 replies; 3+ messages in thread
From: Jacob Keller @ 2013-09-17 0:59 UTC (permalink / raw)
To: netdev
This patch fixes a bug caused by calling napi_disable after local_bh_disable.
It is possible for napi_disable to sleep, (though not guarunteed) so it could
cause an atomic sleep bug during the schedule() call in msleep. This patch
resolves the issue by moving the local_bh_disable() calls inside the for loop
in ixgbe_napi_disable_all().
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Cc: Eliezer Tamir <eliezer.tamir@linux.intel.com>
Cc: Alexander Duyck <alexander.duyck@intel.com>
Cc: Hyong-Youb Kim <hykim@myri.com>
Cc: Amir Vadai <amirv@mellanox.com>
Cc: Dmitry Kravkov <dmitry@broadcom.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index ce3eb60..39b3424 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -3891,15 +3891,15 @@ static void ixgbe_napi_disable_all(struct ixgbe_adapter *adapter)
{
int q_idx;
- local_bh_disable(); /* for ixgbe_qv_lock_napi() */
for (q_idx = 0; q_idx < adapter->num_q_vectors; q_idx++) {
napi_disable(&adapter->q_vector[q_idx]->napi);
+ local_bh_disable(); /* for ixgbe_qv_lock_napi() */
while (!ixgbe_qv_lock_napi(adapter->q_vector[q_idx])) {
pr_info("QV %d locked\n", q_idx);
mdelay(1);
}
+ local_bh_enable();
}
- local_bh_enable();
}
#ifdef CONFIG_IXGBE_DCB
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-09-17 0:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-17 0:59 [PATCH net RFC 0/2] Series short description Jacob Keller
2013-09-17 0:59 ` [PATCH net RFC 1/2] netdevice: add might_sleep() call to napi_disable Jacob Keller
2013-09-17 0:59 ` [PATCH net RFC 2/2] ixgbe: fix sleep bug caused by napi_disable inside local_bh_disable()d context Jacob Keller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).