]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - kernel/sched/cputime.c
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[karo-tx-linux.git] / kernel / sched / cputime.c
index e9e742ed72803a1943a97ac8c39fc2d4f66d2da4..99947919e30bc68963d3bfa937ebad8a2c90ba87 100644 (file)
@@ -121,7 +121,7 @@ static inline void task_group_account_field(struct task_struct *p, int index,
         * is the only cgroup, then nothing else should be necessary.
         *
         */
-       __get_cpu_var(kernel_cpustat).cpustat[index] += tmp;
+       __this_cpu_add(kernel_cpustat.cpustat[index], tmp);
 
        cpuacct_account_field(p, index, tmp);
 }
@@ -551,10 +551,7 @@ static void cputime_adjust(struct task_cputime *curr,
                           struct cputime *prev,
                           cputime_t *ut, cputime_t *st)
 {
-       cputime_t rtime, stime, utime, total;
-
-       stime = curr->stime;
-       total = stime + curr->utime;
+       cputime_t rtime, stime, utime;
 
        /*
         * Tick based cputime accounting depend on random scheduling
@@ -576,13 +573,19 @@ static void cputime_adjust(struct task_cputime *curr,
        if (prev->stime + prev->utime >= rtime)
                goto out;
 
-       if (total) {
+       stime = curr->stime;
+       utime = curr->utime;
+
+       if (utime == 0) {
+               stime = rtime;
+       } else if (stime == 0) {
+               utime = rtime;
+       } else {
+               cputime_t total = stime + utime;
+
                stime = scale_stime((__force u64)stime,
                                    (__force u64)rtime, (__force u64)total);
                utime = rtime - stime;
-       } else {
-               stime = rtime;
-               utime = 0;
        }
 
        /*
@@ -660,9 +663,9 @@ void vtime_account_system(struct task_struct *tsk)
 void vtime_gen_account_irq_exit(struct task_struct *tsk)
 {
        write_seqlock(&tsk->vtime_seqlock);
+       __vtime_account_system(tsk);
        if (context_tracking_in_user())
                tsk->vtime_snap_whence = VTIME_USER;
-       __vtime_account_system(tsk);
        write_sequnlock(&tsk->vtime_seqlock);
 }
 
@@ -680,8 +683,8 @@ void vtime_account_user(struct task_struct *tsk)
 void vtime_user_enter(struct task_struct *tsk)
 {
        write_seqlock(&tsk->vtime_seqlock);
-       tsk->vtime_snap_whence = VTIME_USER;
        __vtime_account_system(tsk);
+       tsk->vtime_snap_whence = VTIME_USER;
        write_sequnlock(&tsk->vtime_seqlock);
 }