[lkml]   [2010]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: x86 rwsem: up_read() does not check active count in fast path
Michel Lespinasse <> 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:


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

From: David Howells <>
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 <>

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)

- decw %dx /* do nothing if still outstanding active readers */
+ decl %edx /* do nothing if still outstanding active readers */
jnz 1f
movq %rax,%rdi

 \ /
  Last update: 2010-05-04 14:45    [W:0.044 / U:55.456 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site