xchg in fastpath for mutex unlock [mutex-xchg.h]

From: Shantanu Gupta
Date: Fri Sep 28 2012 - 06:48:55 EST


Hello,

I am currently studying mutex(es) and was referring to linux sources
for it's implementation. However I noticed one shortcoming, in
"/include/asm-generic/mutex-xchg.h" of the master branch inside
__mutex_fastpath_trylock, Why doesn't the kernel use a cmpxchg instead
of dirtying the value with xchg ?

(The only thing that came to my mind was that x86_x64 implementation
mentioned that all x86_x64 cpu(s) have cmpxchg leading me to
assumption that certain archs can have xchg but not cmpxchg, so is it
this way just to work with architectures without a cmpxchg but with
xchg ?)

Thanks,
Rick
--
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/