Skip to content

Commit

Permalink
cputime: Fix nsecs_to_cputime() return type cast
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Frederic Weisbecker committed Mar 13, 2014
1 parent 6f008e7 commit 69bb260
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/asm-generic/cputime_nsecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ typedef u64 __nocast cputime64_t;
/*
* Convert cputime <-> nanoseconds
*/
#define nsecs_to_cputime(__nsecs) ((__force u64)(__nsecs))
#define nsecs_to_cputime(__nsecs) \
(__force cputime_t)(__nsecs)


/*
Expand Down

0 comments on commit 69bb260

Please sign in to comment.