> Date: Tue, 2 Jan 2018 16:02:16 +0100 > From: Martin Pieuchot <m...@openbsd.org> > > We're no longer using the 'mtx_lock' field, so remove it. > > While here remove the 'volatile' keyword from amd64's 'struct mutex'.
You mean the mtx_owner member. > ok? I think that is wrong. Unless we always access that member using explicit atomic operations, we have to prevent the compiler from thinking that the variable can't change behind its back. So mtx_owner needs to be volatile everywhere. > Index: i386/i386/genassym.cf > =================================================================== > RCS file: /cvs/src/sys/arch/i386/i386/genassym.cf,v > retrieving revision 1.39 > diff -u -p -r1.39 genassym.cf > --- i386/i386/genassym.cf 15 Mar 2016 03:17:51 -0000 1.39 > +++ i386/i386/genassym.cf 2 Jan 2018 14:56:57 -0000 > @@ -136,7 +136,6 @@ member ih_next > endif > > struct mutex > -member mtx_lock > member mtx_wantipl > member mtx_oldipl > member mtx_owner > Index: i386/include/mutex.h > =================================================================== > RCS file: /cvs/src/sys/arch/i386/include/mutex.h,v > retrieving revision 1.9 > diff -u -p -r1.9 mutex.h > --- i386/include/mutex.h 20 Apr 2017 13:57:29 -0000 1.9 > +++ i386/include/mutex.h 2 Jan 2018 14:59:07 -0000 > @@ -29,12 +29,7 @@ > > #include <sys/_lock.h> > > -/* > - * XXX - we don't really need the mtx_lock field, we can use mtx_oldipl > - * as the lock to save some space. > - */ > struct mutex { > - volatile int mtx_lock; > int mtx_wantipl; > int mtx_oldipl; > void *mtx_owner; > @@ -59,10 +54,10 @@ struct mutex { > > #ifdef WITNESS > #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ > - { 0, __MUTEX_IPL(ipl), 0, NULL, MTX_LO_INITIALIZER(name, flags) } > + { __MUTEX_IPL((ipl)), 0, NULL, MTX_LO_INITIALIZER(name, flags) } > #else > #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ > - { 0, __MUTEX_IPL(ipl), 0, NULL } > + { __MUTEX_IPL((ipl)), 0, NULL } > #endif > > void __mtx_init(struct mutex *, int); > 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 2 Jan 2018 14:59:16 -0000 > @@ -32,7 +32,7 @@ > struct mutex { > int mtx_wantipl; > int mtx_oldipl; > - volatile void *mtx_owner; > + void *mtx_owner; > #ifdef WITNESS > struct lock_object mtx_lock_obj; > #endif > >