Commit 6b43ae8
committed
ntp: Fix leap-second hrtimer livelock
Since commit 7dffa3c the ntp
subsystem has used an hrtimer for triggering the leapsecond
adjustment. However, this can cause a potential livelock.
Thomas diagnosed this as the following pattern:
CPU 0 CPU 1
do_adjtimex()
spin_lock_irq(&ntp_lock);
process_adjtimex_modes(); timer_interrupt()
process_adj_status(); do_timer()
ntp_start_leap_timer(); write_lock(&xtime_lock);
hrtimer_start(); update_wall_time();
hrtimer_reprogram(); ntp_tick_length()
tick_program_event() spin_lock(&ntp_lock);
clockevents_program_event()
ktime_get()
seq = req_seqbegin(xtime_lock);
This patch tries to avoid the problem by reverting back to not using
an hrtimer to inject leapseconds, and instead we handle the leapsecond
processing in the second_overflow() function.
The downside to this change is that on systems that support highres
timers, the leap second processing will occur on a HZ tick boundary,
(ie: ~1-10ms, depending on HZ) after the leap second instead of
possibly sooner (~34us in my tests w/ x86_64 lapic).
This patch applies on top of tip/timers/core.
CC: Sasha Levin <levinsasha928@gmail.com>
CC: Thomas Gleixner <tglx@linutronix.de>
Reported-by: Sasha Levin <levinsasha928@gmail.com>
Diagnoised-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>1 parent 57779dc commit 6b43ae8
3 files changed
+48
-102
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
| |||
381 | 379 | | |
382 | 380 | | |
383 | 381 | | |
384 | | - | |
385 | | - | |
386 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
387 | 390 | | |
388 | | - | |
| 391 | + | |
389 | 392 | | |
390 | | - | |
391 | | - | |
| 393 | + | |
392 | 394 | | |
| 395 | + | |
393 | 396 | | |
394 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
395 | 404 | | |
396 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
397 | 410 | | |
398 | 411 | | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
405 | 418 | | |
406 | 419 | | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
412 | 427 | | |
413 | 428 | | |
414 | 429 | | |
415 | 430 | | |
416 | | - | |
| 431 | + | |
| 432 | + | |
417 | 433 | | |
418 | 434 | | |
419 | 435 | | |
420 | 436 | | |
421 | 437 | | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | 438 | | |
447 | | - | |
448 | 439 | | |
449 | 440 | | |
450 | 441 | | |
| |||
481 | 472 | | |
482 | 473 | | |
483 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
484 | 478 | | |
485 | 479 | | |
| 480 | + | |
| 481 | + | |
486 | 482 | | |
487 | 483 | | |
488 | 484 | | |
| |||
544 | 540 | | |
545 | 541 | | |
546 | 542 | | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | 543 | | |
569 | 544 | | |
570 | 545 | | |
| |||
589 | 564 | | |
590 | 565 | | |
591 | 566 | | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | 567 | | |
609 | 568 | | |
610 | 569 | | |
| |||
686 | 645 | | |
687 | 646 | | |
688 | 647 | | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | 648 | | |
693 | 649 | | |
694 | 650 | | |
| |||
1010 | 966 | | |
1011 | 967 | | |
1012 | 968 | | |
1013 | | - | |
1014 | | - | |
1015 | 969 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | 187 | | |
200 | 188 | | |
201 | 189 | | |
| |||
969 | 957 | | |
970 | 958 | | |
971 | 959 | | |
| 960 | + | |
972 | 961 | | |
973 | 962 | | |
974 | | - | |
| 963 | + | |
| 964 | + | |
975 | 965 | | |
976 | 966 | | |
977 | 967 | | |
| |||
1082 | 1072 | | |
1083 | 1073 | | |
1084 | 1074 | | |
| 1075 | + | |
1085 | 1076 | | |
1086 | 1077 | | |
1087 | | - | |
| 1078 | + | |
| 1079 | + | |
1088 | 1080 | | |
1089 | 1081 | | |
1090 | 1082 | | |
| |||
0 commit comments