Module Name: src
Committed By: ad
Date: Sun Dec 8 20:00:56 UTC 2019
Modified Files:
src/sys/arch/amd64/amd64: lock_stubs.S
src/sys/arch/i386/i386: lock_stubs.S
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amd64/amd64/lock_stubs.S
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/i386/i386/lock_stubs.S
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amd64/amd64/lock_stubs.S
diff -u src/sys/arch/amd64/amd64/lock_stubs.S:1.34 src/sys/arch/amd64/amd64/lock_stubs.S:1.35
--- src/sys/arch/amd64/amd64/lock_stubs.S:1.34 Sat Nov 23 16:36:38 2019
+++ src/sys/arch/amd64/amd64/lock_stubs.S Sun Dec 8 20:00:56 2019
@@ -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 @@ END(mutex_spin_exit)
* 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 @@ ENTRY(rw_enter)
* 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 @@ END(rw_exit)
* 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 @@ ENTRY(rw_tryenter)
* 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)
Index: src/sys/arch/i386/i386/lock_stubs.S
diff -u src/sys/arch/i386/i386/lock_stubs.S:1.31 src/sys/arch/i386/i386/lock_stubs.S:1.32
--- src/sys/arch/i386/i386/lock_stubs.S:1.31 Sat Nov 23 16:36:38 2019
+++ src/sys/arch/i386/i386/lock_stubs.S Sun Dec 8 20:00:56 2019
@@ -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 @@ END(mutex_exit)
*/
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 @@ ENTRY(rw_enter)
/*
* Writer
*/
-2:
+2: xorl %eax, %eax
movl %fs:CPU_INFO_CURLWP(%eax), %ecx
orl $RW_WRITE_LOCKED, %ecx
LOCK(3)
@@ -188,15 +186,13 @@ END(rw_exit)
*/
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 @@ ENTRY(rw_tryenter)
* Writer
*/
2:
+ xorl %eax, %eax
movl %fs:CPU_INFO_CURLWP(%eax), %ecx
orl $RW_WRITE_LOCKED, %ecx
LOCK(13)