Syscall getrusage and times, and the rusage parameter in wait series syscalls are now pseudo implementation that return zeros instead of real data. The common data they try to obtain are the actual time elapsed in kernel space and in user space while we are processing this thread's task. We can record the current time before we call trap_return and calculate the elapsed time after we've returned to the kernel space and add that to the user space time. The kernel space time can be calculated similarly before and after we handle the syscalls, page faults and signals.
Note that the time elapsed in IRQ handlers should NOT be counted in.