All of lore.kernel.org
 help / color / mirror / Atom feed
* future developments of usbnet
@ 2011-05-06 18:45 Oliver Neukum
       [not found] ` <201105062045.37336.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Oliver Neukum @ 2011-05-06 18:45 UTC (permalink / raw)
  To: netdev, linux-usb

Hi,

I'd like to get a feeling what people are working out there regarding usbnet.
So please, if you do something, or think something ought to be done, please
speak up now.

IMHO usbnet needs better support for

- batching protocols
- double buffering on the rx path

with the latter having higher priority.

Coments?

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
       [not found] ` <201105062045.37336.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
@ 2011-05-09  3:26   ` Ming Lei
  2011-05-09  8:42     ` Oliver Neukum
  2011-05-10  9:42   ` Richard Cochran
  1 sibling, 1 reply; 14+ messages in thread
From: Ming Lei @ 2011-05-09  3:26 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA

Hi,

2011/5/7 Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>:
> Hi,
>
> I'd like to get a feeling what people are working out there regarding usbnet.
> So please, if you do something, or think something ought to be done, please
> speak up now.
>
> IMHO usbnet needs better support for
>
> - batching protocols
> - double buffering on the rx path
>
> with the latter having higher priority.
>
> Coments?

Maybe another thing about rx should be considered too: we should introduce
one flow control mechanism into rx path so that too much coming packets can
not consume many of memory and cause out of memory for atomic allocation.

Current implementation has such kind of risk certainly, as i explained in the
patch with title below:

       usbnet: runtime pm: fix out of memory

thanks,
-- 
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
  2011-05-09  3:26   ` Ming Lei
@ 2011-05-09  8:42     ` Oliver Neukum
       [not found]       ` <201105091042.01014.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Oliver Neukum @ 2011-05-09  8:42 UTC (permalink / raw)
  To: Ming Lei; +Cc: netdev, linux-usb

Am Montag, 9. Mai 2011, 05:26:04 schrieb Ming Lei:

Hi,

> 2011/5/7 Oliver Neukum <oliver@neukum.org>:
> > Hi,
> >
> > I'd like to get a feeling what people are working out there regarding usbnet.
> > So please, if you do something, or think something ought to be done, please
> > speak up now.
> >
> > IMHO usbnet needs better support for
> >
> > - batching protocols
> > - double buffering on the rx path
> >
> > with the latter having higher priority.
> >
> > Coments?
> 
> Maybe another thing about rx should be considered too: we should introduce
> one flow control mechanism into rx path so that too much coming packets can
> not consume many of memory and cause out of memory for atomic allocation.

Do we really need to avoid it, or do we just need to recover?
If avoidance is needed, should we use NAPI?

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
       [not found]       ` <201105091042.01014.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
@ 2011-05-09 15:22         ` Ming Lei
  2011-05-09 15:31           ` Alan Stern
  0 siblings, 1 reply; 14+ messages in thread
From: Ming Lei @ 2011-05-09 15:22 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA

Hi,

2011/5/9 Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>:

> Do we really need to avoid it, or do we just need to recover?
> If avoidance is needed, should we use NAPI?

IMO, OOM can recover it certainly but with much cost, so we should
avoid the case. I don't think NAPI can avoid it, because NAPI will
cause skb to be allocated without any limit if there are packets
coming, still no chance left for usbnet_bh to handle and free these
SKBs.


thanks,
-- 
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
  2011-05-09 15:22         ` Ming Lei
@ 2011-05-09 15:31           ` Alan Stern
  2011-05-09 15:46             ` Stephen Hemminger
  0 siblings, 1 reply; 14+ messages in thread
From: Alan Stern @ 2011-05-09 15:31 UTC (permalink / raw)
  To: Ming Lei; +Cc: Oliver Neukum, netdev, linux-usb

On Mon, 9 May 2011, Ming Lei wrote:

> Hi,
> 
> 2011/5/9 Oliver Neukum <oliver@neukum.org>:
> 
> > Do we really need to avoid it, or do we just need to recover?
> > If avoidance is needed, should we use NAPI?
> 
> IMO, OOM can recover it certainly but with much cost, so we should
> avoid the case. I don't think NAPI can avoid it, because NAPI will
> cause skb to be allocated without any limit if there are packets
> coming, still no chance left for usbnet_bh to handle and free these
> SKBs.

How do other network drivers handle this problem?  Can the same 
strategy be used?

