提交 a1dabb6b 编写于 作者: V Venkatesh Pallipadi 提交者: Ingo Molnar

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: NShaun Ruffell <sruffell@digium.com>
Signed-off-by: NVenkatesh Pallipadi <venki@google.com>
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1292980144-28796-3-git-send-email-venki@google.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 4dd53d89
...@@ -30,6 +30,9 @@ typedef u64 cputime64_t; ...@@ -30,6 +30,9 @@ typedef u64 cputime64_t;
#define cputime64_to_jiffies64(__ct) (__ct) #define cputime64_to_jiffies64(__ct) (__ct)
#define jiffies64_to_cputime64(__jif) (__jif) #define jiffies64_to_cputime64(__jif) (__jif)
#define cputime_to_cputime64(__ct) ((u64) __ct) #define cputime_to_cputime64(__ct) ((u64) __ct)
#define cputime64_gt(__a, __b) ((__a) > (__b))
#define nsecs_to_cputime64(__ct) nsecs_to_jiffies64(__ct)
/* /*
......
...@@ -307,6 +307,7 @@ extern clock_t jiffies_to_clock_t(long x); ...@@ -307,6 +307,7 @@ extern clock_t jiffies_to_clock_t(long x);
extern unsigned long clock_t_to_jiffies(unsigned long x); extern unsigned long clock_t_to_jiffies(unsigned long x);
extern u64 jiffies_64_to_clock_t(u64 x); extern u64 jiffies_64_to_clock_t(u64 x);
extern u64 nsec_to_clock_t(u64 x); extern u64 nsec_to_clock_t(u64 x);
extern u64 nsecs_to_jiffies64(u64 n);
extern unsigned long nsecs_to_jiffies(u64 n); extern unsigned long nsecs_to_jiffies(u64 n);
#define TIMESTAMP_SIZE 30 #define TIMESTAMP_SIZE 30
......
...@@ -645,7 +645,7 @@ u64 nsec_to_clock_t(u64 x) ...@@ -645,7 +645,7 @@ u64 nsec_to_clock_t(u64 x)
} }
/** /**
* nsecs_to_jiffies - Convert nsecs in u64 to jiffies * nsecs_to_jiffies64 - Convert nsecs in u64 to jiffies64
* *
* @n: nsecs in u64 * @n: nsecs in u64
* *
...@@ -657,7 +657,7 @@ u64 nsec_to_clock_t(u64 x) ...@@ -657,7 +657,7 @@ u64 nsec_to_clock_t(u64 x)
* NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512) * NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
* ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years * ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
*/ */
unsigned long nsecs_to_jiffies(u64 n) u64 nsecs_to_jiffies64(u64 n)
{ {
#if (NSEC_PER_SEC % HZ) == 0 #if (NSEC_PER_SEC % HZ) == 0
/* Common case, HZ = 100, 128, 200, 250, 256, 500, 512, 1000 etc. */ /* Common case, HZ = 100, 128, 200, 250, 256, 500, 512, 1000 etc. */
...@@ -674,6 +674,25 @@ unsigned long nsecs_to_jiffies(u64 n) ...@@ -674,6 +674,25 @@ unsigned long nsecs_to_jiffies(u64 n)
#endif #endif
} }
/**
* nsecs_to_jiffies - Convert nsecs in u64 to jiffies
*
* @n: nsecs in u64
*
* Unlike {m,u}secs_to_jiffies, type of input is not unsigned int but u64.
* And this doesn't return MAX_JIFFY_OFFSET since this function is designed
* for scheduler, not for use in device drivers to calculate timeout value.
*
* note:
* NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
* ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
*/
unsigned long nsecs_to_jiffies(u64 n)
{
return (unsigned long)nsecs_to_jiffies64(n);
}
#if (BITS_PER_LONG < 64) #if (BITS_PER_LONG < 64)
u64 get_jiffies_64(void) u64 get_jiffies_64(void)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册