Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[NETPOLL]: add retry timeout

Add limited retry logic to netpoll_send_skb

Each time we attempt to send, decrement our per-device retry counter.
On every successful send, we reset the counter.

We delay 50us between attempts with up to 20000 retries for a total of
1 second. After we've exhausted our retries, subsequent failed
attempts will try only once until reset by success.

Signed-off-by: Matt Mackall <mpm@selenic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Matt Mackall and committed by
David S. Miller
0db1d6fc f0d3459d

+11 -3
+1
include/linux/netpoll.h
··· 26 26 struct netpoll_info { 27 27 spinlock_t poll_lock; 28 28 int poll_owner; 29 + int tries; 29 30 int rx_flags; 30 31 spinlock_t rx_lock; 31 32 struct netpoll *rx_np; /* netpoll that registered an rx_hook */
+10 -3
net/core/netpoll.c
··· 33 33 #define MAX_UDP_CHUNK 1460 34 34 #define MAX_SKBS 32 35 35 #define MAX_QUEUE_DEPTH (MAX_SKBS / 2) 36 + #define MAX_RETRIES 20000 36 37 37 38 static DEFINE_SPINLOCK(skb_list_lock); 38 39 static int nr_skbs; ··· 266 265 return; 267 266 } 268 267 269 - while (1) { 268 + do { 269 + npinfo->tries--; 270 270 spin_lock(&np->dev->xmit_lock); 271 271 np->dev->xmit_lock_owner = smp_processor_id(); 272 272 ··· 279 277 np->dev->xmit_lock_owner = -1; 280 278 spin_unlock(&np->dev->xmit_lock); 281 279 netpoll_poll(np); 280 + udelay(50); 282 281 continue; 283 282 } 284 283 ··· 288 285 spin_unlock(&np->dev->xmit_lock); 289 286 290 287 /* success */ 291 - if(!status) 288 + if(!status) { 289 + npinfo->tries = MAX_RETRIES; /* reset */ 292 290 return; 291 + } 293 292 294 293 /* transmit busy */ 295 294 netpoll_poll(np); 296 - } 295 + udelay(50); 296 + } while (npinfo->tries > 0); 297 297 } 298 298 299 299 void netpoll_send_udp(struct netpoll *np, const char *msg, int len) ··· 648 642 npinfo->rx_np = NULL; 649 643 npinfo->poll_lock = SPIN_LOCK_UNLOCKED; 650 644 npinfo->poll_owner = -1; 645 + npinfo->tries = MAX_RETRIES; 651 646 npinfo->rx_lock = SPIN_LOCK_UNLOCKED; 652 647 } else 653 648 npinfo = ndev->npinfo;