Page MenuHomeFreeBSD

KASSERT(9): some updates
ClosedPublic

Authored by mhorne on Mar 16 2023, 7:35 PM.
Tags
None
Referenced Files
F102653379: D39131.diff
Fri, Nov 15, 9:36 AM
Unknown Object (File)
Sun, Oct 20, 3:17 AM
Unknown Object (File)
Sun, Oct 20, 1:12 AM
Unknown Object (File)
Sat, Oct 19, 8:17 PM
Unknown Object (File)
Sep 23 2024, 6:48 PM
Unknown Object (File)
Sep 6 2024, 2:19 AM
Unknown Object (File)
Sep 4 2024, 10:33 PM
Unknown Object (File)
Sep 4 2024, 10:33 PM

Details

Summary
  • Correct the needed headers
  • Make the existing example ANSI C. Don't reference a real kernel function whose implementation has changed, it is simple enough to use foo and bar as identifiers
  • Add a little bit of introductory text
  • Document the widely used MPASS macro in this page
  • Drop the cross-reference to config(8)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 50434
Build 47325: arc lint + arc unit

Event Timeline

I have been wondering about MPASS() forever! :-)

share/man/man9/KASSERT.9
50
72

Handle rpokala's comments.

I have been wondering about MPASS() forever! :-)

The definition I gave is not authoritative, just my best guess :)

share/man/man9/KASSERT.9
51

I think this is a bit unclear: certain non-recoverable errors are handled with an explicit call to panic() since they apply to non-INVARIANTS kernels as well. Maybe it should be more obvious that KASSERT() is optional and only enabled in debugging kernels.

88

Traditionally we use options DIAGNOSTIC for really expensive checks (and in some old code it's used to enable some miscellaneous debug printf()s, but I think that's discouraged now). Maybe it'd be worth mentioning that?

share/man/man9/KASSERT.9
88

Maybe one way to express this is that assertion conditions should be checkable in constant time. INVARIANTS kernels are allowed to be slow, but they must still be "usable" in some sense.

I have been wondering about MPASS() forever! :-)

The definition I gave is not authoritative, just my best guess :)

I always thought that it was "multi-processor assert" but that doesn't make a ton of sense (maybe it was introduced during the transition to MPSAFE kernels?) and I have no proof. Your name is better.

Minor nits fixable on commit.

share/man/man9/KASSERT.9
34

March (already!)

125
This revision is now accepted and ready to land.Mar 16 2023, 8:48 PM

Handle comments from markj and pauamma.

This revision now requires review to proceed.Mar 16 2023, 8:59 PM
mhorne added inline comments.
share/man/man9/KASSERT.9
125

Nice catch!

This revision is now accepted and ready to land.Mar 16 2023, 9:03 PM
share/man/man9/KASSERT.9
80

Something should be said that the panic string is formed by sprintf-ing format and args.

99
106

This is in fact the worst example of assert. The normal approach for NULL deref checks is to left it to the MMU. Note that we do not have many a != NULL asserts in kernel. bde@ objected esp. loud against them.

mhorne marked an inline comment as done.

Handle kib's comments.

This revision now requires review to proceed.Mar 17 2023, 6:24 PM
This revision is now accepted and ready to land.Mar 17 2023, 7:59 PM
This revision was automatically updated to reflect the committed changes.