ps "time" field jumps backward

Dan Nelson dnelson at allantgroup.com
Fri Feb 5 21:28:45 UTC 2010


In the last episode (Feb 05), Linda Messerschmidt said:
> For most of 7.2, on up to a 7.3-PRERELEASE built yesterday, I've noticed
> that the "time" field reported by ps and top jumps around for some
> processes.  I've particularly noticed it with MySQL.
> 
> Here are some repeated ps results (ps axo pid,time,wchan,comm) for the
> same process over a few minutes:
> 
>  1647   0:08.06 ucond  mysqld
>  1647   0:08.06 ucond  mysqld
>  1647   0:08.06 ucond  mysqld
>  1647   0:08.06 ucond  mysqld
>  1647   0:08.07 ucond  mysqld
>  1647   0:10.24 wdrain mysqld
>  1647   0:08.08 ucond  mysqld
>  1647   0:09.25 -      mysqld
> 
> It's like when it starts working it builds up time, but as soon as it
> goes back to ucond, it resets back to the earlier value.

By default, ps only lists one thread when listing threaded processes, and if
it's anything like top, the CPU column seems to be randomly picked from one
thread.  Try running "ps axHo pid,lwp,time,wchan,comm" instead (add H and
lwp).

That will print the individual threads, plus the thread id so you can track
them across runs.  You should see one thread with a CPU value of "8.08" (or
so), and other values for the rest.  Ideally, top and ps would total up all
the per-thread CPU counts when displaying the per-process numbers, but it
doesn't seem to.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-hackers mailing list