Page MenuHomeFreeBSD

KASSERT(9): some updates
ClosedPublic

Authored by mhorne on Mar 16 2023, 7:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jun 22, 8:56 PM
Unknown Object (File)
Fri, Jun 21, 2:49 AM
Unknown Object (File)
Tue, Jun 18, 11:30 AM
Unknown Object (File)
Thu, May 30, 5:32 PM
Unknown Object (File)
Thu, May 30, 5:32 PM
Unknown Object (File)
Thu, May 30, 5:32 PM
Unknown Object (File)
May 21 2024, 10:26 AM
Unknown Object (File)
May 19 2024, 7:56 AM

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 Not Applicable
Unit
Tests Not Applicable

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!)

124
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
124

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
101–104

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.