Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Jan 2023 18:51:45 -0700
From:      Warner Losh <imp@bsdimp.com>
To:        Mark Johnston <markj@freebsd.org>
Cc:        Konstantin Belousov <kostikbel@gmail.com>, Mateusz Guzik <mjguzik@gmail.com>,  src-committers <src-committers@freebsd.org>,  "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>, dev-commits-src-main@freebsd.org
Subject:   Re: git: 68912701700c - main - ffs_suspend.c: clean up includes
Message-ID:  <CANCZdfpOZwNAu34phCspy8otpsa0naQ6bwN=bm=_pbO4dESL9w@mail.gmail.com>
In-Reply-To: <Y7TNygrOr8W86XJz@framework>
References:  <202212292056.2BTKuOIu047460@gitrepo.freebsd.org> <CAGudoHEqJVvxp8-PbbrHM9=Qz=jSV8PQR8q848HJOmULiVSZzg@mail.gmail.com> <Y7QXN18gBTKDMj8j@kib.kiev.ua> <Y7TNygrOr8W86XJz@framework>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000e6ba9005f1666d15
Content-Type: text/plain; charset="UTF-8"

On Tue, Jan 3, 2023, 5:52 PM Mark Johnston <markj@freebsd.org> wrote:

> On Tue, Jan 03, 2023 at 01:53:27PM +0200, Konstantin Belousov wrote:
> > On Mon, Jan 02, 2023 at 06:29:57PM +0100, Mateusz Guzik wrote:
> > > On 12/29/22, Konstantin Belousov <kib@freebsd.org> wrote:
> > > > The branch main has been updated by kib:
> > > >
> > > > URL:
> > > >
> https://cgit.FreeBSD.org/src/commit/?id=68912701700ca3230f3e2d4b7858a038f884a327
> > > >
> > > > commit 68912701700ca3230f3e2d4b7858a038f884a327
> > > > Author:     Konstantin Belousov <kib@FreeBSD.org>
> > > > AuthorDate: 2022-12-28 18:17:53 +0000
> > > > Commit:     Konstantin Belousov <kib@FreeBSD.org>
> > > > CommitDate: 2022-12-29 20:55:39 +0000
> > > >
> > > >     ffs_suspend.c: clean up includes
> > > >
> > > >     Order includes alphabetically.
> > > >     Remove unneeded sys/param.h, it is already included by
> sys/systm.h.
> > > >
> > > >     Reviewed by:    mckusick
> > > >     Sponsored by:   The FreeBSD Foundation
> > > >     MFC after:      1 week
> > > >     Differential revision:  https://reviews.freebsd.org/D37896
> > > > ---
> > > >  sys/ufs/ffs/ffs_suspend.c | 7 +++----
> > > >  1 file changed, 3 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/sys/ufs/ffs/ffs_suspend.c b/sys/ufs/ffs/ffs_suspend.c
> > > > index d13097109758..e7c976b6e921 100644
> > > > --- a/sys/ufs/ffs/ffs_suspend.c
> > > > +++ b/sys/ufs/ffs/ffs_suspend.c
> > > > @@ -33,15 +33,14 @@
> > > >  #include <sys/cdefs.h>
> > > >  __FBSDID("$FreeBSD$");
> > > >
> > > > -#include <sys/param.h>
> > > >  #include <sys/systm.h>
> > > >  #include <sys/buf.h>
> > > > -#include <sys/ioccom.h>
> > > > -#include <sys/mount.h>
> > > > -#include <sys/vnode.h>
> > > >  #include <sys/conf.h>
> > > > +#include <sys/ioccom.h>
> > > >  #include <sys/jail.h>
> > > > +#include <sys/mount.h>
> > > >  #include <sys/sx.h>
> > > > +#include <sys/vnode.h>
> > > >
> > > >  #include <security/mac/mac_framework.h>
> > > >
> > > >
> > >
> > > tinderbox fails the KCSAN et al kernels:
> > >
> > > In file included from /usr/src/sys/ufs/ffs/ffs_suspend.c:36:
> > > In file included from /usr/src/sys/sys/systm.h:44:
> > > In file included from ./machine/atomic.h:73:
> > > /usr/src/sys/sys/atomic_san.h:117:24: error: unknown type name
> 'uint8_t'
> > > ATOMIC_SAN_FUNCS(char, uint8_t);
> > >                        ^
> > > it bisects to this commit
> > >
> > So the problem is that sys/systm.h includes machine/atomic.h which always
> > had the pre-requisite sys/types.h, and this is documented in atomic(9).
> > But sys/atomic_san.h uses C89 types in prototypes, not just macros, and
> > this breaks for real.
> >
> > I can
> > 1. Just add sys/types.h to ufs_suspend.c (I prefer not)
> > 2. Add sys/types.h to sys/atomic_san.h.
> > 3. Add sys/types.h to sys/systm.h.
> >
> > IMO #2 is not the best solution, since it pollutes systm.h only
> sometimes,
> > when the right kernel options are used.
>
> All machine/atomic.h include atomic_common.h, which includes
> sys/types.h.  Admittedly this inlcude was added quite recently, but it
> means that systm.h is always polluted, so it seems reasonable to me.
>
> > I would prefer #3, it seems, but
> > want to ensure that there is a consensus about the addition to
> sys/systm.h.
>
> As Mike notes, systm.h already includes param.h, but it happens too late.
>
> Most of systm.h is _KERNEL-only, so I can't see why the includes at the
> beginning are unguarded.  Does userspace (or the boot loader) rely on
> systm.h for anything?  Perhaps we should guard the whole file with
> _KERNEL and put includes in the right order.  That would also solve the
> problem.
>

