Date: Tue, 4 Aug 2020 13:11:02 -0500 From: Alan Cox <alc@rice.edu> To: Emmanuel Vadot <manu@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r363842 - head/sys/compat/linuxkpi/common/include/linux Message-ID: <1c90911b-d5f6-f8b1-8f4d-97a88fa028bd@rice.edu> In-Reply-To: <202008041525.074FPNLh043749@repo.freebsd.org> References: <202008041525.074FPNLh043749@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 8/4/20 10:25 AM, Emmanuel Vadot wrote: > Author: manu > Date: Tue Aug 4 15:25:22 2020 > New Revision: 363842 > URL: https://svnweb.freebsd.org/changeset/base/363842 > > Log: > linuxkpi: Add clear_bit_unlock > > This calls clear_bit and adds a memory barrier. > > Sponsored by: The FreeBSD Foundation > > Reviewed by: hselasky > MFC after: 1 week > Differential Revision: https://reviews.freebsd.org/D25943 > > Modified: > head/sys/compat/linuxkpi/common/include/linux/bitops.h > > Modified: head/sys/compat/linuxkpi/common/include/linux/bitops.h > ============================================================================== > --- head/sys/compat/linuxkpi/common/include/linux/bitops.h Tue Aug 4 15:00:02 2020 (r363841) > +++ head/sys/compat/linuxkpi/common/include/linux/bitops.h Tue Aug 4 15:25:22 2020 (r363842) > @@ -275,6 +275,13 @@ find_next_zero_bit(const unsigned long *addr, unsigned > #define test_bit(i, a) \ > !!(READ_ONCE(((volatile const unsigned long *)(a))[BIT_WORD(i)]) & BIT_MASK(i)) > > +static inline void > +clear_bit_unlock(long bit, volatile unsigned long *var) > +{ > + clear_bit(bit, var); > + wmb(); For an unlock operation, the memory barrier should come before the clear_bit() call, not after. See, for example, the alpha implementation in Linux. Also, the correct "spelling" for this memory barrier in FreeBSD would be atomic_thread_fence_rel(). See, for example, the comment at the top of sys/amd64/include/atomic.h. > +} > + > static inline int > test_and_clear_bit(long bit, volatile unsigned long *var) > {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1c90911b-d5f6-f8b1-8f4d-97a88fa028bd>