diff --git a/include/linux/sched.h b/include/linux/sched.h index d35d2b6..3f1c088 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -418,6 +418,7 @@ struct cpu_itimer { struct cputime { cputime_t utime; cputime_t stime; + cputime_t rtime; }; /** diff --git a/kernel/fork.c b/kernel/fork.c index 1766d32..d67c219 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1235,6 +1235,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, p->utimescaled = p->stimescaled = 0; #ifndef CONFIG_VIRT_CPU_ACCOUNTING p->prev_cputime.utime = p->prev_cputime.stime = 0; + p->prev_cputime.rtime = 0; #endif #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN seqlock_init(&p->vtime_seqlock); diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index ed12cbb..146e5f1 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -560,6 +560,9 @@ static void cputime_adjust(struct task_cputime *curr, */ rtime = nsecs_to_cputime(curr->sum_exec_runtime); + WARN_ON(prev->rtime > rtime); + prev->rtime = rtime; + if (total) stime = scale_stime(stime, rtime, total); else