I prefer mark's review that makes the atomic_san.h file self contained.

Warner

>

--000000000000e6ba9005f1666d15
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div><br><br><div class=3D"gmail_quote"><div dir=3D"ltr" =
class=3D"gmail_attr">On Tue, Jan 3, 2023, 5:52 PM Mark Johnston &lt;<a href=
=3D"mailto:markj@freebsd.org">markj@freebsd.org</a>&gt; wrote:<br></div><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #=
ccc solid;padding-left:1ex">On Tue, Jan 03, 2023 at 01:53:27PM +0200, Konst=
antin Belousov wrote:<br>
&gt; On Mon, Jan 02, 2023 at 06:29:57PM +0100, Mateusz Guzik wrote:<br>
&gt; &gt; On 12/29/22, Konstantin Belousov &lt;<a href=3D"mailto:kib@freebs=
d.org" target=3D"_blank" rel=3D"noreferrer">kib@freebsd.org</a>&gt; wrote:<=
br>
&gt; &gt; &gt; The branch main has been updated by kib:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; URL:<br>
&gt; &gt; &gt; <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3D6891270=
1700ca3230f3e2d4b7858a038f884a327" rel=3D"noreferrer noreferrer" target=3D"=
_blank">https://cgit.FreeBSD.org/src/commit/?id=3D68912701700ca3230f3e2d4b7=
858a038f884a327</a><br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; commit 68912701700ca3230f3e2d4b7858a038f884a327<br>
&gt; &gt; &gt; Author:=C2=A0 =C2=A0 =C2=A0Konstantin Belousov &lt;kib@FreeB=
SD.org&gt;<br>
&gt; &gt; &gt; AuthorDate: 2022-12-28 18:17:53 +0000<br>
&gt; &gt; &gt; Commit:=C2=A0 =C2=A0 =C2=A0Konstantin Belousov &lt;kib@FreeB=
SD.org&gt;<br>
&gt; &gt; &gt; CommitDate: 2022-12-29 20:55:39 +0000<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0ffs_suspend.c: clean up includes<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0Order includes alphabetically.<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0Remove unneeded sys/param.h, it is alread=
y included by sys/systm.h.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0Reviewed by:=C2=A0 =C2=A0 mckusick<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0Sponsored by:=C2=A0 =C2=A0The FreeBSD Fou=
ndation<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0MFC after:=C2=A0 =C2=A0 =C2=A0 1 week<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0Differential revision:=C2=A0 <a href=3D"h=
ttps://reviews.freebsd.org/D37896" rel=3D"noreferrer noreferrer" target=3D"=
_blank">https://reviews.freebsd.org/D37896</a><br>;
&gt; &gt; &gt; ---<br>
&gt; &gt; &gt;=C2=A0 sys/ufs/ffs/ffs_suspend.c | 7 +++----<br>
&gt; &gt; &gt;=C2=A0 1 file changed, 3 insertions(+), 4 deletions(-)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; diff --git a/sys/ufs/ffs/ffs_suspend.c b/sys/ufs/ffs/ffs_sus=
pend.c<br>
&gt; &gt; &gt; index d13097109758..e7c976b6e921 100644<br>
&gt; &gt; &gt; --- a/sys/ufs/ffs/ffs_suspend.c<br>
&gt; &gt; &gt; +++ b/sys/ufs/ffs/ffs_suspend.c<br>
&gt; &gt; &gt; @@ -33,15 +33,14 @@<br>
&gt; &gt; &gt;=C2=A0 #include &lt;sys/cdefs.h&gt;<br>
&gt; &gt; &gt;=C2=A0 __FBSDID(&quot;$FreeBSD$&quot;);<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; -#include &lt;sys/param.h&gt;<br>
&gt; &gt; &gt;=C2=A0 #include &lt;sys/systm.h&gt;<br>
&gt; &gt; &gt;=C2=A0 #include &lt;sys/buf.h&gt;<br>
&gt; &gt; &gt; -#include &lt;sys/ioccom.h&gt;<br>
&gt; &gt; &gt; -#include &lt;sys/mount.h&gt;<br>
&gt; &gt; &gt; -#include &lt;sys/vnode.h&gt;<br>
&gt; &gt; &gt;=C2=A0 #include &lt;sys/conf.h&gt;<br>
&gt; &gt; &gt; +#include &lt;sys/ioccom.h&gt;<br>
&gt; &gt; &gt;=C2=A0 #include &lt;sys/jail.h&gt;<br>
&gt; &gt; &gt; +#include &lt;sys/mount.h&gt;<br>
&gt; &gt; &gt;=C2=A0 #include &lt;sys/sx.h&gt;<br>
&gt; &gt; &gt; +#include &lt;sys/vnode.h&gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;=C2=A0 #include &lt;security/mac/mac_framework.h&gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; <br>
&gt; &gt; tinderbox fails the KCSAN et al kernels:<br>
&gt; &gt; <br>
&gt; &gt; In file included from /usr/src/sys/ufs/ffs/ffs_suspend.c:36:<br>
&gt; &gt; In file included from /usr/src/sys/sys/systm.h:44:<br>
&gt; &gt; In file included from ./machine/atomic.h:73:<br>
&gt; &gt; /usr/src/sys/sys/atomic_san.h:117:24: error: unknown type name &#=
39;uint8_t&#39;<br>
&gt; &gt; ATOMIC_SAN_FUNCS(char, uint8_t);<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 ^<br>
&gt; &gt; it bisects to this commit<br>
&gt; &gt; <br>
&gt; So the problem is that sys/systm.h includes machine/atomic.h which alw=
ays<br>
&gt; had the pre-requisite sys/types.h, and this is documented in atomic(9)=
.<br>
&gt; But sys/atomic_san.h uses C89 types in prototypes, not just macros, an=
d<br>
&gt; this breaks for real.<br>
&gt; <br>
&gt; I can<br>
&gt; 1. Just add sys/types.h to ufs_suspend.c (I prefer not)<br>
&gt; 2. Add sys/types.h to sys/atomic_san.h.<br>
&gt; 3. Add sys/types.h to sys/systm.h.<br>
&gt; <br>
&gt; IMO #2 is not the best solution, since it pollutes systm.h only someti=
mes,<br>
&gt; when the right kernel options are used.<br>
<br>
All machine/atomic.h include atomic_common.h, which includes<br>
sys/types.h.=C2=A0 Admittedly this inlcude was added quite recently, but it=
<br>
means that systm.h is always polluted, so it seems reasonable to me.<br>
<br>
&gt; I would prefer #3, it seems, but<br>
&gt; want to ensure that there is a consensus about the addition to sys/sys=
tm.h.<br>
<br>
As Mike notes, systm.h already includes param.h, but it happens too late.<b=
r>
<br>
Most of systm.h is _KERNEL-only, so I can&#39;t see why the includes at the=
<br>
beginning are unguarded.=C2=A0 Does userspace (or the boot loader) rely on<=
br>
systm.h for anything?=C2=A0 Perhaps we should guard the whole file with<br>
_KERNEL and put includes in the right order.=C2=A0 That would also solve th=
e<br>
problem.<br></blockquote></div></div><div dir=3D"auto"><br></div><div dir=
=3D"auto">I prefer mark&#39;s review that makes the atomic_san.h file self =
contained.=C2=A0</div><div dir=3D"auto"><br></div><div dir=3D"auto">Warner=
=C2=A0</div><div dir=3D"auto"><div class=3D"gmail_quote"><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">
</blockquote></div></div></div>

--000000000000e6ba9005f1666d15--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfpOZwNAu34phCspy8otpsa0naQ6bwN=bm=_pbO4dESL9w>