On Wed, Mar 28, 2007 at 03:00:21PM -0700, Davide Libenzi wrote: > On Wed, 28 Mar 2007, Davide Libenzi wrote: > > > The method you propose is otherwise called "Ticket Lock": > > > > http://en.wikipedia.org/wiki/Ticket_lock > > http://www.cs.rochester.edu/research/synchronization/pseudocode/ss.html#ticket > > That this work prio-art dates to 1991: > > http://www.cs.rochester.edu/u/scott/papers/1991_TOCS_synch.pdf > > So I would not worry to much about patents here. At least W2K MS ones ;) > What I would worry though, is to add another class of locks. There's no
No, as you see from my patch I just change the spinlock implementation to a queued one. I agree it doesn't make sense to add a new type of lock. > reason why Ticket Locks would perform worse than our spinlock, in both > contended and not-contended case, AFAICS. And they have a nice FIFO > behaviour. In most cases, no. For the uncontended case they should be about the same. They have the same spinning behaviour. However there is a little window where they might be a bit slower I think... actually perhaps I'm wrong! Currently if you have 4 CPUs spinning and the lock is released, all 4 CPU cachelines will be invalidated, then they will be loaded again, and found to be 0, so they all try to atomic_dec_return the counter, each one invalidating others' cachelines. 1 gets through. With my queued locks, all 4 cachelines are invalidated and loaded, but only one will be allowed to proceed, and there are 0 atomic operations or stores of any kind. So I take that back: our current spinlocks have a worse thundering herd behaviour under contention than my queued ones. So I'll definitely push the patch through. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/