Page MenuHomeFreeBSD

Add log() style versions of device_printf() and if_printf()
ClosedPublic

Authored by adrian on Mar 18 2021, 6:46 AM.
Tags
None
Referenced Files
F96042093: D29320.diff
Mon, Sep 23, 11:23 AM
F95888996: D29320.id85950.diff
Sun, Sep 22, 11:15 PM
Unknown Object (File)
Sat, Sep 21, 12:39 PM
Unknown Object (File)
Fri, Sep 20, 11:50 AM
Unknown Object (File)
Fri, Sep 20, 4:14 AM
Unknown Object (File)
Thu, Sep 5, 1:46 PM
Unknown Object (File)
Wed, Sep 4, 10:25 AM
Unknown Object (File)
Wed, Sep 4, 12:40 AM

Details

Summary

This is intended to be used by devices and network devices
to log things to the kernel syslog rather than hand-rolling
log() stuff (like what happens in other places in net/if.c)
or being very spammy with device_printf()/printf() (like, well,
a lot of things.)

I've used this in my local tree to convert net80211 and ath_hal
logging over to log at INFO/DEBUG where appropriate and it
works quite well. On devices with serial consoles (ie, all the
weird things I use in my wifi test bed here) writing debug
information to the serial console causes quite bad behaviour.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 37910
Build 34799: arc lint + arc unit

Event Timeline

Seems good to me, but you'll want to make sure others sign off on it too.

sys/kern/subr_bus.c
2457

128 is kinda small, but on the other hand it's also kinda big for the stack :(, but I guess it's no different than device_printf.

This revision is now accepted and ready to land.Mar 18 2021, 4:06 PM
jhb added a subscriber: jhb.
jhb added inline comments.
sys/kern/subr_bus.c
2457

If you wanted to support longer lines you could add a drain routine that wrote to log(). Truncating is probably fine though.

That's a nice addition we should long have.
Please see some minor comments inside.

sys/kern/subr_bus.c
2462

Nit: should it be something like "unknown_device:" ?

sys/net/if.c
3955

Nit: maybe if_buf?