[tip:timers/core] cputime: Fix nsecs_to_cputime() return type cast

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  6ef672ad933956dc1335e67d852896a9677b9a1f
Gitweb:     http://git.kernel.org/tip/6ef672ad933956dc1335e67d852896a9677b9a1f
Author:     Frederic Weisbecker <fweisbec@xxxxxxxxx>
AuthorDate: Wed, 5 Mar 2014 15:33:18 +0100
Committer:  Frederic Weisbecker <fweisbec@xxxxxxxxx>
CommitDate: Wed, 12 Mar 2014 02:03:55 +0100

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@xxxxxxxxxx>
Cc: Marcelo Tosatti <mtosatti@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Acked-by: Rik van Riel <riel@xxxxxxxxxx>
Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
---
 include/asm-generic/cputime_nsecs.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/asm-generic/cputime_nsecs.h b/include/asm-generic/cputime_nsecs.h
index 2c9e62c..768294f 100644
--- a/include/asm-generic/cputime_nsecs.h
+++ b/include/asm-generic/cputime_nsecs.h
@@ -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)
 
 
 /*
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux