All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Ingo Molnar <mingo@elte.hu>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
	Arjan van de Ven <arjan@infradead.org>,
	Nicolas Pitre <nico@cam.org>,
	Jes Sorensen <jes@trained-monkey.org>,
	Al Viro <viro@ftp.linux.org.uk>, Oleg Nesterov <oleg@tv-sign.ru>,
	David Howells <dhowells@redhat.com>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Christoph Hellwig <hch@infradead.org>, Andi Kleen <ak@suse.de>,
	Russell King <rmk+lkml@arm.linux.org.uk>
Subject: Re: [patch 04/19] mutex subsystem, add include/asm-i386/mutex.h
Date: Wed, 04 Jan 2006 00:25:02 +1100	[thread overview]
Message-ID: <43BA7B2E.4070101@yahoo.com.au> (raw)
In-Reply-To: <20060103100737.GD23289@elte.hu>

Ingo Molnar wrote:
> From: Arjan van de Ven <arjan@infradead.org>
> 
> 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.
> +	 */
> +#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...).

-- 
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com 

  reply	other threads:[~2006-01-03 13:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-03 10:07 [patch 04/19] mutex subsystem, add include/asm-i386/mutex.h Ingo Molnar
2006-01-03 13:25 ` Nick Piggin [this message]
2006-01-03 15:21   ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2006-01-03 16:46 Ingo Molnar
2006-01-02 16:33 Ingo Molnar, Arjan van de Ven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43BA7B2E.4070101@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=arjan@infradead.org \
    --cc=dhowells@redhat.com \
    --cc=hch@infradead.org \
    --cc=jes@trained-monkey.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nico@cam.org \
    --cc=oleg@tv-sign.ru \
    --cc=rmk+lkml@arm.linux.org.uk \
    --cc=torvalds@osdl.org \
    --cc=viro@ftp.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.