Alan Stern


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
  2011-05-09 15:31           ` Alan Stern
@ 2011-05-09 15:46             ` Stephen Hemminger
  2011-05-11 17:37               ` Oliver Neukum
  0 siblings, 1 reply; 14+ messages in thread
From: Stephen Hemminger @ 2011-05-09 15:46 UTC (permalink / raw)
  To: Alan Stern; +Cc: Ming Lei, Oliver Neukum, netdev, linux-usb

On Mon, 9 May 2011 11:31:16 -0400 (EDT)
Alan Stern <stern@rowland.harvard.edu> wrote:

> On Mon, 9 May 2011, Ming Lei wrote:
> 
> > Hi,
> > 
> > 2011/5/9 Oliver Neukum <oliver@neukum.org>:
> > 
> > > Do we really need to avoid it, or do we just need to recover?
> > > If avoidance is needed, should we use NAPI?
> > 
> > IMO, OOM can recover it certainly but with much cost, so we should
> > avoid the case. I don't think NAPI can avoid it, because NAPI will
> > cause skb to be allocated without any limit if there are packets
> > coming, still no chance left for usbnet_bh to handle and free these
> > SKBs.
> 
> How do other network drivers handle this problem?  Can the same 
> strategy be used?
> 
> Alan Stern

Most Ethernet drivers have a fixed size receive ring and pass preallocated
memory (skb's or pages) for the hardware to fill in. When NAPI poll is run
it refills the ring and passes the data up to netif_receive_skb. NAPI allows
the poll routine to process a limited number of packets (weight) and after
that the poll loop exits and gets rerun by soft interrupt.  If data is
arriving faster than the kernel can process, eventually the receive ring
passed to hardware gets exhausted and the hardware drops packets.

There is no explicit memory bound limit, instead the flow control happens
when the receive ring gets full.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
       [not found] ` <201105062045.37336.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
  2011-05-09  3:26   ` Ming Lei
@ 2011-05-10  9:42   ` Richard Cochran
  1 sibling, 0 replies; 14+ messages in thread
From: Richard Cochran @ 2011-05-10  9:42 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA

On Fri, May 06, 2011 at 08:45:37PM +0200, Oliver Neukum wrote:
> Hi,
> 
> I'd like to get a feeling what people are working out there regarding usbnet.
> So please, if you do something, or think something ought to be done, please
> speak up now.
> 
> IMHO usbnet needs better support for
> 
> - batching protocols
> - double buffering on the rx path

I would like see phylib and (if possible) NAPI, although for different
reasons than the problems mentioned in this thread. I am willing and
able to do the work, but I obviously don't have all of the usbnet
hardware available for testing.

Thanks,

Richard
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
  2011-05-09 15:46             ` Stephen Hemminger
@ 2011-05-11 17:37               ` Oliver Neukum
       [not found]                 ` <201105111937.47448.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Oliver Neukum @ 2011-05-11 17:37 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Alan Stern, Ming Lei, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA

Am Montag, 9. Mai 2011, 17:46:49 schrieb Stephen Hemminger:
> On Mon, 9 May 2011 11:31:16 -0400 (EDT)
> Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org> wrote:

> > How do other network drivers handle this problem?  Can the same 
> > strategy be used?
> > 
> > Alan Stern
> 
> Most Ethernet drivers have a fixed size receive ring and pass preallocated
> memory (skb's or pages) for the hardware to fill in. When NAPI poll is run
> it refills the ring and passes the data up to netif_receive_skb. NAPI allows
> the poll routine to process a limited number of packets (weight) and after
> that the poll loop exits and gets rerun by soft interrupt.  If data is
> arriving faster than the kernel can process, eventually the receive ring
> passed to hardware gets exhausted and the hardware drops packets.

How is the frequency NAPI uses to poll determined? We could abuse
this and resubmit the rx URBs only at poll time, but this feels dirty,
because we would still leave interrupts enabled.

Is there no other driver which faces this problem?

	Regards
		Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
       [not found]                 ` <201105111937.47448.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
@ 2011-05-11 17:47                   ` David Miller
  2011-05-12  7:59                     ` Oliver Neukum
  0 siblings, 1 reply; 14+ messages in thread
From: David Miller @ 2011-05-11 17:47 UTC (permalink / raw)
  To: oliver-GvhC2dPhHPQdnm+yROfE0A
  Cc: shemminger-ZtmgI6mnKB3QT0dZR+AlfA,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz,
	tom.leiming-Re5JQEeQqe8AvxtiuMwx3w,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA

