diff options
-rw-r--r-- | include/linux/jiffies.h | 21 | ||||
-rw-r--r-- | include/linux/timex.h | 2 | ||||
-rw-r--r-- | kernel/time/jiffies.c | 2 | ||||
-rw-r--r-- | kernel/time/ntp.c | 2 |
4 files changed, 16 insertions, 11 deletions
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index 7d24466fb80b..82680541576d 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h | |||
@@ -55,21 +55,26 @@ | |||
55 | /* LATCH is used in the interval timer and ftape setup. */ | 55 | /* LATCH is used in the interval timer and ftape setup. */ |
56 | # define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ | 56 | # define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ |
57 | 57 | ||
58 | /* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */ | 58 | /* |
59 | # define ACTHZ (SH_DIV(CLOCK_TICK_RATE, LATCH, 8)) | 59 | * HZ is the requested value. However the CLOCK_TICK_RATE may not allow |
60 | * for exactly HZ. So SHIFTED_HZ is high res HZ ("<< 8" is for accuracy) | ||
61 | */ | ||
62 | # define SHIFTED_HZ (SH_DIV(CLOCK_TICK_RATE, LATCH, 8)) | ||
60 | #else | 63 | #else |
61 | # define ACTHZ (HZ << 8) | 64 | # define SHIFTED_HZ (HZ << 8) |
62 | #endif | 65 | #endif |
63 | 66 | ||
64 | /* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */ | 67 | /* TICK_NSEC is the time between ticks in nsec assuming SHIFTED_HZ */ |
65 | #define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8)) | 68 | #define TICK_NSEC (SH_DIV(1000000UL * 1000, SHIFTED_HZ, 8)) |
66 | 69 | ||
67 | /* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */ | 70 | /* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */ |
68 | #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ) | 71 | #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ) |
69 | 72 | ||
70 | /* TICK_USEC_TO_NSEC is the time between ticks in nsec assuming real ACTHZ and */ | 73 | /* |
71 | /* a value TUSEC for TICK_USEC (can be set bij adjtimex) */ | 74 | * TICK_USEC_TO_NSEC is the time between ticks in nsec assuming SHIFTED_HZ and |
72 | #define TICK_USEC_TO_NSEC(TUSEC) (SH_DIV (TUSEC * USER_HZ * 1000, ACTHZ, 8)) | 75 | * a value TUSEC for TICK_USEC (can be set bij adjtimex) |
76 | */ | ||
77 | #define TICK_USEC_TO_NSEC(TUSEC) (SH_DIV(TUSEC * USER_HZ * 1000, SHIFTED_HZ, 8)) | ||
73 | 78 | ||
74 | /* some arch's have a small-data section that can be accessed register-relative | 79 | /* some arch's have a small-data section that can be accessed register-relative |
75 | * but that can only take up to, say, 4-byte variables. jiffies being part of | 80 | * but that can only take up to, say, 4-byte variables. jiffies being part of |
diff --git a/include/linux/timex.h b/include/linux/timex.h index 99bc88b1fc02..7c5ceb20e03a 100644 --- a/include/linux/timex.h +++ b/include/linux/timex.h | |||
@@ -232,7 +232,7 @@ struct timex { | |||
232 | * estimated error = NTP dispersion. | 232 | * estimated error = NTP dispersion. |
233 | */ | 233 | */ |
234 | extern unsigned long tick_usec; /* USER_HZ period (usec) */ | 234 | extern unsigned long tick_usec; /* USER_HZ period (usec) */ |
235 | extern unsigned long tick_nsec; /* ACTHZ period (nsec) */ | 235 | extern unsigned long tick_nsec; /* SHIFTED_HZ period (nsec) */ |
236 | 236 | ||
237 | extern void ntp_init(void); | 237 | extern void ntp_init(void); |
238 | extern void ntp_clear(void); | 238 | extern void ntp_clear(void); |
diff --git a/kernel/time/jiffies.c b/kernel/time/jiffies.c index a470154e0408..46da0537c10b 100644 --- a/kernel/time/jiffies.c +++ b/kernel/time/jiffies.c | |||
@@ -37,7 +37,7 @@ | |||
37 | * requested HZ value. It is also not recommended | 37 | * requested HZ value. It is also not recommended |
38 | * for "tick-less" systems. | 38 | * for "tick-less" systems. |
39 | */ | 39 | */ |
40 | #define NSEC_PER_JIFFY ((u32)((((u64)NSEC_PER_SEC)<<8)/ACTHZ)) | 40 | #define NSEC_PER_JIFFY ((u32)((((u64)NSEC_PER_SEC)<<8)/SHIFTED_HZ)) |
41 | 41 | ||
42 | /* Since jiffies uses a simple NSEC_PER_JIFFY multiplier | 42 | /* Since jiffies uses a simple NSEC_PER_JIFFY multiplier |
43 | * conversion, the .shift value could be zero. However | 43 | * conversion, the .shift value could be zero. However |
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index b7fbadc5c973..24174b4d669b 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
@@ -28,7 +28,7 @@ DEFINE_SPINLOCK(ntp_lock); | |||
28 | /* USER_HZ period (usecs): */ | 28 | /* USER_HZ period (usecs): */ |
29 | unsigned long tick_usec = TICK_USEC; | 29 | unsigned long tick_usec = TICK_USEC; |
30 | 30 | ||
31 | /* ACTHZ period (nsecs): */ | 31 | /* SHIFTED_HZ period (nsecs): */ |
32 | unsigned long tick_nsec; | 32 | unsigned long tick_nsec; |
33 | 33 | ||
34 | static u64 tick_length; | 34 | static u64 tick_length; |