diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2000-12-12 03:49:58 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2000-12-12 03:49:58 +0000 |
| commit | 18f619abce48ab7f1f09c8524c78c48c365a4777 (patch) | |
| tree | 74176b486d9cc0a4b1d100499cd64977ac91a23c | |
| parent | 61d68d6cb89aca251d46e64c5f6086f94321e43c (diff) | |
Notes
| -rw-r--r-- | sys/amd64/include/mutex.h | 41 | ||||
| -rw-r--r-- | sys/i386/include/mutex.h | 41 |
2 files changed, 76 insertions, 6 deletions
diff --git a/sys/amd64/include/mutex.h b/sys/amd64/include/mutex.h index 8bf6e953c336..95d117a4a087 100644 --- a/sys/amd64/include/mutex.h +++ b/sys/amd64/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; \ diff --git a/sys/i386/include/mutex.h b/sys/i386/include/mutex.h index 8bf6e953c336..95d117a4a087 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; \ |
