alpha: Fix jiffies based cputime assumption
authorFrederic Weisbecker <fweisbec@gmail.com>
Mon, 27 Oct 2014 16:20:35 +0000 (17:20 +0100)
committerFrederic Weisbecker <fweisbec@gmail.com>
Wed, 29 Jul 2015 13:44:58 +0000 (15:44 +0200)
That code wrongly assumes that cputime_t wraps jiffies_t. Lets use
the correct accessors/mutators.

In practice there should be no harm yet because alpha currently
only support tick based cputime accounting which is always jiffies
based.

Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Christoph Lameter <cl@linux.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc; John Stultz <john.stultz@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
arch/alpha/kernel/osf_sys.c

index 36dc91ace83ae97069df82f5e3923a24275c6a9b..6cc08166ff00d0f616b3a10146014e3ca4453d4b 100644 (file)
@@ -1138,6 +1138,7 @@ SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
 {
        struct rusage32 r;
        cputime_t utime, stime;
+       unsigned long utime_jiffies, stime_jiffies;
 
        if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
                return -EINVAL;
@@ -1146,14 +1147,18 @@ SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
        switch (who) {
        case RUSAGE_SELF:
                task_cputime(current, &utime, &stime);
-               jiffies_to_timeval32(utime, &r.ru_utime);
-               jiffies_to_timeval32(stime, &r.ru_stime);
+               utime_jiffies = cputime_to_jiffies(utime);
+               stime_jiffies = cputime_to_jiffies(stime);
+               jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
+               jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
                r.ru_minflt = current->min_flt;
                r.ru_majflt = current->maj_flt;
                break;
        case RUSAGE_CHILDREN:
-               jiffies_to_timeval32(current->signal->cutime, &r.ru_utime);
-               jiffies_to_timeval32(current->signal->cstime, &r.ru_stime);
+               utime_jiffies = cputime_to_jiffies(current->signal->cutime);
+               stime_jiffies = cputime_to_jiffies(current->signal->cstime);
+               jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
+               jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
                r.ru_minflt = current->signal->cmin_flt;
                r.ru_majflt = current->signal->cmaj_flt;
                break;