diff options
author | jhb <jhb@FreeBSD.org> | 2000-12-12 03:49:58 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2000-12-12 03:49:58 +0000 |
commit | e1f16f459e131a27f41f02692b2b26c6f1316def (patch) | |
tree | 3c8ca7d7a06dc69ee7cc1a50ce373c9e196978b0 /sys/i386 | |
parent | 1511ebc38e064cc4db55a6501af314da6378a927 (diff) | |
download | FreeBSD-src-e1f16f459e131a27f41f02692b2b26c6f1316def.zip FreeBSD-src-e1f16f459e131a27f41f02692b2b26c6f1316def.tar.gz |
Fix the assembly mutex macros to call the appropriate witness functions if
the witness code is compiled in. Without this, the witness code doesn't
notice that sched_lock is released by fork_trampoline() and thus gets all
confused about spin lock order later on.
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/include/mutex.h | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/sys/i386/include/mutex.h b/sys/i386/include/mutex.h index 8bf6e95..95d117a 100644 --- a/sys/i386/include/mutex.h +++ b/sys/i386/include/mutex.h @@ -261,6 +261,36 @@ extern char STR_SIEN[]; * Simple assembly macros to get and release spin locks. */ +#ifdef WITNESS +#define WITNESS_ENTER(lck, reg) \ + movl lck+MTX_DEBUG,reg; \ + cmpl $0,MTXD_WITNESS(reg); \ + jz 1f; \ + pushl $0; \ + pushl $0; \ + pushl $MTX_SPIN; \ + pushl $lck; \ + call witness_enter; \ + addl $0x10,%esp; \ +1: + +#define WITNESS_EXIT(lck, reg) \ + movl lck+MTX_DEBUG,reg; \ + cmpl $0,MTXD_WITNESS(reg); \ + jz 1f; \ + pushl $0; \ + pushl $0; \ + pushl $MTX_SPIN; \ + pushl $lck; \ + call witness_exit; \ + addl $0x10,%esp; \ +1: + +#else +#define WITNESS_ENTER(lck, reg) +#define WITNESS_EXIT(lck, reg) +#endif + #if defined(I386_CPU) #define MTX_ENTER(lck, reg) \ @@ -268,9 +298,11 @@ extern char STR_SIEN[]; pushfl; \ cli; \ movl reg,lck+MTX_LOCK; \ - popl lck+MTX_SAVEINTR; + popl lck+MTX_SAVEINTR; \ + WITNESS_ENTER(lck, reg) #define MTX_EXIT(lck, reg) \ + WITNESS_EXIT(lck, reg) \ pushl lck+MTX_SAVEINTR; \ movl $ MTX_UNOWNED,lck+MTX_LOCK; \ popfl; @@ -285,10 +317,12 @@ extern char STR_SIEN[]; MPLOCKED \ cmpxchgl reg,lck+MTX_LOCK; \ jnz 9b; \ - popl lck+MTX_SAVEINTR; + popl lck+MTX_SAVEINTR; \ + WITNESS_ENTER(lck, reg) /* Must use locked bus op (cmpxchg) when setting to unowned (barrier) */ #define MTX_EXIT(lck, reg) \ + WITNESS_EXIT(lck, reg) \ pushl lck+MTX_SAVEINTR; \ movl lck+MTX_LOCK,%eax; \ movl $ MTX_UNOWNED,reg; \ @@ -311,9 +345,10 @@ extern char STR_SIEN[]; popl lck+MTX_SAVEINTR; \ jmp 9f; \ 8: add $4,%esp; \ -9: +9: WITNESS_ENTER(lck, reg) #define MTX_EXIT_WITH_RECURSION(lck, reg) \ + WITNESS_EXIT(lck, reg) \ movl lck+MTX_RECURSE,%eax; \ decl %eax; \ js 8f; \ |