* Transform the running time and tick information in proc p into user * and system time usage. If appropriate, include the current time slice * on this CPU. */
| 816 | * on this CPU. |
| 817 | */ |
| 818 | void |
| 819 | calcru(struct proc *p, struct timeval *up, struct timeval *sp) |
| 820 | { |
| 821 | struct thread *td; |
| 822 | uint64_t runtime, u; |
| 823 | |
| 824 | PROC_LOCK_ASSERT(p, MA_OWNED); |
| 825 | PROC_STATLOCK_ASSERT(p, MA_OWNED); |
| 826 | /* |
| 827 | * If we are getting stats for the current process, then add in the |
| 828 | * stats that this thread has accumulated in its current time slice. |
| 829 | * We reset the thread and CPU state as if we had performed a context |
| 830 | * switch right here. |
| 831 | */ |
| 832 | td = curthread; |
| 833 | if (td->td_proc == p) { |
| 834 | u = cpu_ticks(); |
| 835 | runtime = u - PCPU_GET(switchtime); |
| 836 | td->td_runtime += runtime; |
| 837 | td->td_incruntime += runtime; |
| 838 | PCPU_SET(switchtime, u); |
| 839 | } |
| 840 | /* Make sure the per-thread stats are current. */ |
| 841 | FOREACH_THREAD_IN_PROC(p, td) { |
| 842 | if (td->td_incruntime == 0) |
| 843 | continue; |
| 844 | ruxagg(p, td); |
| 845 | } |
| 846 | calcru1(p, &p->p_rux, up, sp); |
| 847 | } |
| 848 | |
| 849 | /* Collect resource usage for a single thread. */ |
| 850 | void |
no test coverage detected