svn commit: r363842 - head/sys/compat/linuxkpi/common/include/linux
Emmanuel Vadot
manu at bidouilliste.com
Tue Aug 4 18:25:51 UTC 2020
On Tue, 4 Aug 2020 13:11:02 -0500
Alan Cox <alc at rice.edu> wrote:
>
> 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.
Ah yes, thanks. I probably got lost looking for the linux implem but
that does make sense, I'll fix that probably tomorow.
Thanks.
>
> > +}
> > +
> > static inline int
> > test_and_clear_bit(long bit, volatile unsigned long *var)
> > {
--
Emmanuel Vadot <manu at bidouilliste.com> <manu at freebsd.org>
More information about the svn-src-all
mailing list