Linux内核中user、sys、iowait计算

Linux源代码路径: kernel/sched/cputime.c

void account_user_time(struct task_struct *p, u64 cputime)
{
        int index;

        /* Add user time to process. */
        p->utime += cputime;
        account_group_user_time(p, cputime);

        index = (task_nice(p) > 0) ? CPUTIME_NICE : CPUTIME_USER;

        /* Add user time to cpustat. */
        task_group_account_field(p, index, cputime);

        /* Account for user time used */
        acct_account_cputime(p);

        /* Account power usage for user time */
        cpufreq_acct_update_power(p, cputime);
}

/*
 * Account guest CPU time to a process.
 * @p: the process that the CPU time gets accounted to
 * @cputime: the CPU time spent in virtual machine since the last update
 */
void acc