NAPI on USB network drivers
Subsystems (3)
Hi,
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?
Regards
Oliver
A message that is not in the archive (sent off-list or not yet received): 1485336881.16604.2.camel-IBi9RG/[email protected]
T2xpdmVyIE5ldWt1bSBbbWFpbHRvOm9uZXVrdW1Ac3VzZS5jb21dDQo+IFNlbnQ6IFdlZG5lc2Rh eSwgSmFudWFyeSAyNSwgMjAxNyA1OjM1IFBNDQpbLi4uXQ0KPiBsb29raW5nIGF0IHI4MTUyIEkg bm90aWNlZCB0aGF0IGl0IHVzZXMgTkFQSS4gSSBuZXZlciBjb25zaWRlcmVkDQo+IHRoaXMgZm9y IHRoZSBnZW5lcmljIFVTQiBuZXR3b3JraW5nIGNvZGUgYXMgeW91IGNhbm5vdCBkaXNhYmxlDQo+ IGludGVycnVwdHMgZm9yIFVTQi4gSXMgaXQgc3RpbGwgd29ydGggaXQ/IFdoYXQgYXJlIHRoZSBi ZW5lZml0cz8NCg0KWW91IGNvdWxkIHVzZSBuYXBpX2dyb19yZWNlaXZlKCkgYW5kIGl0IGluZmx1 ZW5jZXMgdGhlIHBlcmZvcm1hbmNlLg0KDQpCZXN0IFJlZ2FyZHMsDQpIYXllcw0KDQo= --
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 0835B3720019904CB8F7AA43166CEEB201A134A7-JIZ+AM9kKNzKeZCINmmWEypo8c9IxeqyAjHCUHv49ws@public.gmane.org
Quoted 8 lines · Hayes Wang
Oliver Neukum [mailto:oneukum-IBi9RG/[email protected]]
Quoted 1 line
Sent: Wednesday, January 25, 2017 5:35 PM
[...]
Quoted 3 lines
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.
Another positive effect with NAPI is that you won't face out-of-order ethernet frames as you get with non-NAPI drivers, e.g. ax88179_178a
http://marc.info/?l=linux-can&m=148049063812807&w=2
We have the issue with CAN drivers where all USB drivers and >90% of the I/O mapped drivers do not use NAPI.
I wonder whether it makes sense to add NAPI to a driver which only has ONE RX buffer ... but when searching for a solution for o-o-o frames I was always pointed to NAPI.
Regards,
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 24 lines · Oliver Hartkopp
Quoted 5 lines · Hayes Wang
Oliver Neukum [mailto:[email protected]]
Quoted 2 lines
Sent: Wednesday, January 25, 2017 5:35 PM
Quoted 8 lines
[...]
Quoted 4 lines
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.Another positive effect with NAPI is that you won't face out-of-order ethernet frames as you get with non-NAPI drivers, e.g.
ax88179_178ahttp://marc.info/?l=linux-can&m=148049063812807&w=2
We have the issue with CAN drivers where all USB drivers and >90% of the I/O mapped drivers do not use NAPI.
Quoted 7 lines
I wonder whether it makes sense to add NAPI to a driver which only has ONE RX buffer ... but when searching for a solution for o-o-o frames I was always pointed to NAPI.
Regards,
Oliver
You could probably get around the o-o-o problem by enabling RPS for the interface. I have found that it works for me to do that in order to resolve o-o-o frames generated by VMs on virtual interfaces that can't use NAPI.
- Alex
Quoted 6 lines · Alexander Duyck
On Wed, Jan 25, 2017 at 5:33 AM, Oliver Hartkopp <[email protected]> wrote:
You could probably get around the o-o-o problem by enabling RPS for the interface. I have found that it works for me to do that in order to resolve o-o-o frames generated by VMs on virtual interfaces that can't use NAPI.
Sounds promising!
In fact I tried to fix this o-o-o stuff here:
http://marc.info/?l=linux-can&m=143637774606287&w=2
Do you have an example how to do it right?
Best regards,
Oliver
Quoted 8 lines · Hayes Wang
Oliver Neukum [mailto:[email protected]]
Quoted 1 line
Sent: Wednesday, January 25, 2017 5:35 PM
[...]
Quoted 3 lines
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.
drivers/net/usb/r8152.c +4 -1
@@ -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:
A message that is not in the archive (sent off-list or not yet received): 1485353591.5145.8.camel-XN9IlZ5yJG9HTL0Zs8A6p+yfmBU6pStAUsxypvmhUTTZJqsBc5GL+g@public.gmane.org
RXJpYyBEdW1hemV0IFttYWlsdG86ZXJpYy5kdW1hemV0QGdtYWlsLmNvbV0NCj4gU2VudDogV2Vk bmVzZGF5LCBKYW51YXJ5IDI1LCAyMDE3IDEwOjEzIFBNDQpbLi4uXQ0KPiBZb3UgYWxzbyBjb3Vs ZCB1c2UgbmFwaV9jb21wbGV0ZV9kb25lKCkgaW5zdGVhZCBvZiBuYXBpX2NvbXBsZXRlKCksIGFz DQo+IGl0IGFsbG93cyB1c2VycyB0byB0dW5lIHRoZSBwZXJmb3JtYW5jZSB2cyBsYXRlbmN5IGZv ciBHUk8uDQo+IA0KPiBMb29raW5nIGF0IHRoaXMgZHJpdmVyLCBJIGRvIG5vdCBzZWUgYW55IGxp bWl0YXRpb24gb24gdGhlIG51bWJlciBvZg0KPiBza2JzIHRoYXQgY2FuIGJlIHB1c2hlZCBpbnRv IHRwLT5yeF9xdWV1ZS4NCj4gDQo+IEkgd29uZGVyIGlmIHRoaXMgcXVldWUgY2FuIGVuZC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linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller
maintainerFrom: Oliver Neukum <[email protected]>
Date: Wed, 25 Jan 2017 10:34:41 +0100
Quoted 3 lines
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?
I think it's not a good approach for getting GRO.
Exactly because of the issue you raise, in that USB drivers cannot stop the URBs from coming in while running their poll method.