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

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

 



* Nick Piggin <[email protected]> wrote:

> >+#ifdef __HAVE_ARCH_CMPXCHG
> >+	if (likely(atomic_cmpxchg(count, 1, 0)) == 1)
> >+		return 1;
> >+	return 0;
> >+#else
> >+	return fail_fn(count);
> >+#endif
> >+}
> 
> 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...).

yeah. This code predates the generic-atomic-cmpxchg code. (Feel free to 
review all __HAVE_ARCH_CMPXCHG users after this goes in, and remove 
__HAVE_ARCH_CMPXCHG altogether with a CONFIG_ flag.)

but ... the spinlock based variant is quite likely faster (on i386) than 
generic-cmpxchg. Couldnt we introduce a new API, something along the 
lines of:

	atomic_cmpxchg_lock(&count, &lock->wait_lock);

and if the cmpxchg fails, it would hold the spinlock? The cmpxchg 
semantics could be guaranteed by the spinlock. (because it is 'global' 
for that particular critical section)

	Ingo
-
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/

[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