Diff below is mostly cosmetic. The only real change is that `mtx_owner' becomes the first field of 'struct mutex' on i386/amd64/arm64.
ok? Index: amd64/include/mutex.h =================================================================== RCS file: /cvs/src/sys/arch/amd64/include/mutex.h,v retrieving revision 1.8 diff -u -p -r1.8 mutex.h --- amd64/include/mutex.h 20 Apr 2017 13:57:29 -0000 1.8 +++ amd64/include/mutex.h 9 Jan 2018 16:01:41 -0000 @@ -24,15 +24,16 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #ifndef _MACHINE_MUTEX_H_ #define _MACHINE_MUTEX_H_ #include <sys/_lock.h> struct mutex { + volatile void *mtx_owner; int mtx_wantipl; int mtx_oldipl; - volatile void *mtx_owner; #ifdef WITNESS struct lock_object mtx_lock_obj; #endif @@ -54,15 +55,16 @@ struct mutex { #ifdef WITNESS #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { __MUTEX_IPL((ipl)), 0, NULL, MTX_LO_INITIALIZER(name, flags) } + { NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) } #else #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { __MUTEX_IPL((ipl)), 0, NULL } + { NULL, __MUTEX_IPL((ipl)), IPL_NONE } #endif void __mtx_init(struct mutex *, int); #define _mtx_init(mtx, ipl) __mtx_init((mtx), __MUTEX_IPL((ipl))) +#ifdef DIAGNOSTIC #define MUTEX_ASSERT_LOCKED(mtx) do { \ if ((mtx)->mtx_owner != curcpu()) \ panic("mutex %p not held in %s", (mtx), __func__); \ @@ -72,8 +74,12 @@ void __mtx_init(struct mutex *, int); if ((mtx)->mtx_owner == curcpu()) \ panic("mutex %p held in %s", (mtx), __func__); \ } while (0) +#else +#define MUTEX_ASSERT_LOCKED(mtx) do { } while (0) +#define MUTEX_ASSERT_UNLOCKED(mtx) do { } while (0) +#endif #define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj) #define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl -#endif +#endif /* _MACHINE_MUTEX_H_ */ Index: arm64/include/mutex.h =================================================================== RCS file: /cvs/src/sys/arch/arm64/include/mutex.h,v retrieving revision 1.2 diff -u -p -r1.2 mutex.h --- arm64/include/mutex.h 20 Apr 2017 13:57:29 -0000 1.2 +++ arm64/include/mutex.h 9 Jan 2018 15:56:26 -0000 @@ -24,15 +24,16 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #ifndef _MACHINE_MUTEX_H_ #define _MACHINE_MUTEX_H_ #include <sys/_lock.h> struct mutex { + volatile void *mtx_owner; int mtx_wantipl; int mtx_oldipl; - volatile void *mtx_owner; #ifdef WITNESS struct lock_object mtx_lock_obj; #endif @@ -54,15 +55,16 @@ struct mutex { #ifdef WITNESS #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { __MUTEX_IPL((ipl)), 0, NULL, MTX_LO_INITIALIZER(name, flags) } + { NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) } #else #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { __MUTEX_IPL((ipl)), 0, NULL } + { NULL, __MUTEX_IPL((ipl)), IPL_NONE } #endif void __mtx_init(struct mutex *, int); #define _mtx_init(mtx, ipl) __mtx_init((mtx), __MUTEX_IPL((ipl))) +#ifdef DIAGNOSTIC #define MUTEX_ASSERT_LOCKED(mtx) do { \ if ((mtx)->mtx_owner != curcpu()) \ panic("mutex %p not held in %s", (mtx), __func__); \ @@ -72,8 +74,12 @@ void __mtx_init(struct mutex *, int); if ((mtx)->mtx_owner == curcpu()) \ panic("mutex %p held in %s", (mtx), __func__); \ } while (0) +#else +#define MUTEX_ASSERT_LOCKED(mtx) do { } while (0) +#define MUTEX_ASSERT_UNLOCKED(mtx) do { } while (0) +#endif #define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj) #define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl -#endif +#endif /* _MACHINE_MUTEX_H_ */ Index: i386/include/mutex.h =================================================================== RCS file: /cvs/src/sys/arch/i386/include/mutex.h,v retrieving revision 1.10 diff -u -p -r1.10 mutex.h --- i386/include/mutex.h 4 Jan 2018 11:03:48 -0000 1.10 +++ i386/include/mutex.h 9 Jan 2018 15:57:34 -0000 @@ -24,15 +24,16 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #ifndef _MACHINE_MUTEX_H_ #define _MACHINE_MUTEX_H_ #include <sys/_lock.h> struct mutex { + volatile void *mtx_owner; int mtx_wantipl; int mtx_oldipl; - volatile void *mtx_owner; #ifdef WITNESS struct lock_object mtx_lock_obj; #endif @@ -54,15 +55,16 @@ struct mutex { #ifdef WITNESS #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { __MUTEX_IPL((ipl)), 0, NULL, MTX_LO_INITIALIZER(name, flags) } + { NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) } #else #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { __MUTEX_IPL((ipl)), 0, NULL } + { NULL, __MUTEX_IPL((ipl)), IPL_NONE } #endif void __mtx_init(struct mutex *, int); #define _mtx_init(mtx, ipl) __mtx_init((mtx), __MUTEX_IPL((ipl))) +#ifdef DIAGNOSTIC #define MUTEX_ASSERT_LOCKED(mtx) do { \ if ((mtx)->mtx_owner != curcpu()) \ panic("mutex %p not held in %s", (mtx), __func__); \ @@ -72,8 +74,12 @@ void __mtx_init(struct mutex *, int); if ((mtx)->mtx_owner == curcpu()) \ panic("mutex %p held in %s", (mtx), __func__); \ } while (0) +#else +#define MUTEX_ASSERT_LOCKED(mtx) do { } while (0) +#define MUTEX_ASSERT_UNLOCKED(mtx) do { } while (0) +#endif #define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj) #define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl -#endif +#endif /* _MACHINE_MUTEX_H_ */ Index: mips64/include/mutex.h =================================================================== RCS file: /cvs/src/sys/arch/mips64/include/mutex.h,v retrieving revision 1.3 diff -u -p -r1.3 mutex.h --- mips64/include/mutex.h 4 Jan 2018 11:03:48 -0000 1.3 +++ mips64/include/mutex.h 9 Jan 2018 15:59:11 -0000 @@ -82,4 +82,4 @@ void __mtx_init(struct mutex *, int); #define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj) #define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl -#endif +#endif /* _MACHINE_MUTEX_H_ */ Index: powerpc/include/mutex.h =================================================================== RCS file: /cvs/src/sys/arch/powerpc/include/mutex.h,v retrieving revision 1.6 diff -u -p -r1.6 mutex.h --- powerpc/include/mutex.h 20 Apr 2017 13:57:30 -0000 1.6 +++ powerpc/include/mutex.h 9 Jan 2018 16:00:21 -0000 @@ -24,8 +24,9 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _POWERPC_MUTEX_H_ -#define _POWERPC_MUTEX_H_ + +#ifndef _MACHINE_MUTEX_H_ +#define _MACHINE_MUTEX_H_ #include <sys/_lock.h> @@ -54,10 +55,10 @@ struct mutex { #ifdef WITNESS #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { NULL, __MUTEX_IPL(ipl), IPL_NONE, MTX_LO_INITIALIZER(name, flags) } + { NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) } #else #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { NULL, __MUTEX_IPL(ipl), IPL_NONE } + { NULL, __MUTEX_IPL((ipl)), IPL_NONE } #endif void __mtx_init(struct mutex *, int); @@ -79,6 +80,6 @@ void __mtx_init(struct mutex *, int); #endif #define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj) -#define MUTEX_OLDIPL(mtx) ((mtx)->mtx_oldipl) +#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl -#endif +#endif /* _MACHINE_MUTEX_H_ */ Index: sparc64/include/mutex.h =================================================================== RCS file: /cvs/src/sys/arch/sparc64/include/mutex.h,v retrieving revision 1.5 diff -u -p -r1.5 mutex.h --- sparc64/include/mutex.h 20 Apr 2017 13:57:30 -0000 1.5 +++ sparc64/include/mutex.h 9 Jan 2018 16:01:40 -0000 @@ -55,10 +55,10 @@ struct mutex { #ifdef WITNESS #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { NULL, __MUTEX_IPL((ipl)), 0, MTX_LO_INITIALIZER(name, flags) } + { NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) } #else #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { NULL, __MUTEX_IPL((ipl)), 0 } + { NULL, __MUTEX_IPL((ipl)), IPL_NONE } #endif void __mtx_init(struct mutex *, int); @@ -82,4 +82,4 @@ void __mtx_init(struct mutex *, int); #define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj) #define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl -#endif +#endif /* _MACHINE_MUTEX_H_ */