Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+10 -1
+3 -1
include/asm-generic/cputime_jiffies.h
··· 15 15 16 16 17 17 /* 18 - * Convert nanoseconds to cputime 18 + * Convert nanoseconds <-> cputime 19 19 */ 20 + #define cputime_to_nsecs(__ct) \ 21 + jiffies_to_nsecs(cputime_to_jiffies(__ct)) 20 22 #define nsecs_to_cputime64(__nsec) \ 21 23 jiffies64_to_cputime64(nsecs_to_jiffies64(__nsec)) 22 24 #define nsecs_to_cputime(__nsec) \
+2
include/asm-generic/cputime_nsecs.h
··· 44 44 /* 45 45 * Convert cputime <-> nanoseconds 46 46 */ 47 + #define cputime_to_nsecs(__ct) \ 48 + (__force u64)(__ct) 47 49 #define nsecs_to_cputime(__nsecs) \ 48 50 (__force cputime_t)(__nsecs) 49 51
+5
include/linux/cputime.h
··· 3 3 4 4 #include <asm/cputime.h> 5 5 6 + #ifndef cputime_to_nsecs 7 + # define cputime_to_nsecs(__ct) \ 8 + (cputime_to_usecs(__ct) * NSEC_PER_USEC) 9 + #endif 10 + 6 11 #ifndef nsecs_to_cputime 7 12 # define nsecs_to_cputime(__nsecs) \ 8 13 usecs_to_cputime((__nsecs) / NSEC_PER_USEC)