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

cputime: Fix nsecs_to_cputime() return type cast

Even though nsec based cputime_t maps to u64, nsecs_to_cputime() must
return a cputime_t value. We want to enforce this kind of cast in order
to track down buggy manipulations of cputime_t such as direct access
of its values under wrong assumptions on its backend type (nsecs,
jiffies, etc...) by core code.

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>

+2 -1
+2 -1
include/asm-generic/cputime_nsecs.h
··· 44 44 /* 45 45 * Convert cputime <-> nanoseconds 46 46 */ 47 - #define nsecs_to_cputime(__nsecs) ((__force u64)(__nsecs)) 47 + #define nsecs_to_cputime(__nsecs) \ 48 + (__force cputime_t)(__nsecs) 48 49 49 50 50 51 /*