diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-08-03 13:58:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-08-03 13:58:57 -0400 |
commit | ddc5057c1c1fb3e99afeeef45d2b8ff9597e6707 (patch) | |
tree | 801e4842f3a4dce2d777336b54f3caf075975025 /include | |
parent | fcc1d2a9cea4ba97c9800e1de0748003bba07335 (diff) | |
parent | 4e250fdde9be50581c7dd5fed88c9b9960615314 (diff) |
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Ingo Molnar:
"One regression fix, and a couple of cleanups that clean up the code
flow in areas that had high-profile bugs recently."
* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
time: Remove all direct references to timekeeper
time: Clean up offs_real/wall_to_mono and offs_boot/total_sleep_time updates
time: Clean up stray newlines
time/jiffies: Rename ACTHZ to SHIFTED_HZ
time/jiffies: Allow CLOCK_TICK_RATE to be undefined
time: Fix casting issue in tk_set_xtime and tk_xtime_add
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/jiffies.h | 29 | ||||
-rw-r--r-- | include/linux/timex.h | 2 |
2 files changed, 20 insertions, 11 deletions
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index 265e2c3cbd1c..82680541576d 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h | |||
@@ -39,9 +39,6 @@ | |||
39 | # error Invalid value of HZ. | 39 | # error Invalid value of HZ. |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | /* LATCH is used in the interval timer and ftape setup. */ | ||
43 | #define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ | ||
44 | |||
45 | /* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can | 42 | /* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can |
46 | * improve accuracy by shifting LSH bits, hence calculating: | 43 | * improve accuracy by shifting LSH bits, hence calculating: |
47 | * (NOM << LSH) / DEN | 44 | * (NOM << LSH) / DEN |
@@ -54,18 +51,30 @@ | |||
54 | #define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \ | 51 | #define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \ |
55 | + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN)) | 52 | + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN)) |
56 | 53 | ||
57 | /* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */ | 54 | #ifdef CLOCK_TICK_RATE |
58 | #define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) | 55 | /* LATCH is used in the interval timer and ftape setup. */ |
56 | # define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ | ||
57 | |||
58 | /* | ||
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)) | ||
63 | #else | ||
64 | # define SHIFTED_HZ (HZ << 8) | ||
65 | #endif | ||
59 | 66 | ||
60 | /* 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 */ |
61 | #define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8)) | 68 | #define TICK_NSEC (SH_DIV(1000000UL * 1000, SHIFTED_HZ, 8)) |
62 | 69 | ||
63 | /* 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 */ |
64 | #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ) | 71 | #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ) |
65 | 72 | ||
66 | /* TICK_USEC_TO_NSEC is the time between ticks in nsec assuming real ACTHZ and */ | 73 | /* |
67 | /* 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 |
68 | #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)) | ||
69 | 78 | ||
70 | /* 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 |
71 | * 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); |