Re: [linux-usb-devel] Re: [PATCH 00/10] usb-serial: Switches fromspin lock to atomic_t.

From: Arjan van de Ven
Date: Wed Dec 07 2005 - 10:21:59 EST



> On the other hand, Oliver needs to be careful about claiming too much. In
> general atomic_t operations _are_ superior to the spinlock approach.

No they're not. Both are just about equally expensive cpu wise,
sometimes the atomic_t ones are a bit more expensive (like on parisc
architecture). But on x86 in either case it's a locked cycle, which is
just expensive no matter which side you flip the coin...

> If
> they weren't, atomic_t wouldn't belong in the kernel at all.

there's different usage patterns where either makes sense.
In this case it looks just disgusting on very first sight; the atomic
are used to implement a lock, and that lock itself is then implemented
with a spinlock again. For me, again on first sight, the real solution
appears to be to use a linux primitive for the higher level lock in the
first place, instead of reimplementing <your own thing> with <another
own thing>.



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/