History

netpoll: make ndo_poll_controller() optional

As diagnosed by Song Liu, ndo_poll_controller() can be very dangerous on loaded hosts, since the cpu calling ndo_poll_controller() might steal all NAPI contexts (for all RX/TX queues of the NIC). This capture can last for unlimited amount of time, since one cpu is generally not able to drain all the queues under load. It seems that all networking drivers that do use NAPI for their TX completions, should not provide a ndo_poll_controller(). NAPI drivers have netpoll support already handled in core networking stack, since netpoll_poll_dev() uses poll_napi(dev) to iterate through registered NAPI contexts for a device. This patch allows netpoll_poll_dev() to process NAPI contexts even for drivers not providing ndo_poll_controller(), allowing for following patches in NAPI drivers. Also we export netpoll_poll_dev() so that it can be called by bonding/team drivers in following patches.

Eric Dumazet committed 8 years ago

Commit ac3d9dd1 parent 16fdf8b2 files · +10 −14Browse files

Unified · Split

2 files
  1. include/linux/netpoll.h +3 −2
  2. net/core/netpoll.c +7 −12
include/linux/netpoll.h+3−2
@@ -49,8 +49,9 @@ struct netpoll_info { · 48 unmodified lines
4949 };
5050
5151 #ifdef CONFIG_NETPOLL
52−extern void netpoll_poll_disable(struct net_device *dev);
53−extern void netpoll_poll_enable(struct net_device *dev);
52+void netpoll_poll_dev(struct net_device *dev);
53+void netpoll_poll_disable(struct net_device *dev);
54+void netpoll_poll_enable(struct net_device *dev);
5455 #else
5556 static inline void netpoll_poll_disable(struct net_device *dev) { return; }
5657 static inline void netpoll_poll_enable(struct net_device *dev) { return; }
net/core/netpoll.c+7−12
@@ -187,16 +187,16 @@ static void poll_napi(struct net_device *dev) · 186 unmodified lines
187187 }
188188 }
189189
190−static void netpoll_poll_dev(struct net_device *dev)
190+void netpoll_poll_dev(struct net_device *dev)
191191 {
192− const struct net_device_ops *ops;
193192 struct netpoll_info *ni = rcu_dereference_bh(dev->npinfo);
193+ const struct net_device_ops *ops;
194194
195195 /* Don't do any rx activity if the dev_lock mutex is held
196196 * the dev_open/close paths use this to block netpoll activity
197197 * while changing device state
198198 */
199− if (down_trylock(&ni->dev_lock))
199+ if (!ni || down_trylock(&ni->dev_lock))
200200 return;
201201
202202 if (!netif_running(dev)) {
@@ -205,13 +205,8 @@ static void netpoll_poll_dev(struct net_device *dev) · 2 unmodified lines
205205 }
206206
207207 ops = dev->netdev_ops;
208− if (!ops->ndo_poll_controller) {
209− up(&ni->dev_lock);
210− return;
211− }
212−
213− /* Process pending work on NIC */
214− ops->ndo_poll_controller(dev);
208+ if (ops->ndo_poll_controller)
209+ ops->ndo_poll_controller(dev);
215210
216211 poll_napi(dev);
217212
@@ -219,6 +214,7 @@ static void netpoll_poll_dev(struct net_device *dev) · 1 unmodified line
219214
220215 zap_completion_queue();
221216 }
217+EXPORT_SYMBOL(netpoll_poll_dev);
222218
223219 void netpoll_poll_disable(struct net_device *dev)
224220 {
@@ -613,8 +609,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev) · 388 unmodified lines
613609 strlcpy(np->dev_name, ndev->name, IFNAMSIZ);
614610 INIT_WORK(&np->cleanup_work, netpoll_async_cleanup);
615611
616− if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) ||
617− !ndev->netdev_ops->ndo_poll_controller) {
612+ if (ndev->priv_flags & IFF_DISABLE_NETPOLL) {
618613 np_err(np, "%s doesn't support polling, aborting\n",
619614 np->dev_name);
620615 err = -ENOTSUPP;