diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2010-09-28 20:27:57 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2010-09-28 20:27:57 +0000 |
commit | 15969dfa68e37d305dd11968e20ca0a425d2092a (patch) | |
tree | ff5f69008da4bbcba278d383b53bb927776d4644 /sys/arch/sparc64 | |
parent | 23487e0f53f72934a66dcf7e42b399ec6562e966 (diff) |
Implement a per-cpu held mutex counter if DIAGNOSTIC on all non-x86 platforms,
to complete matthew@'s commit of a few days ago, and drop __HAVE_CPU_MUTEX_LEVEL
define. With help from, and ok deraadt@.
Diffstat (limited to 'sys/arch/sparc64')
-rw-r--r-- | sys/arch/sparc64/include/cpu.h | 6 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/genassym.cf | 5 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/mutex.S | 18 |
3 files changed, 26 insertions, 3 deletions
diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h index 2ac13e33306..dcee1819254 100644 --- a/sys/arch/sparc64/include/cpu.h +++ b/sys/arch/sparc64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.72 2009/03/26 17:24:33 oga Exp $ */ +/* $OpenBSD: cpu.h,v 1.73 2010/09/28 20:27:55 miod Exp $ */ /* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */ /* @@ -148,6 +148,10 @@ struct cpu_info { paddr_t ci_cpuset; paddr_t ci_mondo; #endif + +#ifdef DIAGNOSTIC + int ci_mutex_level; +#endif }; #define CPUF_RUNNING 0x0001 /* CPU is running */ diff --git a/sys/arch/sparc64/sparc64/genassym.cf b/sys/arch/sparc64/sparc64/genassym.cf index 563d79ad446..5b19a21685e 100644 --- a/sys/arch/sparc64/sparc64/genassym.cf +++ b/sys/arch/sparc64/sparc64/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.33 2008/08/07 18:46:04 kettenis Exp $ +# $OpenBSD: genassym.cf,v 1.34 2010/09/28 20:27:55 miod Exp $ # $NetBSD: genassym.cf,v 1.23 2001/08/08 00:09:30 eeh Exp $ # @@ -158,6 +158,9 @@ member ci_mmfsa member ci_cpumq member ci_devmq endif +ifdef DIAGNOSTIC +member ci_mutex_level +endif # FPU state struct fpstate64 diff --git a/sys/arch/sparc64/sparc64/mutex.S b/sys/arch/sparc64/sparc64/mutex.S index 5ae4267c361..987d801e554 100644 --- a/sys/arch/sparc64/sparc64/mutex.S +++ b/sys/arch/sparc64/sparc64/mutex.S @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.S,v 1.6 2009/08/13 13:24:55 weingart Exp $ */ +/* $OpenBSD: mutex.S,v 1.7 2010/09/28 20:27:55 miod Exp $ */ /* * Copyright (c) 2007 Mark Kettenis @@ -72,6 +72,11 @@ ENTRY(mtx_enter) ba,a 1b 4: stw %g4, [%o0 + MTX_OLDIPL] +#ifdef DIAGNOSTIC + ld [%g1 + CI_MUTEX_LEVEL], %g5 + add %g5, 1, %g5 + st %g5, [%g1 + CI_MUTEX_LEVEL] +#endif retl membar #LoadLoad | #LoadStore @@ -98,11 +103,22 @@ ENTRY(mtx_enter_try) mov 0, %o0 3: stw %g4, [%o0 + MTX_OLDIPL] +#ifdef DIAGNOSTIC + ld [%g1 + CI_MUTEX_LEVEL], %g5 + add %g5, 1, %g5 + st %g5, [%g1 + CI_MUTEX_LEVEL] +#endif membar #LoadLoad | #LoadStore retl mov 1, %o0 ENTRY(mtx_leave) +#ifdef DIAGNOSTIC + GET_CURCPU(%g1) + ld [%g1 + CI_MUTEX_LEVEL], %g5 + sub %g5, 1, %g5 + st %g5, [%g1 + CI_MUTEX_LEVEL] +#endif ld [%o0 + MTX_OLDIPL], %g1 membar #StoreStore | #LoadStore stx %g0, [%o0 + MTX_OWNER] |