> > That can certainly work, and it has the advantages of simplicity.
> > I wouldn't use that strategy in every driver of course, but I'd
> > guess it's fine for the serial and usblp cases mentioned here.
> 
> Why would you not want it in every driver?

For starters, your pre-emptive claim that performance isn't a factor
is erroneous.  PCs are resource-rich -- in CPU and memory -- but Linux
isn't just x86, and even x86 hits resource limits.

The CPU costs for hitting the heap twice (free then allocate) vs. just
reusing an URB will add up in low-MIPS systems.  When those costs get
paid in IRQ context, they impact IRQ latency.  When they get paid on
systems with small batteries, they reduce time-till-recharge.  When
they replace cache lines with less useful information, they increase
the system's cycle-per-instruction ratio.  While the cost to one driver
may not be high, system-wide costs do add up.

The implicit assumptions about memory availability may be more important.
It can take more code to recover from memory allocation failures than
to properly synchronize memory re-use.  That code rarely gets tested...
Plus, that code tends to run at awkward moments, when everything is
more liable to break.

I wouldn't for example anticipate changing the usbnet core to stop
recycling RX and TX urbs.  It was converted to use that strategy
explicitly for reasons of robustness.  Most network drivers are set
up to used fixed resources (don't touch the heap in critical paths
like RX and TX) ... so long as the network stack can provide SKBs,
traffic will flow reliably.


> As Oliver is finding out, a 
> lot of these "simple" drivers have races all due to their use of a
> pre-allocated urb.  For what kind of situation would you feel this would
> not work?

Not-simple drivers.  ;)

Engineering tradeoffs always need to be made.  My point was less about
"not work" and more about "good tradeoff".  One size does not fit all.
A driver which prioritizes simplicity isn't necessarily going to handle
all the corner cases robustly and efficiently.  Resource shortages are
a *HUGE* category of corner cases.

- Dave

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to