Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/ad-namecache]: src/sys/sys Adaptive rwlocks proposed on tech-kern and wo...
details: https://anonhg.NetBSD.org/src/rev/e0303cafde7f
branches: ad-namecache
changeset: 982994:e0303cafde7f
user: ad <ad%NetBSD.org@localhost>
date: Sun Jan 19 21:08:29 2020 +0000
description:
Adaptive rwlocks proposed on tech-kern and working well on this branch
with vnode locks.
diffstat:
sys/arch/amd64/amd64/genassym.cf | 12 +-
sys/arch/amd64/amd64/lock_stubs.S | 122 +-----------
sys/arch/i386/i386/genassym.cf | 12 +-
sys/arch/i386/i386/lock_stubs.S | 130 +------------
sys/kern/kern_rwlock.c | 403 +++++++++++++++++++++++++++++--------
sys/kern/kern_synch.c | 8 +-
sys/sys/lwp.h | 3 +-
7 files changed, 329 insertions(+), 361 deletions(-)
diffs (truncated from 1035 to 300 lines):
diff -r 37f590a8ab79 -r e0303cafde7f sys/arch/amd64/amd64/genassym.cf
--- a/sys/arch/amd64/amd64/genassym.cf Sun Jan 19 19:44:34 2020 +0000
+++ b/sys/arch/amd64/amd64/genassym.cf Sun Jan 19 21:08:29 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.80.2.1 2020/01/17 21:47:22 ad Exp $
+# $NetBSD: genassym.cf,v 1.80.2.2 2020/01/19 21:08:29 ad Exp $
#
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -78,7 +78,6 @@
include <sys/device.h>
include <sys/mbuf.h>
include <sys/mutex.h>
-include <sys/rwlock.h>
include <sys/cpu_data.h>
include <sys/evcnt.h>
include <sys/cpu.h>
@@ -346,15 +345,6 @@
define MTX_LOCK offsetof(struct kmutex, u.s.mtxs_lock)
define MTX_OWNER offsetof(struct kmutex, u.mtxa_owner)
-define RW_OWNER offsetof(struct krwlock, rw_owner)
-define RW_WRITE_LOCKED RW_WRITE_LOCKED
-define RW_WRITE_WANTED RW_WRITE_WANTED
-define RW_READ_INCR RW_READ_INCR
-define RW_HAS_WAITERS RW_HAS_WAITERS
-define RW_THREAD RW_THREAD
-define RW_READER RW_READER
-define RW_WRITER RW_WRITER
-
define EV_COUNT offsetof(struct evcnt, ev_count)
define OPTERON_MSR_PASSCODE OPTERON_MSR_PASSCODE
diff -r 37f590a8ab79 -r e0303cafde7f sys/arch/amd64/amd64/lock_stubs.S
--- a/sys/arch/amd64/amd64/lock_stubs.S Sun Jan 19 19:44:34 2020 +0000
+++ b/sys/arch/amd64/amd64/lock_stubs.S Sun Jan 19 21:08:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock_stubs.S,v 1.35 2019/12/08 20:00:56 ad Exp $ */
+/* $NetBSD: lock_stubs.S,v 1.35.2.1 2020/01/19 21:08:29 ad Exp $ */
/*
* Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -185,126 +185,6 @@
END(mutex_spin_exit)
-/*
- * void rw_enter(krwlock_t *rwl, krw_t op);
- *
- * Acquire one hold on a RW lock.
- */
-ENTRY(rw_enter)
- cmpl $RW_READER, %esi
- jne 2f
-
- /*
- * Reader: this is the most common case.
- */
- movq (%rdi), %rax
-0:
- testb $(RW_WRITE_LOCKED|RW_WRITE_WANTED), %al
- jnz 3f
- leaq RW_READ_INCR(%rax), %rdx
- LOCK
- cmpxchgq %rdx, (%rdi)
- jnz 1f
- RET
-1:
- jmp 0b
-
- /*
- * 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)
- jnz 3f
- RET
-3:
- jmp _C_LABEL(rw_vector_enter)
-END(rw_enter)
-
-/*
- * void rw_exit(krwlock_t *rwl);
- *
- * Release one hold on a RW lock.
- */
-ENTRY(rw_exit)
- movq (%rdi), %rax
- testb $RW_WRITE_LOCKED, %al
- jnz 2f
-
- /*
- * Reader
- */
-0: testb $RW_HAS_WAITERS, %al
- jnz 3f
- cmpq $RW_READ_INCR, %rax
- jb 3f
- leaq -RW_READ_INCR(%rax), %rdx
- LOCK
- cmpxchgq %rdx, (%rdi)
- jnz 1f
- ret
-1:
- jmp 0b
-
- /*
- * Writer
- */
-2: leaq -RW_WRITE_LOCKED(%rax), %rdx
- subq CPUVAR(CURLWP), %rdx
- jnz 3f
- LOCK
- cmpxchgq %rdx, (%rdi)
- jnz 3f
- ret
-
-3: jmp _C_LABEL(rw_vector_exit)
-END(rw_exit)
-
-/*
- * int rw_tryenter(krwlock_t *rwl, krw_t op);
- *
- * Try to acquire one hold on a RW lock.
- */
-ENTRY(rw_tryenter)
- cmpl $RW_READER, %esi
- jne 2f
-
- /*
- * Reader: this is the most common case.
- */
- movq (%rdi), %rax
-0:
- testb $(RW_WRITE_LOCKED|RW_WRITE_WANTED), %al
- jnz 4f
- leaq RW_READ_INCR(%rax), %rdx
- LOCK
- cmpxchgq %rdx, (%rdi)
- jnz 1f
- movl %edx, %eax /* nonzero */
- RET
-1:
- jmp 0b
-
- /*
- * 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)
- movl $0, %eax
- setz %al
-3:
- RET
- ret
-4:
- xorl %eax, %eax
- jmp 3b
-END(rw_tryenter)
-
#endif /* LOCKDEBUG */
/*
diff -r 37f590a8ab79 -r e0303cafde7f sys/arch/i386/i386/genassym.cf
--- a/sys/arch/i386/i386/genassym.cf Sun Jan 19 19:44:34 2020 +0000
+++ b/sys/arch/i386/i386/genassym.cf Sun Jan 19 21:08:29 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.117.2.1 2020/01/17 21:47:25 ad Exp $
+# $NetBSD: genassym.cf,v 1.117.2.2 2020/01/19 21:08:29 ad Exp $
#
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -79,7 +79,6 @@
include <sys/device.h>
include <sys/mbuf.h>
include <sys/mutex.h>
-include <sys/rwlock.h>
include <sys/cpu.h>
include <netinet/in.h>
@@ -354,15 +353,6 @@
define MTX_LOCK offsetof(struct kmutex, mtx_lock)
define MTX_OWNER offsetof(struct kmutex, u.mtxa_owner)
-define RW_OWNER offsetof(struct krwlock, rw_owner)
-define RW_WRITE_LOCKED RW_WRITE_LOCKED
-define RW_WRITE_WANTED RW_WRITE_WANTED
-define RW_READ_INCR RW_READ_INCR
-define RW_HAS_WAITERS RW_HAS_WAITERS
-define RW_THREAD RW_THREAD
-define RW_READER RW_READER
-define RW_WRITER RW_WRITER
-
define EV_COUNT offsetof(struct evcnt, ev_count)
define OPTERON_MSR_PASSCODE OPTERON_MSR_PASSCODE
diff -r 37f590a8ab79 -r e0303cafde7f sys/arch/i386/i386/lock_stubs.S
--- a/sys/arch/i386/i386/lock_stubs.S Sun Jan 19 19:44:34 2020 +0000
+++ b/sys/arch/i386/i386/lock_stubs.S Sun Jan 19 21:08:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock_stubs.S,v 1.32 2019/12/08 20:00:56 ad Exp $ */
+/* $NetBSD: lock_stubs.S,v 1.32.2.1 2020/01/19 21:08:29 ad Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: lock_stubs.S,v 1.32 2019/12/08 20:00:56 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lock_stubs.S,v 1.32.2.1 2020/01/19 21:08:29 ad Exp $");
#include "opt_lockdebug.h"
@@ -97,132 +97,6 @@
jmp _C_LABEL(mutex_vector_exit)
END(mutex_exit)
-/*
- * void rw_enter(krwlock_t *rwl, krw_t op);
- *
- * Acquire one hold on a RW lock.
- */
-ENTRY(rw_enter)
- movl 4(%esp), %edx
- cmpl $RW_READER, 8(%esp)
- jne 2f
-
- /*
- * Reader
- */
- movl (%edx), %eax
-0:
- testb $(RW_WRITE_LOCKED|RW_WRITE_WANTED), %al
- jnz 3f
- leal RW_READ_INCR(%eax), %ecx
- LOCK(2)
- cmpxchgl %ecx, (%edx)
- jnz 1f
- RET(2)
-1:
- jmp 0b
-
- /*
- * Writer
- */
-2: xorl %eax, %eax
- movl %fs:CPU_INFO_CURLWP(%eax), %ecx
- orl $RW_WRITE_LOCKED, %ecx
- LOCK(3)
- cmpxchgl %ecx, (%edx)
- jnz 3f
- RET(3)
-3:
- jmp _C_LABEL(rw_vector_enter)
-END(rw_enter)
-
-/*
- * void rw_exit(krwlock_t *rwl);
- *
- * Release one hold on a RW lock.
- */
-ENTRY(rw_exit)
- movl 4(%esp), %edx
- movl (%edx), %eax
- testb $RW_WRITE_LOCKED, %al
- jnz 2f
-
- /*
- * Reader
- */
-0: testb $RW_HAS_WAITERS, %al
- jnz 3f
- cmpl $RW_READ_INCR, %eax
- jb 3f
- leal -RW_READ_INCR(%eax), %ecx
- LOCK(4)
- cmpxchgl %ecx, (%edx)
- jnz 1f
- ret
-1:
- jmp 0b
-
- /*
- * Writer
- */
-2: leal -RW_WRITE_LOCKED(%eax), %ecx
- subl CPUVAR(CURLWP), %ecx
- jnz 3f
- LOCK(5)
- cmpxchgl %ecx, (%edx)
- jnz 3f
- ret
-
Home |
Main Index |
Thread Index |
Old Index