Re: [patch 04/19] mutex subsystem, add include/asm-i386/mutex.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Ingo Molnar wrote:
From: Arjan van de Ven <[email protected]>

add the i386 version of mutex.h, optimized in assembly.

+static inline int
+__mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *))
+	/*
+	 * We have two variants here. The cmpxchg based one is the best one
+	 * because it never induce a false contention state.  It is included
+	 * here because architectures using the inc/dec algorithms over the
+	 * xchg ones are much more likely to support cmpxchg natively.
+	 *
+	 * If not we fall back to the spinlock based variant - that is
+	 * just as efficient (and simpler) as a 'destructive' probing of
+	 * the mutex state would be.
+	 */
+	if (likely(atomic_cmpxchg(count, 1, 0)) == 1)
+		return 1;
+	return 0;
+	return fail_fn(count);

asm-i386 version I think really should just use atomic_cmpxchg unconditionally,
because otherwise an i386 compatible kernel will not use cmpxchg even when
running on 486+ (not sure how important that is these days, but still...).

SUSE Labs, Novell Inc.

Send instant messages to your online friends -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at
Please read the FAQ at

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux