aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time.c
diff options
context:
space:
mode:
authorVenkatesh Pallipadi <venki@google.com>2010-12-21 20:09:01 -0500
committerIngo Molnar <mingo@elte.hu>2011-01-26 06:33:20 -0500
commita1dabb6bfffccb897eff3e1d102dacf2a4bedf3b (patch)
tree412e36223e65fca0bd8ea7db6a57553a25799245 /kernel/time.c
parent4dd53d891ca46dcc1fde0376a33540d3fd83cb9a (diff)
time: Add nsecs_to_cputime64 interface for asm-generic
Add nsecs_to_cputime64 interface. This is used in following patches that updates cpu irq stat based on ns granularity info in IRQ_TIME_ACCOUNTING. Tested-by: Shaun Ruffell <sruffell@digium.com> Signed-off-by: Venkatesh Pallipadi <venki@google.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1292980144-28796-3-git-send-email-venki@google.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/time.c')
-rw-r--r--kernel/time.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/kernel/time.c b/kernel/time.c
index 32174359576f..55337a816b20 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -645,7 +645,7 @@ u64 nsec_to_clock_t(u64 x)
645} 645}
646 646
647/** 647/**
648 * nsecs_to_jiffies - Convert nsecs in u64 to jiffies 648 * nsecs_to_jiffies64 - Convert nsecs in u64 to jiffies64
649 * 649 *
650 * @n: nsecs in u64 650 * @n: nsecs in u64
651 * 651 *
@@ -657,7 +657,7 @@ u64 nsec_to_clock_t(u64 x)
657 * NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512) 657 * NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
658 * ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years 658 * ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
659 */ 659 */
660unsigned long nsecs_to_jiffies(u64 n) 660u64 nsecs_to_jiffies64(u64 n)
661{ 661{
662#if (NSEC_PER_SEC % HZ) == 0 662#if (NSEC_PER_SEC % HZ) == 0
663 /* Common case, HZ = 100, 128, 200, 250, 256, 500, 512, 1000 etc. */ 663 /* Common case, HZ = 100, 128, 200, 250, 256, 500, 512, 1000 etc. */
@@ -674,6 +674,25 @@ unsigned long nsecs_to_jiffies(u64 n)
674#endif 674#endif
675} 675}
676 676
677
678/**
679 * nsecs_to_jiffies - Convert nsecs in u64 to jiffies
680 *
681 * @n: nsecs in u64
682 *
683 * Unlike {m,u}secs_to_jiffies, type of input is not unsigned int but u64.
684 * And this doesn't return MAX_JIFFY_OFFSET since this function is designed
685 * for scheduler, not for use in device drivers to calculate timeout value.
686 *
687 * note:
688 * NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
689 * ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
690 */
691unsigned long nsecs_to_jiffies(u64 n)
692{
693 return (unsigned long)nsecs_to_jiffies64(n);
694}
695
677#if (BITS_PER_LONG < 64) 696#if (BITS_PER_LONG < 64)
678u64 get_jiffies_64(void) 697u64 get_jiffies_64(void)
679{ 698{