Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys use lockstatus() instead of L_BIGLOCK to check if we're ...
details: https://anonhg.NetBSD.org/src/rev/c3a5e2f1240e
branches: trunk
changeset: 566721:c3a5e2f1240e
user: yamt <yamt%NetBSD.org@localhost>
date: Tue May 18 11:59:11 2004 +0000
description:
use lockstatus() instead of L_BIGLOCK to check if we're holding a biglock.
fix PR/25595.
diffstat:
sys/kern/kern_lock.c | 27 +++++++++++++++++++++++----
sys/kern/kern_sa.c | 6 +++---
sys/kern/kern_synch.c | 18 +++++-------------
sys/sys/lwp.h | 3 +--
sys/sys/systm.h | 8 +++++++-
5 files changed, 39 insertions(+), 23 deletions(-)
diffs (194 lines):
diff -r 25a37e9a65dd -r c3a5e2f1240e sys/kern/kern_lock.c
--- a/sys/kern/kern_lock.c Tue May 18 11:55:59 2004 +0000
+++ b/sys/kern/kern_lock.c Tue May 18 11:59:11 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_lock.c,v 1.76 2004/05/18 11:55:59 yamt Exp $ */
+/* $NetBSD: kern_lock.c,v 1.77 2004/05/18 11:59:11 yamt Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.76 2004/05/18 11:55:59 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.77 2004/05/18 11:59:11 yamt Exp $");
#include "opt_multiprocessor.h"
#include "opt_lockdebug.h"
@@ -1371,14 +1371,33 @@
SCHED_ASSERT_UNLOCKED();
spinlockmgr(&kernel_lock, LK_EXCLUSIVE, 0);
- l->l_flag |= L_BIGLOCK;
}
void
_kernel_proc_unlock(struct lwp *l)
{
- l->l_flag &= ~L_BIGLOCK;
spinlockmgr(&kernel_lock, LK_RELEASE, 0);
}
+
+int
+_kernel_lock_release_all()
+{
+ int hold_count;
+
+ if (lockstatus(&kernel_lock) == LK_EXCLUSIVE)
+ hold_count = spinlock_release_all(&kernel_lock);
+ else
+ hold_count = 0;
+
+ return hold_count;
+}
+
+void
+_kernel_lock_acquire_count(int hold_count)
+{
+
+ if (hold_count != 0)
+ spinlock_acquire_count(&kernel_lock, hold_count);
+}
#endif /* MULTIPROCESSOR */
diff -r 25a37e9a65dd -r c3a5e2f1240e sys/kern/kern_sa.c
--- a/sys/kern/kern_sa.c Tue May 18 11:55:59 2004 +0000
+++ b/sys/kern/kern_sa.c Tue May 18 11:59:11 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sa.c,v 1.50 2004/03/27 00:49:47 petrov Exp $ */
+/* $NetBSD: kern_sa.c,v 1.51 2004/05/18 11:59:11 yamt Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.50 2004/03/27 00:49:47 petrov Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sa.c,v 1.51 2004/05/18 11:59:11 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -622,7 +622,7 @@
int ret;
#if defined(MULTIPROCESSOR)
- KDASSERT(l->l_flag & L_BIGLOCK);
+ KDASSERT(lockstatus(&kernel_lock) == LK_EXCLUSIVE);
#endif
if (vp->savp_lwp != l) {
diff -r 25a37e9a65dd -r c3a5e2f1240e sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c Tue May 18 11:55:59 2004 +0000
+++ b/sys/kern/kern_synch.c Tue May 18 11:59:11 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_synch.c,v 1.143 2004/05/12 20:13:58 yamt Exp $ */
+/* $NetBSD: kern_synch.c,v 1.144 2004/05/18 11:59:11 yamt Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.143 2004/05/12 20:13:58 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.144 2004/05/18 11:59:11 yamt Exp $");
#include "opt_ddb.h"
#include "opt_ktrace.h"
@@ -840,23 +840,18 @@
struct rlimit *rlim;
long s, u;
struct timeval tv;
-#if defined(MULTIPROCESSOR)
- int hold_count = 0; /* XXX: gcc */
-#endif
+ int hold_count;
struct proc *p = l->l_proc;
int retval;
SCHED_ASSERT_LOCKED();
-#if defined(MULTIPROCESSOR)
/*
* Release the kernel_lock, as we are about to yield the CPU.
* The scheduler lock is still held until cpu_switch()
* selects a new process and removes it from the run queue.
*/
- if (l->l_flag & L_BIGLOCK)
- hold_count = spinlock_release_all(&kernel_lock);
-#endif
+ hold_count = KERNEL_LOCK_RELEASE_ALL();
KDASSERT(l->l_cpu != NULL);
KDASSERT(l->l_cpu == curcpu());
@@ -967,15 +962,12 @@
KDASSERT(l->l_cpu == curcpu());
microtime(&l->l_cpu->ci_schedstate.spc_runtime);
-#if defined(MULTIPROCESSOR)
/*
* Reacquire the kernel_lock now. We do this after we've
* released the scheduler lock to avoid deadlock, and before
* we reacquire the interlock.
*/
- if (l->l_flag & L_BIGLOCK)
- spinlock_acquire_count(&kernel_lock, hold_count);
-#endif
+ KERNEL_LOCK_ACQUIRE_COUNT(hold_count);
return retval;
}
diff -r 25a37e9a65dd -r c3a5e2f1240e sys/sys/lwp.h
--- a/sys/sys/lwp.h Tue May 18 11:55:59 2004 +0000
+++ b/sys/sys/lwp.h Tue May 18 11:59:11 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lwp.h,v 1.21 2004/03/14 01:08:47 cl Exp $ */
+/* $NetBSD: lwp.h,v 1.22 2004/05/18 11:59:11 yamt Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -109,7 +109,6 @@
#define L_SINTR 0x00080 /* Sleep is interruptible. */
#define L_TIMEOUT 0x00400 /* Timing out during sleep. */
#define L_PROCEXIT 0x00800 /* In process exit, l_proc no longer valid */
-#define L_BIGLOCK 0x80000 /* LWP needs kernel "big lock" to run */
#define L_SA 0x100000 /* Scheduler activations LWP */
#define L_SA_UPCALL 0x200000 /* SA upcall is pending */
#define L_SA_BLOCKING 0x400000 /* Blocking in tsleep() */
diff -r 25a37e9a65dd -r c3a5e2f1240e sys/sys/systm.h
--- a/sys/sys/systm.h Tue May 18 11:55:59 2004 +0000
+++ b/sys/sys/systm.h Tue May 18 11:59:11 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: systm.h,v 1.171 2004/04/21 20:31:50 matt Exp $ */
+/* $NetBSD: systm.h,v 1.172 2004/05/18 11:59:11 yamt Exp $ */
/*-
* Copyright (c) 1982, 1988, 1991, 1993
@@ -442,12 +442,16 @@
void _kernel_unlock(void);
void _kernel_proc_lock(struct lwp *);
void _kernel_proc_unlock(struct lwp *);
+int _kernel_lock_release_all(void);
+void _kernel_lock_acquire_count(int);
#define KERNEL_LOCK_INIT() _kernel_lock_init()
#define KERNEL_LOCK(flag) _kernel_lock((flag))
#define KERNEL_UNLOCK() _kernel_unlock()
#define KERNEL_PROC_LOCK(l) _kernel_proc_lock((l))
#define KERNEL_PROC_UNLOCK(l) _kernel_proc_unlock((l))
+#define KERNEL_LOCK_RELEASE_ALL() _kernel_lock_release_all()
+#define KERNEL_LOCK_ACQUIRE_COUNT(count) _kernel_lock_acquire_count(count)
#else /* ! MULTIPROCESSOR */
@@ -456,6 +460,8 @@
#define KERNEL_UNLOCK() /* nothing */
#define KERNEL_PROC_LOCK(l) /* nothing */
#define KERNEL_PROC_UNLOCK(l) /* nothing */
+#define KERNEL_LOCK_RELEASE_ALL() (0)
+#define KERNEL_LOCK_ACQUIRE_COUNT(count) /* nothing */
#endif /* MULTIPROCESSOR */
Home |
Main Index |
Thread Index |
Old Index