Best way to print something from the kernel at 1s intervals?

Peter Eriksson pen at lysator.liu.se
Thu Nov 28 20:52:37 UTC 2019


I’ve been looking into the “kernel looks to be hung at reboot” problem at bit. Adding a lot of printf() calls to the relevant parts it looks like it actually isn’t hung but busy unmounting filesystems (which we have thousands of), flushing disk caches, calling registered callbacks and stuff and sometimes it takes a bit longer than usual - probably due to ZFS having stuff queued up that needs to be written to disk before it finishes…

Anyway, I’d like to propose that we add some kind of counter/printf() calls in that code area so we can see that things are indeed progressing. However, I’d probably prefer not to print _every_ filesystem (or registered callbacks - a lot of those...) - that generates a lot of output (tried that :-) but something like:

Unmounting filesystems:
1234 done
(With the "1234 done” updated something like once per second).

What’s the right/best way to do that from the kernel? In user space I’d just call time(&t) at some convenient points and only print something if “t” has changed. :-)

- Peter



More information about the freebsd-current mailing list