Page MenuHomeFreeBSD

exterror(9): dynamic kernel categories
Needs ReviewPublic

Authored by brooks on Tue, Jul 14, 8:08 PM.
Tags
None
Referenced Files
F163431820: D58237.id181997.diff
Thu, Jul 23, 3:57 AM
Unknown Object (File)
Tue, Jul 21, 1:13 PM
Unknown Object (File)
Tue, Jul 21, 1:09 PM
Unknown Object (File)
Tue, Jul 21, 8:26 AM
Unknown Object (File)
Tue, Jul 21, 2:26 AM
Unknown Object (File)
Sun, Jul 19, 9:32 PM
Unknown Object (File)
Sun, Jul 19, 9:19 PM
Unknown Object (File)
Sat, Jul 18, 8:55 PM
Subscribers

Details

Reviewers
kib
mckusick
Summary

Make it possible to define categories without compiling their
paths into libc (important for third-party modules). A
EXTERR_CATEGORY_DYNAMIC macro can be defined to a string describing the
compilation unit (generally the path relative to src/sys) which takes
the place of EXTERR_CATEGORY.

These strings are assembled in linker sets with category numbers
assigned at system startup or module load time. The strings can be
retrieved from the kern.exterr.categories.<category> sysctl.

Sponsored by: Innovate UK

Diff Detail

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

Event Timeline

This addresses an issue I realized during Kirk's talk at BSDCan. In the existing model, it's quite hard to support third-party modules and even in-tree modules for downstreams would require reserving a portion of the identifier space. This approach adds cost to the EXTERROR_VERBOSE reporting path, but significantly decouples the kernel and libc. I'm not sure I'd want to go as far moving entirely to dynamic, but it's probably not a problem in practice.

If I wanted to make this more efficient I'd add an AT_EXTERR_CATS and AT_EXTERR_CAT_MAX or the like and use shared pages to push out an array of pointers (or maybe with a third variable indexes) into processes addresses spaces. You might still want a fallback for categories larger than AT_EXTERR_CAT_MAX to use the sysctl interface if modules were loaded so I think this is the right direction regardless.

sys/kern/subr_exterr.c
35

This might want to be an RB tree if there are lots of modules, but this is simple