public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Michel Lespinasse <walken@google.com>
Cc: dhowells@redhat.com, Andrew Morton <akpm@google.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: x86 rwsem: up_read() does not check active count in fast path
Date: Tue, 04 May 2010 13:41:36 +0100	[thread overview]
Message-ID: <30960.1272976896@redhat.com> (raw)
In-Reply-To: <20100503225105.GA18897@google.com>

Michel Lespinasse <walken@google.com> wrote:

> Looking at the x86 rwsem code, I have been wondering about the up_read()
> path.  __rwsem_do_wake() comment mentions that one should check the active
> count on the way there; however I could not find that check when coming from
> up_read().

Look in call_rwsem_wake(), which is implemented in assembly in two places in
the x86 arch:

	arch/x86/lib/rwsem_64.S
	arch/x86/lib/semaphore_32.S

Note that the x86_64 version contains a bug, a patch for which is attached.

David
---
From: David Howells <dhowells@redhat.com>
Subject: [PATCH] Fix the x86_64 implementation of call_rwsem_wait()

The x86_64 call_rwsem_wait() treats the active state counter part of the R/W
semaphore state as being 16-bit when it's actually 32-bit (it's half of the
64-bit state).  It should do "decl %edx" not "decw %dx".

Signed-off-by: David Howells <dhowells@redhat.com>
---

 arch/x86/lib/rwsem_64.S |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/arch/x86/lib/rwsem_64.S b/arch/x86/lib/rwsem_64.S
index 15acecf..41fcf00 100644
--- a/arch/x86/lib/rwsem_64.S
+++ b/arch/x86/lib/rwsem_64.S
@@ -60,7 +60,7 @@ ENTRY(call_rwsem_down_write_failed)
 	ENDPROC(call_rwsem_down_write_failed)
 
 ENTRY(call_rwsem_wake)
-	decw %dx    /* do nothing if still outstanding active readers */
+	decl %edx	/* do nothing if still outstanding active readers */
 	jnz 1f
 	save_common_regs
 	movq %rax,%rdi

  reply	other threads:[~2010-05-04 12:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-03 22:51 x86 rwsem: up_read() does not check active count in fast path Michel Lespinasse
2010-05-04 12:41 ` David Howells [this message]
2010-05-04 22:38   ` Michel Lespinasse

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=30960.1272976896@redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=walken@google.com \
    /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