usbatm subdriver registration w/o .driver_info

Duncan Sands duncan.sands at
Fri Jan 28 03:16:28 EST 2005

Hi Roman,

> So the only thing we need to make sure is that list
> traversal doesn't fail.  I thought that choosing the appropriate list
> primitives would do the job without locks.

no, you need locks for this.  I guess you are thinking that when elements
are added or removed, the links are set up in the right order so that someone
traversing will still traverse correctly?  This kind of reasoning is dangerous:
on many architectures reads and writes can be reordered, so even if you put the
right order in your code, it may not be the right order in practice unless you
put memory barriers all over the place.  The standard list primitives have no
memory barriers because it would be a heavy cost for users who don't need them.
And don't forget the related problem of the compiler doing reordering, or putting
some list bits in registers, so delaying writing of those ones to memory.  Also,
if several CPUs try to add/remove list elements at the same time, then you are
stuffed any unless they are serialised.  In my experience, trying to do things
lockless is just asking for trouble - you really need to know what you are doing.
And in this case we don't care.  Personally I think even a rw-semaphore is a waste
of time - just use a standard semaphore.  I may change my mind if you can show me
someone capable of plugging and unplugging their modem a billion times a second :)



More information about the Usbatm mailing list