Process timing issue
rysto32 at gmail.com
Wed Feb 23 01:08:22 UTC 2011
To debug weird scheduling issues I find it helpful to start by looking
at a schedgraph. schedgraph is a tool that can display a graphical
representation of what the scheduler was doing over a small slice of
time. The one downside is that you have to recompile your kernel to
get the hooks that collect the necessary data, but it sounds like your
problem is pretty easy to reproduce and so that shouldn't be a big
To enable the hooks, put the following in your kernel conf:
Then rebuild and install the new kernel. Next, run your test. The
instant that your test has detected the long delay, set the sysctl
debug.ktr.mask to 0. The scheduler hooks record data into a ring
buffer, so the interesting data can be flushed out within seconds.
Clearing that sysctl will stop any further events from being logged,
which means that the interesting data will stay there until you go and
You can get the raw data by redirecting the output of "ktrdump -ct"
into a file. Then from any machine with a graphical interface(FreeBSD
with X installed, Windows, Mac, whatever) and python installed, run:
$ python schedgraph.py /path/to/ktrdump/output
You can get schedgraph.py from /usr/src/tools/sched.
If you want to collect the data again, set the sysctl debug.ktr.mask
back to 0x20000000 to restart gathering scheduler data.
More information about the freebsd-current