From: Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
Date: Wed, 11 May 2011 19:37:47 +0200

> How is the frequency NAPI uses to poll determined? We could abuse
> this and resubmit the rx URBs only at poll time, but this feels dirty,
> because we would still leave interrupts enabled.

It's not a frequency determined internally by the networking.

It is purely event based (meaning triggered by the device's interrupt).

Control flow is:

IRQ --> irq_handler()
	my_netdevice_disable_device_irq();
	napi_schedule();
		--> schedule POLL soft irq
SOFTIRQ --> net_rx_action()
	budget = netdev_budget;
	for_each_net_device_needing_polling() {
		...
		weight = napi_state->weight;
		...
		work = n->poll(n, weight);
		...
		budget -= work;
		...
	}

That's the general idea.

Basically once you take you interrupt, and disable device interrupts,
the generic net device layer calls your ->poll() routing with a "weight"
You should not process more RX packets than this value.

If you have less than "weight" work to do, you should do a napi_complete(),
which takes you out of the polling group, and re-enable device interrupts.

So the idea is that you keep getting ->poll()'d until there is no more
RX work to do.

The "weight" argument implements fairness amongst competing, actively
polling, devices on the same CPU.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
  2011-05-11 17:47                   ` David Miller
@ 2011-05-12  7:59                     ` Oliver Neukum
       [not found]                       ` <201105120959.28473.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Oliver Neukum @ 2011-05-12  7:59 UTC (permalink / raw)
  To: David Miller; +Cc: shemminger, stern, tom.leiming, netdev, linux-usb

Am Mittwoch, 11. Mai 2011, 19:47:27 schrieb David Miller:

> Basically once you take you interrupt, and disable device interrupts,
> the generic net device layer calls your ->poll() routing with a "weight"
> You should not process more RX packets than this value.
> 
> If you have less than "weight" work to do, you should do a napi_complete(),
> which takes you out of the polling group, and re-enable device interrupts.
> 
> So the idea is that you keep getting ->poll()'d until there is no more
> RX work to do.
> 
> The "weight" argument implements fairness amongst competing, actively
> polling, devices on the same CPU.
> 

Thank you, this is very informative. Our problem here is that USB doesn't work
sanely without interrupts. We can stop IO regarding rx, but we cannot stop
interrupts if we want to do rx.

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
       [not found]                       ` <201105120959.28473.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
@ 2011-05-12 14:37                         ` Alan Stern
  2011-05-14 10:01                           ` Oliver Neukum
  2011-05-12 17:46                         ` David Miller
  1 sibling, 1 reply; 14+ messages in thread
From: Alan Stern @ 2011-05-12 14:37 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: David Miller, shemminger-ZtmgI6mnKB3QT0dZR+AlfA,
	tom.leiming-Re5JQEeQqe8AvxtiuMwx3w,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA

On Thu, 12 May 2011, Oliver Neukum wrote:

> Am Mittwoch, 11. Mai 2011, 19:47:27 schrieb David Miller:
> 
> > Basically once you take you interrupt, and disable device interrupts,
> > the generic net device layer calls your ->poll() routing with a "weight"
> > You should not process more RX packets than this value.
> > 
> > If you have less than "weight" work to do, you should do a napi_complete(),
> > which takes you out of the polling group, and re-enable device interrupts.
> > 
> > So the idea is that you keep getting ->poll()'d until there is no more
> > RX work to do.
> > 
> > The "weight" argument implements fairness amongst competing, actively
> > polling, devices on the same CPU.
> > 
> 
> Thank you, this is very informative. Our problem here is that USB doesn't work
> sanely without interrupts. We can stop IO regarding rx, but we cannot stop
> interrupts if we want to do rx.

The idea behind NAPI can be adapted to the usbnet context.  The basic
idea is that the driver is allowed to accept only a limited number of 
packets, driven by polling from the NAPI core.

Therefore usbnet's poll routine should take the "weight" argument as an
indication of how many outstanding rx URBs are allowed.  Each time the
poll routine is called, it should check to see if any rx URBs have
completed since the previous poll.  If not then there is no network
traffic, so usbnet can take itself out of the poll loop.  Otherwise,
the number of outstanding URBs should be adjusted (by unlinking some or
submitting more -- subject to some fixed maximum limit) to match the
new "weight".

Does that make sense?

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
       [not found]                       ` <201105120959.28473.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
  2011-05-12 14:37                         ` Alan Stern
@ 2011-05-12 17:46                         ` David Miller
  1 sibling, 0 replies; 14+ messages in thread
From: David Miller @ 2011-05-12 17:46 UTC (permalink / raw)
  To: oliver-GvhC2dPhHPQdnm+yROfE0A
  Cc: shemminger-ZtmgI6mnKB3QT0dZR+AlfA,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz,
	tom.leiming-Re5JQEeQqe8AvxtiuMwx3w,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA

From: Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
Date: Thu, 12 May 2011 09:59:28 +0200

> Our problem here is that USB doesn't work sanely without
> interrupts. We can stop IO regarding rx, but we cannot stop
> interrupts if we want to do rx.

Understood.

However, I was wondering if you could do this in software.  When URBs
trigger, just queue that pending work up in a software queue when NAPI
is scheduled, then when you exit NAPI polling you check that queue to
see if there are interrupt events to process.

Similarly to how we handle software interrupts.

Anyways, just an idea.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
  2011-05-12 14:37                         ` Alan Stern
@ 2011-05-14 10:01                           ` Oliver Neukum
       [not found]                             ` <201105141201.40265.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Oliver Neukum @ 2011-05-14 10:01 UTC (permalink / raw)
  To: Alan Stern; +Cc: David Miller, shemminger, tom.leiming, netdev, linux-usb

Am Donnerstag, 12. Mai 2011, 16:37:28 schrieb Alan Stern:
> Therefore usbnet's poll routine should take the "weight" argument as an
> indication of how many outstanding rx URBs are allowed.  Each time the
> poll routine is called, it should check to see if any rx URBs have
> completed since the previous poll.  If not then there is no network
> traffic, so usbnet can take itself out of the poll loop.  Otherwise,
> the number of outstanding URBs should be adjusted (by unlinking some or
> submitting more -- subject to some fixed maximum limit) to match the
> new "weight".
> 
> Does that make sense?

What does happen if we reach the weight 0 ?

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: future developments of usbnet
       [not found]                             ` <201105141201.40265.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
@ 2011-05-14 10:46                               ` Michał Mirosław
  0 siblings, 0 replies; 14+ messages in thread
From: Michał Mirosław @ 2011-05-14 10:46 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Alan Stern, David Miller, shemminger-ZtmgI6mnKB3QT0dZR+AlfA,
	tom.leiming-Re5JQEeQqe8AvxtiuMwx3w,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA

2011/5/14 Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>:
> Am Donnerstag, 12. Mai 2011, 16:37:28 schrieb Alan Stern:
>> Therefore usbnet's poll routine should take the "weight" argument as an
>> indication of how many outstanding rx URBs are allowed.  Each time the
>> poll routine is called, it should check to see if any rx URBs have
>> completed since the previous poll.  If not then there is no network
>> traffic, so usbnet can take itself out of the poll loop.  Otherwise,
>> the number of outstanding URBs should be adjusted (by unlinking some or
>> submitting more -- subject to some fixed maximum limit) to match the
>> new "weight".
> What does happen if we reach the weight 0 ?

Poll callback won't be called with weight 0. If there are more RX
packets after processing 'weight' of them, then the callback will be
called again later.

Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-05-14 10:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-06 18:45 future developments of usbnet Oliver Neukum
     [not found] ` <201105062045.37336.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2011-05-09  3:26   ` Ming Lei
2011-05-09  8:42     ` Oliver Neukum
     [not found]       ` <201105091042.01014.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2011-05-09 15:22         ` Ming Lei
2011-05-09 15:31           ` Alan Stern
2011-05-09 15:46             ` Stephen Hemminger
2011-05-11 17:37               ` Oliver Neukum
     [not found]                 ` <201105111937.47448.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2011-05-11 17:47                   ` David Miller
2011-05-12  7:59                     ` Oliver Neukum
     [not found]                       ` <201105120959.28473.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2011-05-12 14:37                         ` Alan Stern
2011-05-14 10:01                           ` Oliver Neukum
     [not found]                             ` <201105141201.40265.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2011-05-14 10:46                               ` Michał Mirosław
2011-05-12 17:46                         ` David Miller
2011-05-10  9:42   ` Richard Cochran

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.