Date: Mon, 26 Jan 2026 10:55:27 -0500 From: "Drew Gallatin" <gallatin@freebsd.org> To: =?UTF-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@freebsd.org>, src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: a11d132f6c62 - main - devstat: Provide 32-bit compatibility Message-ID: <d5878bcd-b7b7-4acc-9897-7f7041d0643d@app.fastmail.com> In-Reply-To: <697757ba.b040.558a1a55@gitrepo.freebsd.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
My build dies with:
In file included from /usr/src/sys/kern/subr_devstat.c:47:
In file included from /usr/src/sys/compat/freebsd32/freebsd32.h:38:
/usr/src/sys/sys/user.h:692:16: error: field has incomplete type 'struct kevent'
692 | struct kevent knt_event;
| ^
/usr/src/sys/sys/user.h:692:9: note: forward declaration of 'struct kevent'
692 | struct kevent knt_event;
| ^
In file included from /usr/src/sys/kern/subr_devstat.c:47:
/usr/src/sys/compat/freebsd32/freebsd32.h:465:18: error: field has incomplete type 'struct kevent32'
465 | struct kevent32 knt_event;
| ^
/usr/src/sys/compat/freebsd32/freebsd32.h:465:9: note: forward declaration of 'struct kevent32'
465 | struct kevent32 knt_event;
| ^
Reverting this commit fixes it.
My kernel conf a pretty close to standard GENERIC-NODEBUG.
Drew
include GENERIC-NODEBUG
ident GENERIC-DREW
makeoptions WITH_EXTRA_TCP_STACKS=1
nooptions INVARIANTS
nooptions INVARIANT_SUPPORT
nooptions WITNESS
nooptions WITNESS_SKIPSPIN
nooptions BUF_TRACKING
nooptions DEADLKRES
nooptions FULL_BUF_TRACKING
nooptions COVERAGE
nooptions KCOV
nooptions VIMAGE # Subsystem virtualization, e.g. VNET
#options DEADLKRES # Enable the deadlock resolver
options MSGBUF_SIZE=524288
#options MP_WATCHDOG
nooptions IPSEC
options KERN_TLS # TLS transmit offload
options TCPHPTS
options RATELIMIT # TX rate limiting support
On Mon, Jan 26, 2026, at 7:02 AM, Dag-Erling Smørgrav wrote:
> The branch main has been updated by des:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=a11d132f6c62f32abe44b19f7527d97ddc239058
>
> commit a11d132f6c62f32abe44b19f7527d97ddc239058
> Author: Dag-Erling Smørgrav <des@FreeBSD.org>
> AuthorDate: 2026-01-26 12:01:39 +0000
> Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
> CommitDate: 2026-01-26 12:01:59 +0000
>
> devstat: Provide 32-bit compatibility
>
> If a 32-bit process running on a 64-bit kernel requests kern.devstat.all,
> translate each struct devstat to its 32-bit equivalent before copying it
> out.
>
> Also fix a bug where an early error would be ignored if there were no
> devices to report.
>
> MFC after: 1 week
> Reviewed by: kib
> Differential Revision: https://reviews.freebsd.org/D54591
> ---
> sys/compat/freebsd32/freebsd32.h | 27 +++++++++++++++++++
> sys/kern/subr_devstat.c | 56 +++++++++++++++++++++++++++++++++++-----
> 2 files changed, 76 insertions(+), 7 deletions(-)
>
> diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h
> index 7d21a5be5570..a8d54290980d 100644
> --- a/sys/compat/freebsd32/freebsd32.h
> +++ b/sys/compat/freebsd32/freebsd32.h
> @@ -29,7 +29,10 @@
> #ifndef _COMPAT_FREEBSD32_FREEBSD32_H_
> #define _COMPAT_FREEBSD32_FREEBSD32_H_
>
> +#include <sys/cdefs.h>
> #include <sys/abi_compat.h>
> +#include <sys/devicestat.h>
> +#include <sys/mount.h>
> #include <sys/procfs.h>
> #include <sys/socket.h>
> #include <sys/user.h>
> @@ -540,4 +543,28 @@ struct ptrace_sc_remote32 {
> uint32_t pscr_args;
> };
>
> +struct devstat32 {
> + u_int sequence0;
> + int allocated;
> + u_int start_count;
> + u_int end_count;
> + struct bintime32 busy_from;
> + struct { u_int32_t stqe_next; } dev_links;
> + u_int32_t device_number;
> + char device_name[DEVSTAT_NAME_LEN];
> + int unit_number;
> + freebsd32_uint64_t bytes[DEVSTAT_N_TRANS_FLAGS];
> + freebsd32_uint64_t operations[DEVSTAT_N_TRANS_FLAGS];
> + struct bintime32 duration[DEVSTAT_N_TRANS_FLAGS];
> + struct bintime32 busy_time;
> + struct bintime32 creation_time;
> + u_int32_t block_size;
> + freebsd32_uint64_t tag_types[3];
> + devstat_support_flags flags;
> + devstat_type_flags device_type;
> + devstat_priority priority;
> + u_int32_t id;
> + u_int sequence1;
> +};
> +
> #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */
> diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c
> index c4d0223d484f..c62df0e210e1 100644
> --- a/sys/kern/subr_devstat.c
> +++ b/sys/kern/subr_devstat.c
> @@ -43,6 +43,10 @@
> #include <vm/vm.h>
> #include <vm/pmap.h>
>
> +#ifdef COMPAT_FREEBSD32
> +#include <compat/freebsd32/freebsd32.h>
> +#endif
> +
> #include <machine/atomic.h>
>
> SDT_PROVIDER_DEFINE(io);
> @@ -398,25 +402,63 @@ sysctl_devstat(SYSCTL_HANDLER_ARGS)
> */
> mygen = devstat_generation;
>
> - error = SYSCTL_OUT(req, &mygen, sizeof(mygen));
> -
> - if (devstat_num_devs == 0)
> - return(0);
> +#ifdef COMPAT_FREEBSD32
> + if ((req->flags & SCTL_MASK32) != 0) {
> + int32_t mygen32 = (int32_t)mygen;
>
> + error = SYSCTL_OUT(req, &mygen32, sizeof(mygen32));
> + } else
> +#endif /* COMPAT_FREEBSD32 */
> + error = SYSCTL_OUT(req, &mygen, sizeof(mygen));
> if (error != 0)
> return (error);
>
> + if (devstat_num_devs == 0)
> + return(0);
> +
> mtx_lock(&devstat_mutex);
> nds = STAILQ_FIRST(&device_statq);
> if (mygen != devstat_generation)
> error = EBUSY;
> mtx_unlock(&devstat_mutex);
> -
> if (error != 0)
> return (error);
>
> while (nds != NULL) {
> - error = SYSCTL_OUT(req, nds, sizeof(struct devstat));
> +#ifdef COMPAT_FREEBSD32
> + if ((req->flags & SCTL_MASK32) != 0) {
> + struct devstat32 ds32;
> + unsigned int i;
> +
> + CP(*nds, ds32, sequence0);
> + CP(*nds, ds32, allocated);
> + CP(*nds, ds32, start_count);
> + CP(*nds, ds32, end_count);
> + BT_CP(*nds, ds32, busy_from);
> + PTROUT_CP(*nds, ds32, dev_links.stqe_next);
> + CP(*nds, ds32, device_number);
> + strcpy(ds32.device_name, nds->device_name);
> + CP(*nds, ds32, unit_number);
> + for (i = 0; i < DEVSTAT_N_TRANS_FLAGS; i++) {
> + FU64_CP(*nds, ds32, bytes[i]);
> + FU64_CP(*nds, ds32, operations[i]);
> + BT_CP(*nds, ds32, duration[i]);
> + }
> + BT_CP(*nds, ds32, busy_time);
> + BT_CP(*nds, ds32, creation_time);
> + CP(*nds, ds32, block_size);
> + for (i = 0; i < nitems(ds32.tag_types); i++) {
> + FU64_CP(*nds, ds32, tag_types[i]);
> + }
> + CP(*nds, ds32, flags);
> + CP(*nds, ds32, device_type);
> + CP(*nds, ds32, priority);
> + PTROUT_CP(*nds, ds32, id);
> + CP(*nds, ds32, sequence1);
> + error = SYSCTL_OUT(req, &ds32, sizeof(ds32));
> + } else
> +#endif /* COMPAT_FREEBSD32 */
> + error = SYSCTL_OUT(req, nds, sizeof(*nds));
> if (error != 0)
> return (error);
> mtx_lock(&devstat_mutex);
> @@ -428,7 +470,7 @@ sysctl_devstat(SYSCTL_HANDLER_ARGS)
> if (error != 0)
> return (error);
> }
> - return(error);
> + return (error);
> }
>
> /*
>
>
[-- Attachment #2 --]
<!DOCTYPE html><html><head><title></title></head><body><div>My build dies with:</div><div><br></div><div>In file included from /usr/src/sys/kern/subr_devstat.c:47:</div><div>In file included from /usr/src/sys/compat/freebsd32/freebsd32.h:38:</div><div>/usr/src/sys/sys/user.h:692:16: error: field has incomplete type 'struct kevent'</div><div> 692 | struct kevent knt_event;</div><div> | ^</div><div>/usr/src/sys/sys/user.h:692:9: note: forward declaration of 'struct kevent'</div><div> 692 | struct kevent knt_event;</div><div> | ^</div><div>In file included from /usr/src/sys/kern/subr_devstat.c:47:</div><div>/usr/src/sys/compat/freebsd32/freebsd32.h:465:18: error: field has incomplete type 'struct kevent32'</div><div> 465 | struct kevent32 knt_event;</div><div> | ^</div><div>/usr/src/sys/compat/freebsd32/freebsd32.h:465:9: note: forward declaration of 'struct kevent32'</div><div> 465 | struct kevent32 knt_event;</div><div> | ^</div><div><br></div><div><br></div><div>Reverting this commit fixes it.</div><div><br></div><div>My kernel conf a pretty close to standard GENERIC-NODEBUG.</div><div><br></div><div>Drew</div><div><br></div><div>include GENERIC-NODEBUG</div><div><br></div><div>ident GENERIC-DREW</div><div><br></div><div>makeoptions WITH_EXTRA_TCP_STACKS=1</div><div>nooptions INVARIANTS</div><div>nooptions INVARIANT_SUPPORT</div><div>nooptions WITNESS</div><div>nooptions WITNESS_SKIPSPIN</div><div>nooptions BUF_TRACKING</div><div>nooptions DEADLKRES</div><div>nooptions FULL_BUF_TRACKING</div><div>nooptions COVERAGE</div><div>nooptions KCOV</div><div>nooptions VIMAGE # Subsystem virtualization, e.g. VNET</div><div>#options DEADLKRES # Enable the deadlock resolver</div><div>options MSGBUF_SIZE=524288</div><div>#options MP_WATCHDOG</div><div>nooptions IPSEC</div><div>options KERN_TLS # TLS transmit offload</div><div>options TCPHPTS</div><div>options RATELIMIT # TX rate limiting support</div><div><br></div><div><br></div><div>On Mon, Jan 26, 2026, at 7:02 AM, Dag-Erling Smørgrav wrote:</div><blockquote type="cite" id="qt" style=""><div>The branch main has been updated by des:</div><div><br></div><div>URL: <a href="https://cgit.FreeBSD.org/src/commit/?id=a11d132f6c62f32abe44b19f7527d97ddc239058">https://cgit.FreeBSD.org/src/commit/?id=a11d132f6c62f32abe44b19f7527d97ddc239058</a></div><div><br></div><div>commit a11d132f6c62f32abe44b19f7527d97ddc239058</div><div>Author: Dag-Erling Smørgrav <<a href="mailto:des@FreeBSD.org">des@FreeBSD.org</a>></div><div>AuthorDate: 2026-01-26 12:01:39 +0000</div><div>Commit: Dag-Erling Smørgrav <<a href="mailto:des@FreeBSD.org">des@FreeBSD.org</a>></div><div>CommitDate: 2026-01-26 12:01:59 +0000</div><div><br></div><div> devstat: Provide 32-bit compatibility</div><div> </div><div> If a 32-bit process running on a 64-bit kernel requests <a href="http://kern.devstat.all">kern.devstat.all</a>,</div><div> translate each struct devstat to its 32-bit equivalent before copying it</div><div> out.</div><div> </div><div> Also fix a bug where an early error would be ignored if there were no</div><div> devices to report.</div><div> </div><div> MFC after: 1 week</div><div> Reviewed by: kib</div><div> Differential Revision: <a href="https://reviews.freebsd.org/D54591">https://reviews.freebsd.org/D54591</a></div><div>---</div><div>sys/compat/freebsd32/freebsd32.h | 27 +++++++++++++++++++</div><div>sys/kern/subr_devstat.c | 56 +++++++++++++++++++++++++++++++++++-----</div><div>2 files changed, 76 insertions(+), 7 deletions(-)</div><div><br></div><div>diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h</div><div>index 7d21a5be5570..a8d54290980d 100644</div><div>--- a/sys/compat/freebsd32/freebsd32.h</div><div>+++ b/sys/compat/freebsd32/freebsd32.h</div><div>@@ -29,7 +29,10 @@</div><div>#ifndef _COMPAT_FREEBSD32_FREEBSD32_H_</div><div>#define _COMPAT_FREEBSD32_FREEBSD32_H_</div><div> </div><div>+#include <sys/cdefs.h></div><div>#include <sys/abi_compat.h></div><div>+#include <sys/devicestat.h></div><div>+#include <sys/mount.h></div><div>#include <sys/procfs.h></div><div>#include <sys/socket.h></div><div>#include <sys/user.h></div><div>@@ -540,4 +543,28 @@ struct ptrace_sc_remote32 {</div><div>uint32_t pscr_args;</div><div>};</div><div> </div><div>+struct devstat32 {</div><div>+ u_int sequence0;</div><div>+ int allocated;</div><div>+ u_int start_count;</div><div>+ u_int end_count;</div><div>+ struct bintime32 busy_from;</div><div>+ struct { u_int32_t stqe_next; } dev_links;</div><div>+ u_int32_t device_number;</div><div>+ char device_name[DEVSTAT_NAME_LEN];</div><div>+ int unit_number;</div><div>+ freebsd32_uint64_t bytes[DEVSTAT_N_TRANS_FLAGS];</div><div>+ freebsd32_uint64_t operations[DEVSTAT_N_TRANS_FLAGS];</div><div>+ struct bintime32 duration[DEVSTAT_N_TRANS_FLAGS];</div><div>+ struct bintime32 busy_time;</div><div>+ struct bintime32 creation_time;</div><div>+ u_int32_t block_size;</div><div>+ freebsd32_uint64_t tag_types[3];</div><div>+ devstat_support_flags flags;</div><div>+ devstat_type_flags device_type;</div><div>+ devstat_priority priority;</div><div>+ u_int32_t id;</div><div>+ u_int sequence1;</div><div>+};</div><div>+</div><div>#endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */</div><div>diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c</div><div>index c4d0223d484f..c62df0e210e1 100644</div><div>--- a/sys/kern/subr_devstat.c</div><div>+++ b/sys/kern/subr_devstat.c</div><div>@@ -43,6 +43,10 @@</div><div>#include <vm/vm.h></div><div>#include <vm/pmap.h></div><div> </div><div>+#ifdef COMPAT_FREEBSD32</div><div>+#include <compat/freebsd32/freebsd32.h></div><div>+#endif</div><div>+</div><div>#include <machine/atomic.h></div><div> </div><div>SDT_PROVIDER_DEFINE(io);</div><div>@@ -398,25 +402,63 @@ sysctl_devstat(SYSCTL_HANDLER_ARGS)</div><div>*/</div><div>mygen = devstat_generation;</div><div> </div><div>- error = SYSCTL_OUT(req, &mygen, sizeof(mygen));</div><div>-</div><div>- if (devstat_num_devs == 0)</div><div>- return(0);</div><div>+#ifdef COMPAT_FREEBSD32</div><div>+ if ((req->flags & SCTL_MASK32) != 0) {</div><div>+ int32_t mygen32 = (int32_t)mygen;</div><div> </div><div>+ error = SYSCTL_OUT(req, &mygen32, sizeof(mygen32));</div><div>+ } else</div><div>+#endif /* COMPAT_FREEBSD32 */</div><div>+ error = SYSCTL_OUT(req, &mygen, sizeof(mygen));</div><div>if (error != 0)</div><div>return (error);</div><div> </div><div>+ if (devstat_num_devs == 0)</div><div>+ return(0);</div><div>+</div><div>mtx_lock(&devstat_mutex);</div><div>nds = STAILQ_FIRST(&device_statq); </div><div>if (mygen != devstat_generation)</div><div>error = EBUSY;</div><div>mtx_unlock(&devstat_mutex);</div><div>-</div><div>if (error != 0)</div><div>return (error);</div><div> </div><div>while (nds != NULL) {</div><div>- error = SYSCTL_OUT(req, nds, sizeof(struct devstat));</div><div>+#ifdef COMPAT_FREEBSD32</div><div>+ if ((req->flags & SCTL_MASK32) != 0) {</div><div>+ struct devstat32 ds32;</div><div>+ unsigned int i;</div><div>+</div><div>+ CP(*nds, ds32, sequence0);</div><div>+ CP(*nds, ds32, allocated);</div><div>+ CP(*nds, ds32, start_count);</div><div>+ CP(*nds, ds32, end_count);</div><div>+ BT_CP(*nds, ds32, busy_from);</div><div>+ PTROUT_CP(*nds, ds32, dev_links.stqe_next);</div><div>+ CP(*nds, ds32, device_number);</div><div>+ strcpy(<a href="http://ds32.device">ds32.device</a>_name, nds->device_name);</div><div>+ CP(*nds, ds32, unit_number);</div><div>+ for (i = 0; i < DEVSTAT_N_TRANS_FLAGS; i++) {</div><div>+ FU64_CP(*nds, ds32, bytes[i]);</div><div>+ FU64_CP(*nds, ds32, operations[i]);</div><div>+ BT_CP(*nds, ds32, duration[i]);</div><div>+ }</div><div>+ BT_CP(*nds, ds32, busy_time);</div><div>+ BT_CP(*nds, ds32, creation_time);</div><div>+ CP(*nds, ds32, block_size);</div><div>+ for (i = 0; i < nitems(<a href="http://ds32.tag">ds32.tag</a>_types); i++) {</div><div>+ FU64_CP(*nds, ds32, tag_types[i]);</div><div>+ }</div><div>+ CP(*nds, ds32, flags);</div><div>+ CP(*nds, ds32, device_type);</div><div>+ CP(*nds, ds32, priority);</div><div>+ PTROUT_CP(*nds, ds32, id);</div><div>+ CP(*nds, ds32, sequence1);</div><div>+ error = SYSCTL_OUT(req, &ds32, sizeof(ds32));</div><div>+ } else</div><div>+#endif /* COMPAT_FREEBSD32 */</div><div>+ error = SYSCTL_OUT(req, nds, sizeof(*nds));</div><div>if (error != 0)</div><div>return (error);</div><div>mtx_lock(&devstat_mutex);</div><div>@@ -428,7 +470,7 @@ sysctl_devstat(SYSCTL_HANDLER_ARGS)</div><div>if (error != 0)</div><div>return (error);</div><div>}</div><div>- return(error);</div><div>+ return (error);</div><div>}</div><div> </div><div>/*</div><div><br></div><div><br></div></blockquote><div><br></div></body></html>
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d5878bcd-b7b7-4acc-9897-7f7041d0643d>
