diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2017-01-30 22:09:16 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-02-01 03:13:45 -0500 |
commit | 93825f2ec736f30e034ab7c9d56b42849c5b00da (patch) | |
tree | 7e61fea64d0830050671211625c661a380515b5a | |
parent | ed5c8c854f2b990dfa4d85c4995d115768a05d3c (diff) |
jiffies: Reuse TICK_NSEC instead of NSEC_PER_JIFFY
NSEC_PER_JIFFY is an ad-hoc redefinition of TICK_NSEC. Let's rather
use a unique and well maintained version.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Wanpeng Li <wanpeng.li@hotmail.com>
Link: http://lkml.kernel.org/r/1485832191-26889-1-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | kernel/time/jiffies.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/kernel/time/jiffies.c b/kernel/time/jiffies.c index a4a0e478e44d..7906b3f0c41a 100644 --- a/kernel/time/jiffies.c +++ b/kernel/time/jiffies.c | |||
@@ -27,19 +27,8 @@ | |||
27 | 27 | ||
28 | #include "timekeeping.h" | 28 | #include "timekeeping.h" |
29 | 29 | ||
30 | /* The Jiffies based clocksource is the lowest common | ||
31 | * denominator clock source which should function on | ||
32 | * all systems. It has the same coarse resolution as | ||
33 | * the timer interrupt frequency HZ and it suffers | ||
34 | * inaccuracies caused by missed or lost timer | ||
35 | * interrupts and the inability for the timer | ||
36 | * interrupt hardware to accuratly tick at the | ||
37 | * requested HZ value. It is also not recommended | ||
38 | * for "tick-less" systems. | ||
39 | */ | ||
40 | #define NSEC_PER_JIFFY ((NSEC_PER_SEC+HZ/2)/HZ) | ||
41 | 30 | ||
42 | /* Since jiffies uses a simple NSEC_PER_JIFFY multiplier | 31 | /* Since jiffies uses a simple TICK_NSEC multiplier |
43 | * conversion, the .shift value could be zero. However | 32 | * conversion, the .shift value could be zero. However |
44 | * this would make NTP adjustments impossible as they are | 33 | * this would make NTP adjustments impossible as they are |
45 | * in units of 1/2^.shift. Thus we use JIFFIES_SHIFT to | 34 | * in units of 1/2^.shift. Thus we use JIFFIES_SHIFT to |
@@ -47,8 +36,8 @@ | |||
47 | * amount, and give ntp adjustments in units of 1/2^8 | 36 | * amount, and give ntp adjustments in units of 1/2^8 |
48 | * | 37 | * |
49 | * The value 8 is somewhat carefully chosen, as anything | 38 | * The value 8 is somewhat carefully chosen, as anything |
50 | * larger can result in overflows. NSEC_PER_JIFFY grows as | 39 | * larger can result in overflows. TICK_NSEC grows as HZ |
51 | * HZ shrinks, so values greater than 8 overflow 32bits when | 40 | * shrinks, so values greater than 8 overflow 32bits when |
52 | * HZ=100. | 41 | * HZ=100. |
53 | */ | 42 | */ |
54 | #if HZ < 34 | 43 | #if HZ < 34 |
@@ -64,12 +53,23 @@ static u64 jiffies_read(struct clocksource *cs) | |||
64 | return (u64) jiffies; | 53 | return (u64) jiffies; |
65 | } | 54 | } |
66 | 55 | ||
56 | /* | ||
57 | * The Jiffies based clocksource is the lowest common | ||
58 | * denominator clock source which should function on | ||
59 | * all systems. It has the same coarse resolution as | ||
60 | * the timer interrupt frequency HZ and it suffers | ||
61 | * inaccuracies caused by missed or lost timer | ||
62 | * interrupts and the inability for the timer | ||
63 | * interrupt hardware to accuratly tick at the | ||
64 | * requested HZ value. It is also not recommended | ||
65 | * for "tick-less" systems. | ||
66 | */ | ||
67 | static struct clocksource clocksource_jiffies = { | 67 | static struct clocksource clocksource_jiffies = { |
68 | .name = "jiffies", | 68 | .name = "jiffies", |
69 | .rating = 1, /* lowest valid rating*/ | 69 | .rating = 1, /* lowest valid rating*/ |
70 | .read = jiffies_read, | 70 | .read = jiffies_read, |
71 | .mask = CLOCKSOURCE_MASK(32), | 71 | .mask = CLOCKSOURCE_MASK(32), |
72 | .mult = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */ | 72 | .mult = TICK_NSEC << JIFFIES_SHIFT, /* details above */ |
73 | .shift = JIFFIES_SHIFT, | 73 | .shift = JIFFIES_SHIFT, |
74 | .max_cycles = 10, | 74 | .max_cycles = 10, |
75 | }; | 75 | }; |
@@ -125,7 +125,7 @@ int register_refined_jiffies(long cycles_per_second) | |||
125 | shift_hz += cycles_per_tick/2; | 125 | shift_hz += cycles_per_tick/2; |
126 | do_div(shift_hz, cycles_per_tick); | 126 | do_div(shift_hz, cycles_per_tick); |
127 | /* Calculate nsec_per_tick using shift_hz */ | 127 | /* Calculate nsec_per_tick using shift_hz */ |
128 | nsec_per_tick = (u64)NSEC_PER_SEC << 8; | 128 | nsec_per_tick = (u64)TICK_NSEC << 8; |
129 | nsec_per_tick += (u32)shift_hz/2; | 129 | nsec_per_tick += (u32)shift_hz/2; |
130 | do_div(nsec_per_tick, (u32)shift_hz); | 130 | do_div(nsec_per_tick, (u32)shift_hz); |
131 | 131 | ||