Prev: [PATCH resend] x86, amd: Check X86_FEATURE_OSVW bit before accessing OSVW MSRs
Next: rwsem: wake queued readers when other readers are active
From: David Howells on 12 May 2010 08:20 Michel Lespinasse <walken(a)google.com> wrote: > static inline void __up_write(struct rw_semaphore *sem) > { > ... > LOCK_PREFIX " xadd %1,(%2)\n\t" > - /* tries to transition > - 0xffff0001 -> 0x00000000 */ > - " jz 1f\n" > + /* substracts 0xffff0001, returns the old value */ > + " cmp %4,%1\n\t" > + /* are there waiting threads and no active threads ? */ > + " jne 1f\n" > " call call_rwsem_wake\n" It looks like you're betting on there being fast-path contention. If the common case is no fast-path contention, then you'd be better off putting the comparison out of line in the medium-path and retaining the JZ instruction. The same goes for __up_read(): you could retain the JNS there and put the comparison out of line into the medium-path. Doing this also saves you some code space. David -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |