diff mbox

NAPI on USB network drivers

Message ID 1485353591.5145.8.camel@edumazet-glaptop3.roam.corp.google.com
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Jan. 25, 2017, 2:13 p.m. UTC
On Wed, 2017-01-25 at 09:39 +0000, Hayes Wang wrote:
> Oliver Neukum [mailto:oneukum@suse.com]
> > Sent: Wednesday, January 25, 2017 5:35 PM
> [...]
> > looking at r8152 I noticed that it uses NAPI. I never considered
> > this for the generic USB networking code as you cannot disable
> > interrupts for USB. Is it still worth it? What are the benefits?
> 
> You could use napi_gro_receive() and it influences the performance.

You also could use napi_complete_done() instead of napi_complete(), as
it allows users to tune the performance vs latency for GRO.

Looking at this driver, I do not see any limitation on the number of
skbs that can be pushed into tp->rx_queue.

I wonder if this queue can end up consuming all memory of a host under
stress.

Comments

Hayes Wang Jan. 26, 2017, 1:43 a.m. UTC | #1
Eric Dumazet [mailto:eric.dumazet@gmail.com]
> Sent: Wednesday, January 25, 2017 10:13 PM

[...]
> You also could use napi_complete_done() instead of napi_complete(), as

> it allows users to tune the performance vs latency for GRO.

> 

> Looking at this driver, I do not see any limitation on the number of

> skbs that can be pushed into tp->rx_queue.

> 

> I wonder if this queue can end up consuming all memory of a host under

> stress.

> 

> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c

> index

> e1466b4d2b6c727148a884672bbd9593bf04b3ac..221df4a931b5c1073f1922d0fa0b

> bff158c73b7d 100644

> --- a/drivers/net/usb/r8152.c

> +++ b/drivers/net/usb/r8152.c

> @@ -1840,7 +1840,10 @@ static int rx_bottom(struct r8152 *tp, int budget)

>  				stats->rx_packets++;

>  				stats->rx_bytes += pkt_len;

>  			} else {

> -				__skb_queue_tail(&tp->rx_queue, skb);

> +				if (unlikely(skb_queue_len(&tp->rx_queue) >= 1000))

> +					kfree_skb(skb);

> +				else

> +					__skb_queue_tail(&tp->rx_queue, skb);

>  			}

> 

>  find_next_rx:


Thanks for your suggestion. I would submit it later.

Best Regards,
Hayes
diff mbox

Patch

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index e1466b4d2b6c727148a884672bbd9593bf04b3ac..221df4a931b5c1073f1922d0fa0bbff158c73b7d 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1840,7 +1840,10 @@  static int rx_bottom(struct r8152 *tp, int budget)
 				stats->rx_packets++;
 				stats->rx_bytes += pkt_len;
 			} else {
-				__skb_queue_tail(&tp->rx_queue, skb);
+				if (unlikely(skb_queue_len(&tp->rx_queue) >= 1000))
+					kfree_skb(skb);
+				else
+					__skb_queue_tail(&tp->rx_queue, skb);
 			}
 
 find_next_rx: