Commit cc06268c6a87db156af2daed6e96a936b955cc82
Committed by
John Stultz
1 parent
058892e632
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
time: Move common updates to a function
CC: Thomas Gleixner <tglx@linutronix.de> CC: Eric Dumazet <eric.dumazet@gmail.com> CC: Richard Cochran <richardcochran@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
Showing 1 changed file with 17 additions and 22 deletions Side-by-side Diff
kernel/time/timekeeping.c
... | ... | @@ -172,17 +172,26 @@ |
172 | 172 | return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift); |
173 | 173 | } |
174 | 174 | |
175 | +/* must hold write on timekeeper.lock */ | |
176 | +static void timekeeping_update(bool clearntp) | |
177 | +{ | |
178 | + if (clearntp) { | |
179 | + timekeeper.ntp_error = 0; | |
180 | + ntp_clear(); | |
181 | + } | |
182 | + update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, | |
183 | + timekeeper.clock, timekeeper.mult); | |
184 | +} | |
185 | + | |
186 | + | |
175 | 187 | void timekeeping_leap_insert(int leapsecond) |
176 | 188 | { |
177 | 189 | unsigned long flags; |
178 | 190 | |
179 | 191 | write_seqlock_irqsave(&timekeeper.lock, flags); |
180 | - | |
181 | 192 | timekeeper.xtime.tv_sec += leapsecond; |
182 | 193 | timekeeper.wall_to_monotonic.tv_sec -= leapsecond; |
183 | - update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, | |
184 | - timekeeper.clock, timekeeper.mult); | |
185 | - | |
194 | + timekeeping_update(false); | |
186 | 195 | write_sequnlock_irqrestore(&timekeeper.lock, flags); |
187 | 196 | |
188 | 197 | } |
189 | 198 | |
... | ... | @@ -386,13 +395,8 @@ |
386 | 395 | timespec_sub(timekeeper.wall_to_monotonic, ts_delta); |
387 | 396 | |
388 | 397 | timekeeper.xtime = *tv; |
398 | + timekeeping_update(true); | |
389 | 399 | |
390 | - timekeeper.ntp_error = 0; | |
391 | - ntp_clear(); | |
392 | - | |
393 | - update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, | |
394 | - timekeeper.clock, timekeeper.mult); | |
395 | - | |
396 | 400 | write_sequnlock_irqrestore(&timekeeper.lock, flags); |
397 | 401 | |
398 | 402 | /* signal hrtimers about time change */ |
399 | 403 | |
... | ... | @@ -425,12 +429,8 @@ |
425 | 429 | timekeeper.wall_to_monotonic = |
426 | 430 | timespec_sub(timekeeper.wall_to_monotonic, *ts); |
427 | 431 | |
428 | - timekeeper.ntp_error = 0; | |
429 | - ntp_clear(); | |
432 | + timekeeping_update(true); | |
430 | 433 | |
431 | - update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, | |
432 | - timekeeper.clock, timekeeper.mult); | |
433 | - | |
434 | 434 | write_sequnlock_irqrestore(&timekeeper.lock, flags); |
435 | 435 | |
436 | 436 | /* signal hrtimers about time change */ |
... | ... | @@ -668,10 +668,7 @@ |
668 | 668 | |
669 | 669 | __timekeeping_inject_sleeptime(delta); |
670 | 670 | |
671 | - timekeeper.ntp_error = 0; | |
672 | - ntp_clear(); | |
673 | - update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, | |
674 | - timekeeper.clock, timekeeper.mult); | |
671 | + timekeeping_update(true); | |
675 | 672 | |
676 | 673 | write_sequnlock_irqrestore(&timekeeper.lock, flags); |
677 | 674 | |
... | ... | @@ -1083,9 +1080,7 @@ |
1083 | 1080 | second_overflow(); |
1084 | 1081 | } |
1085 | 1082 | |
1086 | - /* check to see if there is a new clocksource to use */ | |
1087 | - update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, | |
1088 | - timekeeper.clock, timekeeper.mult); | |
1083 | + timekeeping_update(false); | |
1089 | 1084 | |
1090 | 1085 | out: |
1091 | 1086 | write_sequnlock_irqrestore(&timekeeper.lock, flags); |