Messages in this thread | | | Date | Mon, 9 Jul 2007 12:16:26 -0700 (PDT) | From | Davide Libenzi <> | Subject | Re: queued spinlock code and results |
| |
On Mon, 9 Jul 2007, Davide Libenzi wrote:
> #define ZLOCK_INIT(l) (l)[0] = 0, (l)[1] = 0 > static inline void zlock(short *lock) > { > __asm__ __volatile__ ("lock ; xaddl %%eax, %0\n\t" > "mov %%eax, %%ebx\n\t" > "shr $16, %%ebx\n\t" > "1:\n\t" > "cmpw %%ax, %%bx\n\t" > "je 2f\n\t" > "rep ; nop\n\t" - "movw %1, %%bx\n\t" + "movw %1, %%ax\n\t" > "lfence\n\t" > "jmp 1b\n\t" > "2:\n\t" > : "+m" (*(int *) lock) > : "m" (lock[0]), "a" (0x10000) : "ebx", "memory"); > }
Erm, modulo that bugger ;) that'd never should up in the non-contended case (and that does not change numbers):
inc-lock in cache takes 7.28ns xadd-lock in cache takes 8.93ns vadd-lock in cache takes 10.34ns zadd-lock in cache takes 8.43ns inc-lock out of cache takes 87.98ns xadd-lock out of cache takes 88.89ns vadd-lock out of cache takes 89.59ns zadd-lock out of cache takes 89.86ns
- Davide
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |