aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bonding.h
diff options
context:
space:
mode:
authorNeil Horman <nhorman@tuxdriver.com>2010-10-13 12:01:50 -0400
committerDavid S. Miller <davem@davemloft.net>2010-10-18 11:32:07 -0400
commite843fa50887582c867d8b7995f81fe9c1a076806 (patch)
tree5a8e34f5afaeeed539d519b0e91b7a4c92268b11 /drivers/net/bonding/bonding.h
parentc2355e1ab910278a94d487b78590ee3c8eecd08a (diff)
bonding: Fix deadlock in bonding driver resulting from internal locking when using netpoll
The monitoring paths in the bonding driver take write locks that are shared by the tx path. If netconsole is in use, these paths can call printk which puts us in the netpoll tx path, which, if netconsole is attached to the bonding driver, result in deadlock (the xmit_lock guards are useless in netpoll_send_skb, as the monitor paths in the bonding driver don't claim the xmit_lock, nor should they). The solution is to use a per cpu flag internal to the driver to indicate when a cpu is holding the lock in a path that might recusrse into the tx path for the driver via netconsole. By checking this flag on transmit, we can defer the sending of the netconsole frames until a later time using the retransmit feature of netpoll_send_skb that is triggered on the return code NETDEV_TX_BUSY. I've tested this and am able to transmit via netconsole while causing failover conditions on the bond slave links. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bonding.h')
-rw-r--r--drivers/net/bonding/bonding.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index c15f21347486..2c12a5f812f4 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -19,6 +19,7 @@
19#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
20#include <linux/if_bonding.h> 20#include <linux/if_bonding.h>
21#include <linux/kobject.h> 21#include <linux/kobject.h>
22#include <linux/cpumask.h>
22#include <linux/in6.h> 23#include <linux/in6.h>
23#include "bond_3ad.h" 24#include "bond_3ad.h"
24#include "bond_alb.h" 25#include "bond_alb.h"
@@ -117,6 +118,35 @@
117 bond_for_each_slave_from(bond, pos, cnt, (bond)->first_slave) 118 bond_for_each_slave_from(bond, pos, cnt, (bond)->first_slave)
118 119
119 120
121#ifdef CONFIG_NET_POLL_CONTROLLER
122extern cpumask_var_t netpoll_block_tx;
123
124static inline void block_netpoll_tx(void)
125{
126 preempt_disable();
127 BUG_ON(cpumask_test_and_set_cpu(smp_processor_id(),
128 netpoll_block_tx));
129}
130
131static inline void unblock_netpoll_tx(void)
132{
133 BUG_ON(!cpumask_test_and_clear_cpu(smp_processor_id(),
134 netpoll_block_tx));
135 preempt_enable();
136}
137
138static inline int is_netpoll_tx_blocked(struct net_device *dev)
139{
140 if (unlikely(dev->priv_flags & IFF_IN_NETPOLL))
141 return cpumask_test_cpu(smp_processor_id(), netpoll_block_tx);
142 return 0;
143}
144#else
145#define block_netpoll_tx()
146#define unblock_netpoll_tx()
147#define is_netpoll_tx_blocked(dev) (0)
148#endif
149
120struct bond_params { 150struct bond_params {
121 int mode; 151 int mode;
122 int xmit_policy; 152 int xmit_policy;