Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch After lots of testing I'm not convinced of the bene...



details:   https://anonhg.NetBSD.org/src/rev/e8dfc638b076
branches:  trunk
changeset: 1005464:e8dfc638b076
user:      ad <ad%NetBSD.org@localhost>
date:      Sun Dec 08 20:00:56 2019 +0000

description:
After lots of testing I'm not convinced of the benefit to the tweak
I made to rw_enter(), so undo it to return to baseline.

diffstat:

 sys/arch/amd64/amd64/lock_stubs.S |  20 +++++++++-----------
 sys/arch/i386/i386/lock_stubs.S   |  21 +++++++++------------
 2 files changed, 18 insertions(+), 23 deletions(-)

diffs (138 lines):

diff -r 871d6dbcef8d -r e8dfc638b076 sys/arch/amd64/amd64/lock_stubs.S
--- a/sys/arch/amd64/amd64/lock_stubs.S Sun Dec 08 19:52:37 2019 +0000
+++ b/sys/arch/amd64/amd64/lock_stubs.S Sun Dec 08 20:00:56 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock_stubs.S,v 1.34 2019/11/23 16:36:38 ad Exp $       */
+/*     $NetBSD: lock_stubs.S,v 1.35 2019/12/08 20:00:56 ad Exp $       */
 
 /*
  * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -191,15 +191,13 @@
  * Acquire one hold on a RW lock.
  */
 ENTRY(rw_enter)
-       xorl    %eax, %eax
-       testl   %esi, %esi      /* RW_READER = 0 */
+       cmpl    $RW_READER, %esi
        jne     2f
 
        /*
-        * Reader, and no existing readers on the lock: this is a most
-        * common case.  Instead of reading from the lock word, use cmpxchg
-        * and get the cache line into the EXCLUSIVE state to begin with.
+        * Reader: this is the most common case.
         */
+       movq    (%rdi), %rax
 0:
        testb   $(RW_WRITE_LOCKED|RW_WRITE_WANTED), %al
        jnz     3f
@@ -215,6 +213,7 @@
         * Writer: if the compare-and-set fails, don't bother retrying.
         */
 2:     movq    CPUVAR(CURLWP), %rcx
+       xorq    %rax, %rax
        orq     $RW_WRITE_LOCKED, %rcx
        LOCK
        cmpxchgq %rcx, (%rdi)
@@ -269,15 +268,13 @@
  * Try to acquire one hold on a RW lock.
  */
 ENTRY(rw_tryenter)
-       xorl    %eax, %eax
-       testl   %esi, %esi      /* RW_READER = 0 */
+       cmpl    $RW_READER, %esi
        jne     2f
 
        /*
-        * Reader, and no existing readers on the lock: this is a most
-        * common case.  Instead of reading from the lock word, use cmpxchg
-        * and get the cache line into the EXCLUSIVE state to begin with.
+        * Reader: this is the most common case.
         */
+       movq    (%rdi), %rax
 0:
        testb   $(RW_WRITE_LOCKED|RW_WRITE_WANTED), %al
        jnz     4f
@@ -294,6 +291,7 @@
         * Writer: if the compare-and-set fails, don't bother retrying.
         */
 2:     movq    CPUVAR(CURLWP), %rcx
+       xorq    %rax, %rax
        orq     $RW_WRITE_LOCKED, %rcx
        LOCK
        cmpxchgq %rcx, (%rdi)
diff -r 871d6dbcef8d -r e8dfc638b076 sys/arch/i386/i386/lock_stubs.S
--- a/sys/arch/i386/i386/lock_stubs.S   Sun Dec 08 19:52:37 2019 +0000
+++ b/sys/arch/i386/i386/lock_stubs.S   Sun Dec 08 20:00:56 2019 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: lock_stubs.S,v 1.31 2019/11/23 16:36:38 ad Exp $       */
+/*     $NetBSD: lock_stubs.S,v 1.32 2019/12/08 20:00:56 ad Exp $       */
 
 /*-
- * Copyright (c) 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -35,7 +35,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: lock_stubs.S,v 1.31 2019/11/23 16:36:38 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lock_stubs.S,v 1.32 2019/12/08 20:00:56 ad Exp $");
 
 #include "opt_lockdebug.h"
 
@@ -104,15 +104,13 @@
  */
 ENTRY(rw_enter)
        movl    4(%esp), %edx
-       xorl    %eax, %eax
        cmpl    $RW_READER, 8(%esp)
        jne     2f
 
        /*
-        * Reader, and no existing readers on the lock: this is a most
-        * common case.  Instead of reading from the lock word, use cmpxchg
-        * and get the cache line into the EXCLUSIVE state to begin with.
+        * Reader
         */
+       movl    (%edx), %eax
 0:
        testb   $(RW_WRITE_LOCKED|RW_WRITE_WANTED), %al
        jnz     3f
@@ -127,7 +125,7 @@
        /*
         * Writer
         */
-2:
+2:     xorl    %eax, %eax
        movl    %fs:CPU_INFO_CURLWP(%eax), %ecx
        orl     $RW_WRITE_LOCKED, %ecx
        LOCK(3)
@@ -188,15 +186,13 @@
  */
 ENTRY(rw_tryenter)
        movl    4(%esp), %edx
-       xorl    %eax, %eax
        cmpl    $RW_READER, 8(%esp)
        jne     2f
 
        /*
-        * Reader, and no existing readers on the lock: this is a most
-        * common case.  Instead of reading from the lock word, use cmpxchg
-        * and get the cache line into the EXCLUSIVE state to begin with.
+        * Reader
         */
+       movl    (%edx), %eax
 0:
        testb   $(RW_WRITE_LOCKED|RW_WRITE_WANTED), %al
        jnz     4f
@@ -213,6 +209,7 @@
         * Writer
         */
 2:
+       xorl    %eax, %eax
        movl    %fs:CPU_INFO_CURLWP(%eax), %ecx
        orl     $RW_WRITE_LOCKED, %ecx
        LOCK(13)



Home | Main Index | Thread Index | Old Index