HomeFreeBSD

sysctl(9): Ease exporting struct sizes; Discourage doing that

Description

sysctl(9): Ease exporting struct sizes; Discourage doing that

Introduce two helpers, the more general SYSCTL_SIZEOF() and
a struct-specific one SYSCTL_SIZEOF_STRUCT() which prepends 'struct' in
the description and in the use of sizeof() but uses the raw structure
name as the knob's name. The size of the object/structure is exported
under 'debug.sizeof'.

Existing knobs under 'debug.sizeof' were all converted to use the
helpers.

Add a note before the helpers discouraging the introduction of new
leaves for ad-hoc reasons. List alternative means for developers to
obtain the size of arbitrary kernel structures easily (thanks to markj@
for providing these).

No functional change (intended).

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50121

(cherry picked from commit 713abc9880aabe0ff924ff644bceb6ff404ed3cd)

Details

Provenance
olceAuthored on May 1 2025, 4:02 PM
Reviewer
kib
Differential Revision
D50121: sysctl(9): Ease exporting struct sizes; Discourage doing that
Parents
rG5af18707c155: stress2: exlock2.sh: Preserve behavior after ps(1)'s '-U' change
Branches
Unknown
Tags
Unknown