cputime: Bring cputime -> nsecs conversion

We already have nsecs_to_cputime(). Now we need to be able to convert
the other way around in order to fix a bug on steal time accounting.

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
This commit is contained in:
Frederic Weisbecker 2014-03-05 16:22:37 +01:00
parent bfc3f0281e
commit d8a9ce3f8a
3 changed files with 10 additions and 1 deletions

View File

@ -15,8 +15,10 @@ typedef u64 __nocast cputime64_t;
/*
* Convert nanoseconds to cputime
* Convert nanoseconds <-> cputime
*/
#define cputime_to_nsecs(__ct) \
jiffies_to_nsecs(cputime_to_jiffies(__ct))
#define nsecs_to_cputime64(__nsec) \
jiffies64_to_cputime64(nsecs_to_jiffies64(__nsec))
#define nsecs_to_cputime(__nsec) \

View File

@ -44,6 +44,8 @@ typedef u64 __nocast cputime64_t;
/*
* Convert cputime <-> nanoseconds
*/
#define cputime_to_nsecs(__ct) \
(__force u64)(__ct)
#define nsecs_to_cputime(__nsecs) \
(__force cputime_t)(__nsecs)

View File

@ -3,6 +3,11 @@
#include <asm/cputime.h>
#ifndef cputime_to_nsecs
# define cputime_to_nsecs(__ct) \
(cputime_to_usecs(__ct) * NSEC_PER_USEC)
#endif
#ifndef nsecs_to_cputime
# define nsecs_to_cputime(__nsecs) \
usecs_to_cputime((__nsecs) / NSEC_PER_USEC)