aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ia64/include/asm/cputime.h1
-rw-r--r--arch/powerpc/include/asm/cputime.h13
-rw-r--r--arch/powerpc/kernel/time.c4
-rw-r--r--arch/s390/include/asm/cputime.h1
-rw-r--r--include/asm-generic/cputime.h1
-rw-r--r--kernel/itimer.c4
-rw-r--r--kernel/posix-cpu-timers.c6
-rw-r--r--kernel/sched.c9
8 files changed, 29 insertions, 10 deletions
diff --git a/arch/ia64/include/asm/cputime.h b/arch/ia64/include/asm/cputime.h
index d20b998cb91d..7fa8a8594660 100644
--- a/arch/ia64/include/asm/cputime.h
+++ b/arch/ia64/include/asm/cputime.h
@@ -30,6 +30,7 @@ typedef u64 cputime_t;
30typedef u64 cputime64_t; 30typedef u64 cputime64_t;
31 31
32#define cputime_zero ((cputime_t)0) 32#define cputime_zero ((cputime_t)0)
33#define cputime_one_jiffy jiffies_to_cputime(1)
33#define cputime_max ((~((cputime_t)0) >> 1) - 1) 34#define cputime_max ((~((cputime_t)0) >> 1) - 1)
34#define cputime_add(__a, __b) ((__a) + (__b)) 35#define cputime_add(__a, __b) ((__a) + (__b))
35#define cputime_sub(__a, __b) ((__a) - (__b)) 36#define cputime_sub(__a, __b) ((__a) - (__b))
diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h
index f42e623030ee..fa19f3fe05ff 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -18,6 +18,9 @@
18 18
19#ifndef CONFIG_VIRT_CPU_ACCOUNTING 19#ifndef CONFIG_VIRT_CPU_ACCOUNTING
20#include <asm-generic/cputime.h> 20#include <asm-generic/cputime.h>
21#ifdef __KERNEL__
22static inline void setup_cputime_one_jiffy(void) { }
23#endif
21#else 24#else
22 25
23#include <linux/types.h> 26#include <linux/types.h>
@@ -49,6 +52,11 @@ typedef u64 cputime64_t;
49#ifdef __KERNEL__ 52#ifdef __KERNEL__
50 53
51/* 54/*
55 * One jiffy in timebase units computed during initialization
56 */
57extern cputime_t cputime_one_jiffy;
58
59/*
52 * Convert cputime <-> jiffies 60 * Convert cputime <-> jiffies
53 */ 61 */
54extern u64 __cputime_jiffies_factor; 62extern u64 __cputime_jiffies_factor;
@@ -89,6 +97,11 @@ static inline cputime_t jiffies_to_cputime(const unsigned long jif)
89 return ct; 97 return ct;
90} 98}
91 99
100static inline void setup_cputime_one_jiffy(void)
101{
102 cputime_one_jiffy = jiffies_to_cputime(1);
103}
104
92static inline cputime64_t jiffies64_to_cputime64(const u64 jif) 105static inline cputime64_t jiffies64_to_cputime64(const u64 jif)
93{ 106{
94 cputime_t ct; 107 cputime_t ct;
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index eae4511ceeac..211d7b0cd370 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -193,6 +193,8 @@ EXPORT_SYMBOL(__cputime_clockt_factor);
193DEFINE_PER_CPU(unsigned long, cputime_last_delta); 193DEFINE_PER_CPU(unsigned long, cputime_last_delta);
194DEFINE_PER_CPU(unsigned long, cputime_scaled_last_delta); 194DEFINE_PER_CPU(unsigned long, cputime_scaled_last_delta);
195 195
196cputime_t cputime_one_jiffy;
197
196static void calc_cputime_factors(void) 198static void calc_cputime_factors(void)
197{ 199{
198 struct div_result res; 200 struct div_result res;
@@ -500,6 +502,7 @@ static int __init iSeries_tb_recal(void)
500 tb_to_xs = divres.result_low; 502 tb_to_xs = divres.result_low;
501 vdso_data->tb_ticks_per_sec = tb_ticks_per_sec; 503 vdso_data->tb_ticks_per_sec = tb_ticks_per_sec;
502 vdso_data->tb_to_xs = tb_to_xs; 504 vdso_data->tb_to_xs = tb_to_xs;
505 setup_cputime_one_jiffy();
503 } 506 }
504 else { 507 else {
505 printk( "Titan recalibrate: FAILED (difference > 4 percent)\n" 508 printk( "Titan recalibrate: FAILED (difference > 4 percent)\n"
@@ -945,6 +948,7 @@ void __init time_init(void)
945 tb_ticks_per_usec = ppc_tb_freq / 1000000; 948 tb_ticks_per_usec = ppc_tb_freq / 1000000;
946 tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000); 949 tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000);
947 calc_cputime_factors(); 950 calc_cputime_factors();
951 setup_cputime_one_jiffy();
948 952
949 /* 953 /*
950 * Calculate the length of each tick in ns. It will not be 954 * Calculate the length of each tick in ns. It will not be
diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h
index 7a3817a656df..24b1244aadb9 100644
--- a/arch/s390/include/asm/cputime.h
+++ b/arch/s390/include/asm/cputime.h
@@ -42,6 +42,7 @@ __div(unsigned long long n, unsigned int base)
42#endif /* __s390x__ */ 42#endif /* __s390x__ */
43 43
44#define cputime_zero (0ULL) 44#define cputime_zero (0ULL)
45#define cputime_one_jiffy jiffies_to_cputime(1)
45#define cputime_max ((~0UL >> 1) - 1) 46#define cputime_max ((~0UL >> 1) - 1)
46#define cputime_add(__a, __b) ((__a) + (__b)) 47#define cputime_add(__a, __b) ((__a) + (__b))
47#define cputime_sub(__a, __b) ((__a) - (__b)) 48#define cputime_sub(__a, __b) ((__a) - (__b))
diff --git a/include/asm-generic/cputime.h b/include/asm-generic/cputime.h
index 1c1fa422d18a..ca0f239f0e13 100644
--- a/include/asm-generic/cputime.h
+++ b/include/asm-generic/cputime.h
@@ -7,6 +7,7 @@
7typedef unsigned long cputime_t; 7typedef unsigned long cputime_t;
8 8
9#define cputime_zero (0UL) 9#define cputime_zero (0UL)
10#define cputime_one_jiffy jiffies_to_cputime(1)
10#define cputime_max ((~0UL >> 1) - 1) 11#define cputime_max ((~0UL >> 1) - 1)
11#define cputime_add(__a, __b) ((__a) + (__b)) 12#define cputime_add(__a, __b) ((__a) + (__b))
12#define cputime_sub(__a, __b) ((__a) - (__b)) 13#define cputime_sub(__a, __b) ((__a) - (__b))
diff --git a/kernel/itimer.c b/kernel/itimer.c
index 21adff7b2a17..8078a32d3b10 100644
--- a/kernel/itimer.c
+++ b/kernel/itimer.c
@@ -64,7 +64,7 @@ static void get_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,
64 64
65 if (cputime_le(cval, t)) 65 if (cputime_le(cval, t))
66 /* about to fire */ 66 /* about to fire */
67 cval = jiffies_to_cputime(1); 67 cval = cputime_one_jiffy;
68 else 68 else
69 cval = cputime_sub(cval, t); 69 cval = cputime_sub(cval, t);
70 } 70 }
@@ -161,7 +161,7 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,
161 if (!cputime_eq(cval, cputime_zero) || 161 if (!cputime_eq(cval, cputime_zero) ||
162 !cputime_eq(nval, cputime_zero)) { 162 !cputime_eq(nval, cputime_zero)) {
163 if (cputime_gt(nval, cputime_zero)) 163 if (cputime_gt(nval, cputime_zero))
164 nval = cputime_add(nval, jiffies_to_cputime(1)); 164 nval = cputime_add(nval, cputime_one_jiffy);
165 set_process_cpu_timer(tsk, clock_id, &nval, &cval); 165 set_process_cpu_timer(tsk, clock_id, &nval, &cval);
166 } 166 }
167 it->expires = nval; 167 it->expires = nval;
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index 69c92374355f..18bdde6f676f 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -1086,7 +1086,7 @@ static void check_cpu_itimer(struct task_struct *tsk, struct cpu_itimer *it,
1086 it->error += it->incr_error; 1086 it->error += it->incr_error;
1087 if (it->error >= onecputick) { 1087 if (it->error >= onecputick) {
1088 it->expires = cputime_sub(it->expires, 1088 it->expires = cputime_sub(it->expires,
1089 jiffies_to_cputime(1)); 1089 cputime_one_jiffy);
1090 it->error -= onecputick; 1090 it->error -= onecputick;
1091 } 1091 }
1092 } else 1092 } else
@@ -1461,7 +1461,7 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
1461 if (!cputime_eq(*oldval, cputime_zero)) { 1461 if (!cputime_eq(*oldval, cputime_zero)) {
1462 if (cputime_le(*oldval, now.cpu)) { 1462 if (cputime_le(*oldval, now.cpu)) {
1463 /* Just about to fire. */ 1463 /* Just about to fire. */
1464 *oldval = jiffies_to_cputime(1); 1464 *oldval = cputime_one_jiffy;
1465 } else { 1465 } else {
1466 *oldval = cputime_sub(*oldval, now.cpu); 1466 *oldval = cputime_sub(*oldval, now.cpu);
1467 } 1467 }
@@ -1712,7 +1712,7 @@ static __init int init_posix_cpu_timers(void)
1712 register_posix_clock(CLOCK_PROCESS_CPUTIME_ID, &process); 1712 register_posix_clock(CLOCK_PROCESS_CPUTIME_ID, &process);
1713 register_posix_clock(CLOCK_THREAD_CPUTIME_ID, &thread); 1713 register_posix_clock(CLOCK_THREAD_CPUTIME_ID, &thread);
1714 1714
1715 cputime_to_timespec(jiffies_to_cputime(1), &ts); 1715 cputime_to_timespec(cputime_one_jiffy, &ts);
1716 onecputick = ts.tv_nsec; 1716 onecputick = ts.tv_nsec;
1717 WARN_ON(ts.tv_sec != 0); 1717 WARN_ON(ts.tv_sec != 0);
1718 1718
diff --git a/kernel/sched.c b/kernel/sched.c
index 1b59e265273b..8f977d5cc515 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5031,17 +5031,16 @@ void account_idle_time(cputime_t cputime)
5031 */ 5031 */
5032void account_process_tick(struct task_struct *p, int user_tick) 5032void account_process_tick(struct task_struct *p, int user_tick)
5033{ 5033{
5034 cputime_t one_jiffy = jiffies_to_cputime(1); 5034 cputime_t one_jiffy_scaled = cputime_to_scaled(cputime_one_jiffy);
5035 cputime_t one_jiffy_scaled = cputime_to_scaled(one_jiffy);
5036 struct rq *rq = this_rq(); 5035 struct rq *rq = this_rq();
5037 5036
5038 if (user_tick) 5037 if (user_tick)
5039 account_user_time(p, one_jiffy, one_jiffy_scaled); 5038 account_user_time(p, cputime_one_jiffy, one_jiffy_scaled);
5040 else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET)) 5039 else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET))
5041 account_system_time(p, HARDIRQ_OFFSET, one_jiffy, 5040 account_system_time(p, HARDIRQ_OFFSET, cputime_one_jiffy,
5042 one_jiffy_scaled); 5041 one_jiffy_scaled);
5043 else 5042 else
5044 account_idle_time(one_jiffy); 5043 account_idle_time(cputime_one_jiffy);
5045} 5044}
5046 5045
5047/* 5046/*