Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Aug 2020 20:25:41 +0200
From:      Emmanuel Vadot <manu@bidouilliste.com>
To:        Alan Cox <alc@rice.edu>
Cc:        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:  <20200804202541.0b6b3eb6ce26522ee12a796c@bidouilliste.com>
In-Reply-To: <1c90911b-d5f6-f8b1-8f4d-97a88fa028bd@rice.edu>
References:  <202008041525.074FPNLh043749@repo.freebsd.org> <1c90911b-d5f6-f8b1-8f4d-97a88fa028bd@rice.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 4 Aug 2020 13:11:02 -0500
Alan Cox <alc@rice.edu> wrote:

>=20
> 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
> >   =20
> >    This calls clear_bit and adds a memory barrier.
> >   =20
> >    Sponsored by: The FreeBSD Foundation
> >   =20
> >    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
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
> > --- head/sys/compat/linuxkpi/common/include/linux/bitops.h	Tue Aug  4 1=
5:00:02 2020	(r363841)
> > +++ head/sys/compat/linuxkpi/common/include/linux/bitops.h	Tue Aug  4 1=
5:25:22 2020	(r363842)
> > @@ -275,6 +275,13 @@ find_next_zero_bit(const unsigned long *addr, unsi=
gned
> >   #define	test_bit(i, a)							\
> >       !!(READ_ONCE(((volatile const unsigned long *)(a))[BIT_WORD(i)]) =
& BIT_MASK(i))
> >  =20
> > +static inline void
> > +clear_bit_unlock(long bit, volatile unsigned long *var)
> > +{
> > +	clear_bit(bit, var);
> > +	wmb();
>=20
>=20
> For an unlock operation, the memory barrier should come before the=20
> clear_bit() call, not after.=A0 See, for example, the alpha implementatio=
n=20
> in Linux.=A0 Also, the correct "spelling" for this memory barrier in=20
> FreeBSD would be atomic_thread_fence_rel(). See, for example, the=20
> 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.

>=20
> > +}
> > +
> >   static inline int
> >   test_and_clear_bit(long bit, volatile unsigned long *var)
> >   {


--=20
Emmanuel Vadot <manu@bidouilliste.com> <manu@freebsd.org>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200804202541.0b6b3eb6ce26522ee12a796c>