Messages in this thread | | | Date | Tue, 3 Jan 2006 16:21:17 +0100 | From | Ingo Molnar <> | Subject | Re: [patch 04/19] mutex subsystem, add include/asm-i386/mutex.h |
| |
* Nick Piggin <nickpiggin@yahoo.com.au> 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 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/
| |