Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Three MULTIPROCESSOR + LOCKDEBUG fixes:
details: https://anonhg.NetBSD.org/src/rev/7901bac17c05
branches: trunk
changeset: 481939:7901bac17c05
user: sommerfeld <sommerfeld%NetBSD.org@localhost>
date: Wed Feb 09 16:46:09 2000 +0000
description:
Three MULTIPROCESSOR + LOCKDEBUG fixes:
1) fix typo preventing compilation (missing comma).
2) in SLOCK_WHERE, display cpu number in the MP case.
3) the folowing race condition was observed in _simple_lock:
cpu 1 releases lock,
cpu 0 grabs lock
cpu 1 sees it's already locked.
cpu 1 sees that lock_holder== "cpu 1"
cpu 1 assumes that it already holds it and barfs.
cpu 0 sets lock_holder == "cpu 0"
Fix: set lock_holder to LK_NOCPU in _simple_unlock().
diffstat:
sys/kern/kern_lock.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diffs (45 lines):
diff -r adde08afe2cc -r 7901bac17c05 sys/kern/kern_lock.c
--- a/sys/kern/kern_lock.c Wed Feb 09 16:24:03 2000 +0000
+++ b/sys/kern/kern_lock.c Wed Feb 09 16:46:09 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_lock.c,v 1.25 1999/08/27 01:14:38 thorpej Exp $ */
+/* $NetBSD: kern_lock.c,v 1.26 2000/02/09 16:46:09 sommerfeld Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -689,10 +689,17 @@
#define SLOCK_DEBUGGER() /* nothing */
#endif /* } */
+#ifdef MULTIPROCESSOR
+#define SLOCK_MP() lock_printf("on cpu %d\n", cpu_number())
+#else
+#define SLOCK_MP() /* nothing */
+#endif
+
#define SLOCK_WHERE(str, alp, id, l) \
do { \
lock_printf(str); \
- lock_printf("currently at: %s:%d\n", (id), (l)); \
+ lock_printf("lock: %p, currently at: %s:%d\n", (alp), (id), (l)); \
+ SLOCK_MP(); \
if ((alp)->lock_file != NULL) \
lock_printf("last locked: %s:%d\n", (alp)->lock_file, \
(alp)->lock_line); \
@@ -792,7 +799,7 @@
if ((rv = cpu_simple_lock_try(alp)) == 0) {
if (alp->lock_holder == cpu_id)
SLOCK_WHERE("simple_lock_try: locking against myself\n",
- alp, id l);
+ alp, id, l);
goto out;
}
#else
@@ -858,6 +865,7 @@
alp->unlock_line = l;
#if defined(MULTIPROCESSOR) /* { */
+ alp->lock_holder = LK_NOCPU;
/* Now that we've modified all fields, release the lock. */
cpu_simple_unlock(alp);
#else
Home |
Main Index |
Thread Index |
Old Index