Commit d8a9ce3f8ad2b546b9ebaf65de809da0793f11c5
1 parent
bfc3f0281e
Exists in
master
and in
13 other branches
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>
Showing 3 changed files with 10 additions and 1 deletions Side-by-side Diff
include/asm-generic/cputime_jiffies.h
... | ... | @@ -15,8 +15,10 @@ |
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) \ |
include/asm-generic/cputime_nsecs.h
include/linux/cputime.h
... | ... | @@ -3,6 +3,11 @@ |
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) |