Page MenuHomeFreeBSD

exterror(9): dynamic kernel categories
AcceptedPublic

Authored by brooks on Tue, Jul 14, 8:08 PM.
Tags
None
Referenced Files
F164243683: D58237.id182526.diff
Thu, Jul 30, 1:12 AM
Unknown Object (File)
Wed, Jul 29, 7:12 AM
Unknown Object (File)
Tue, Jul 28, 11:36 AM
Unknown Object (File)
Tue, Jul 28, 6:30 AM
Unknown Object (File)
Mon, Jul 27, 10:36 PM
Unknown Object (File)
Mon, Jul 27, 5:59 PM
Unknown Object (File)
Mon, Jul 27, 5:28 AM
Unknown Object (File)
Sun, Jul 26, 10:30 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

sys/kern/subr_exterr.c
40

I think this lock can usefully be rwlock.

103

free under the mutex establishes the order between uma locks (and transitively VM locks) and the cat_mtx. Then it would be impossible to use that somewhere deep in VM.

This might be not a serious issues because a loadable module probably does not provide low-level VM functionality, but there it is trivial to avoid introducing the order.

brooks marked 2 inline comments as done.

Switch to rwlock, hoist free outside the locked region.

This comment was removed by brooks.
This revision is now accepted and ready to land.Fri, Jul 24, 7:51 PM