mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Davide Libenzi <davidel@xmailserver.org>
To: Nick Piggin <npiggin@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: queued spinlock code and results
Date: Mon, 9 Jul 2007 12:16:26 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0707091210510.15898@alien.or.mcafeemobile.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0707091140440.15898@alien.or.mcafeemobile.com>

On Mon, 9 Jul 2007, Davide Libenzi wrote:

> #define ZLOCK_INIT(l) (l)[0] = 0, (l)[1] = 0
> static inline void zlock(short *lock)
> {
> 	__asm__ __volatile__ ("lock ; xaddl %%eax, %0\n\t"
> 			      "mov %%eax, %%ebx\n\t"
> 			      "shr $16, %%ebx\n\t"
> 			      "1:\n\t"
> 			      "cmpw %%ax, %%bx\n\t"
> 			      "je 2f\n\t"
> 			      "rep ; nop\n\t"
- 			      "movw %1, %%bx\n\t"
+ 			      "movw %1, %%ax\n\t"
> 			      "lfence\n\t"
> 			      "jmp 1b\n\t"
> 			      "2:\n\t"
> 			    : "+m" (*(int *) lock)
> 			    : "m" (lock[0]), "a" (0x10000) : "ebx", "memory");
> }

Erm, modulo that bugger ;) that'd never should up in the non-contended 
case (and that does not change numbers):

inc-lock in cache takes 7.28ns
xadd-lock in cache takes 8.93ns
vadd-lock in cache takes 10.34ns
zadd-lock in cache takes 8.43ns
inc-lock out of cache takes 87.98ns
xadd-lock out of cache takes 88.89ns
vadd-lock out of cache takes 89.59ns
zadd-lock out of cache takes 89.86ns



- Davide



  reply	other threads:[~2007-07-09 19:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-08  4:32 Nick Piggin
2007-07-08 11:18 ` Andi Kleen
2007-07-08 10:40   ` Nick Piggin
2007-07-08 16:49   ` Linus Torvalds
2007-07-10 20:52   ` Christoph Lameter
2007-07-11  2:06     ` Nick Piggin
2007-07-11  2:26       ` Christoph Lameter
2007-07-11  4:51         ` Nick Piggin
2007-07-09 19:01 ` Davide Libenzi
2007-07-09 19:16   ` Davide Libenzi [this message]
2007-07-09 19:26   ` Linus Torvalds
2007-07-09 19:47     ` Davide Libenzi
2007-07-09 19:55       ` Linus Torvalds
2007-07-09 20:08         ` Linus Torvalds

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=Pine.LNX.4.64.0707091210510.15898@alien.or.mcafeemobile.com \
    --to=davidel@xmailserver.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --cc=torvalds@linux-foundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®