On Tue, Dec 06, 2005 at 11:40:41AM -0800, Greg KH wrote: > On Tue, Dec 06, 2005 at 09:56:10AM -0200, Luiz Fernando Capitulino wrote: > > Greg, > > > > Don't get scared. :-) > > > > As showed by Eduardo Habkost some days ago, the spin lock 'lock' in the > > struct 'usb_serial_port' is being used by some USB serial drivers to protect > > the access to the 'write_urb_busy' member of the same struct. > > > > The spin lock however, is needless: we can change 'write_urb_busy' type > > to be atomic_t and remove all the spin lock usage. > > But if you do that, you make things slower on non-smp machines, which > isn't very nice. Why does the spinlock bother you? >
We thought that an atomic_t was better when you suggested that we could drop the spinlock after we added a semaphore to struct usb_serial_port recently. Won't we drop the spinlock as suggested? Anyway, I don't see yet why the atomic_t would make the code slower on non-smp. Is atomic_add_unless(v, 1, 1) supposed to be slower than 'if (!v) v = 1;' ? If it is really slower, is atomic_cmpxchg() supposed to be slower, too? ("Check it yourself" is a valid answer, too :) But maybe someone could elighten me and I could save some time testing and checking the generated code) -- Eduardo
pgpo6ShuRVT7N.pgp
Description: PGP signature