Add userland boot profiling to TSLOG
authorColin Percival <cperciva@FreeBSD.org>
Sat, 16 Oct 2021 18:47:34 +0000 (11:47 -0700)
committerColin Percival <cperciva@FreeBSD.org>
Sat, 16 Oct 2021 18:47:34 +0000 (11:47 -0700)
commit46dd801acb2318c8464b185893bb111f09b71138
tree1e7b6bf14951cf4cd199706dc27430ac41895486
parent498cca14836da0408841cca8101e481e32151886
Add userland boot profiling to TSLOG

On kernels compiled with 'options TSLOG', record for each process ID:
* The timestamp of the fork() which creates it and the parent
process ID,
* The first path passed to execve(), if any,
* The first path resolved by namei, if any, and
* The timestamp of the exit() which terminates the process.

Expose this information via a new sysctl, debug.tslog_user.

On kernels lacking 'options TSLOG' (the default), no information is
recorded and the sysctl does not exist.

Note that recording namei is needed in order to obtain the names of
rc.d scripts being launched, as the rc system sources them in a
subshell rather than execing the scripts.

With this commit it is now possible to generate flamecharts of the
entire boot process from the start of the loader to the end of
/etc/rc.  The code needed to perform this processing is currently
found in github: https://github.com/cperciva/freebsd-boot-profiling

Reviewed by: mhorne
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D32493
sys/kern/kern_exec.c
sys/kern/kern_exit.c
sys/kern/kern_fork.c
sys/kern/kern_tslog.c
sys/kern/vfs_lookup.c
sys/sys/tslog.h