diff options
author | Alexander Motin <mav@FreeBSD.org> | 2019-06-14 01:09:10 +0000 |
---|---|---|
committer | Alexander Motin <mav@FreeBSD.org> | 2019-06-14 01:09:10 +0000 |
commit | c80038a0a732d1fbbb3ea1566c995c37e0fbe047 (patch) | |
tree | 1251a72bff1f0bd33af164d8d5cbd9189857a8f4 /sys/kern/kern_clock.c | |
parent | 1682a3ab4b725e31e9aab4aa4a8aa2ba400463fe (diff) | |
download | src-c80038a0a732d1fbbb3ea1566c995c37e0fbe047.tar.gz src-c80038a0a732d1fbbb3ea1566c995c37e0fbe047.zip |
Notes
Diffstat (limited to 'sys/kern/kern_clock.c')
-rw-r--r-- | sys/kern/kern_clock.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 47cdce455bc3..f4910e4728d2 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -644,6 +644,7 @@ statclock(int cnt, int usermode) struct proc *p; long rss; long *cp_time; + uint64_t runtime, new_switchtime; td = curthread; p = td->td_proc; @@ -699,6 +700,17 @@ statclock(int cnt, int usermode) "prio:%d", td->td_priority, "stathz:%d", (stathz)?stathz:hz); SDT_PROBE2(sched, , , tick, td, td->td_proc); thread_lock_flags(td, MTX_QUIET); + + /* + * Compute the amount of time during which the current + * thread was running, and add that to its total so far. + */ + new_switchtime = cpu_ticks(); + runtime = new_switchtime - PCPU_GET(switchtime); + td->td_runtime += runtime; + td->td_incruntime += runtime; + PCPU_SET(switchtime, new_switchtime); + for ( ; cnt > 0; cnt--) sched_clock(td); thread_unlock(td); |