diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2013-02-21 17:51:38 -0500 |
|---|---|---|
| committer | John Stultz <john.stultz@linaro.org> | 2013-03-22 19:20:01 -0400 |
| commit | 9a7a71b1d0968fc2bd602b7481cde1d4872e01ff (patch) | |
| tree | 18954e171dcf260a7750ad6be2f70bac7ef63a78 /kernel/time | |
| parent | 7e40672d930b369c1984457233ec5557aa53bfb8 (diff) | |
timekeeping: Split timekeeper_lock into lock and seqcount
We want to shorten the seqcount write hold time. So split the seqlock
into a lock and a seqcount.
Open code the seqwrite_lock in the places which matter and drop the
sequence counter update where it's pointless.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[jstultz: Merge fixups from CLOCK_TAI collisions]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel/time')
| -rw-r--r-- | kernel/time/timekeeping.c | 132 |
1 files changed, 73 insertions, 59 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index caede71c0a35..5e048e030c62 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
| @@ -26,7 +26,8 @@ | |||
| 26 | #include "tick-internal.h" | 26 | #include "tick-internal.h" |
| 27 | 27 | ||
| 28 | static struct timekeeper timekeeper; | 28 | static struct timekeeper timekeeper; |
| 29 | static DEFINE_SEQLOCK(timekeeper_lock); | 29 | static DEFINE_RAW_SPINLOCK(timekeeper_lock); |
| 30 | static seqcount_t timekeeper_seq; | ||
| 30 | 31 | ||
| 31 | /* flag for if timekeeping is suspended */ | 32 | /* flag for if timekeeping is suspended */ |
| 32 | int __read_mostly timekeeping_suspended; | 33 | int __read_mostly timekeeping_suspended; |
| @@ -204,8 +205,6 @@ static void update_pvclock_gtod(struct timekeeper *tk) | |||
| 204 | 205 | ||
| 205 | /** | 206 | /** |
| 206 | * pvclock_gtod_register_notifier - register a pvclock timedata update listener | 207 | * pvclock_gtod_register_notifier - register a pvclock timedata update listener |
| 207 | * | ||
| 208 | * Must hold write on timekeeper.lock | ||
| 209 | */ | 208 | */ |
| 210 | int pvclock_gtod_register_notifier(struct notifier_block *nb) | 209 | int pvclock_gtod_register_notifier(struct notifier_block *nb) |
| 211 | { | 210 | { |
| @@ -213,11 +212,10 @@ int pvclock_gtod_register_notifier(struct notifier_block *nb) | |||
| 213 | unsigned long flags; | 212 | unsigned long flags; |
| 214 | int ret; | 213 | int ret; |
| 215 | 214 | ||
| 216 | write_seqlock_irqsave(&timekeeper_lock, flags); | 215 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 217 | ret = raw_notifier_chain_register(&pvclock_gtod_chain, nb); | 216 | ret = raw_notifier_chain_register(&pvclock_gtod_chain, nb); |
| 218 | /* update timekeeping data */ | ||
| 219 | update_pvclock_gtod(tk); | 217 | update_pvclock_gtod(tk); |
| 220 | write_sequnlock_irqrestore(&timekeeper_lock, flags); | 218 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
| 221 | 219 | ||
| 222 | return ret; | 220 | return ret; |
| 223 | } | 221 | } |
| @@ -226,23 +224,21 @@ EXPORT_SYMBOL_GPL(pvclock_gtod_register_notifier); | |||
| 226 | /** | 224 | /** |
| 227 | * pvclock_gtod_unregister_notifier - unregister a pvclock | 225 | * pvclock_gtod_unregister_notifier - unregister a pvclock |
| 228 | * timedata update listener | 226 | * timedata update listener |
| 229 | * | ||
| 230 | * Must hold write on timekeeper.lock | ||
| 231 | */ | 227 | */ |
| 232 | int pvclock_gtod_unregister_notifier(struct notifier_block *nb) | 228 | int pvclock_gtod_unregister_notifier(struct notifier_block *nb) |
| 233 | { | 229 | { |
| 234 | unsigned long flags; | 230 | unsigned long flags; |
| 235 | int ret; | 231 | int ret; |
| 236 | 232 | ||
| 237 | write_seqlock_irqsave(&timekeeper_lock, flags); | 233 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 238 | ret = raw_notifier_chain_unregister(&pvclock_gtod_chain, nb); | 234 | ret = raw_notifier_chain_unregister(&pvclock_gtod_chain, nb); |
| 239 | write_sequnlock_irqrestore(&timekeeper_lock, flags); | 235 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
| 240 | 236 | ||
| 241 | return ret; | 237 | return ret; |
| 242 | } | 238 | } |
| 243 | EXPORT_SYMBOL_GPL(pvclock_gtod_unregister_notifier); | 239 | EXPORT_SYMBOL_GPL(pvclock_gtod_unregister_notifier); |
| 244 | 240 | ||
| 245 | /* must hold write on timekeeper.lock */ | 241 | /* must hold timekeeper_lock */ |
| 246 | static void timekeeping_update(struct timekeeper *tk, bool clearntp) | 242 | static void timekeeping_update(struct timekeeper *tk, bool clearntp) |
| 247 | { | 243 | { |
| 248 | if (clearntp) { | 244 | if (clearntp) { |
| @@ -296,12 +292,12 @@ int __getnstimeofday(struct timespec *ts) | |||
| 296 | s64 nsecs = 0; | 292 | s64 nsecs = 0; |
| 297 | 293 | ||
| 298 | do { | 294 | do { |
| 299 | seq = read_seqbegin(&timekeeper_lock); | 295 | seq = read_seqcount_begin(&timekeeper_seq); |
| 300 | 296 | ||
| 301 | ts->tv_sec = tk->xtime_sec; | 297 | ts->tv_sec = tk->xtime_sec; |
| 302 | nsecs = timekeeping_get_ns(tk); | 298 | nsecs = timekeeping_get_ns(tk); |
| 303 | 299 | ||
| 304 | } while (read_seqretry(&timekeeper_lock, seq)); | 300 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 305 | 301 | ||
| 306 | ts->tv_nsec = 0; | 302 | ts->tv_nsec = 0; |
| 307 | timespec_add_ns(ts, nsecs); | 303 | timespec_add_ns(ts, nsecs); |
| @@ -337,11 +333,11 @@ ktime_t ktime_get(void) | |||
| 337 | WARN_ON(timekeeping_suspended); | 333 | WARN_ON(timekeeping_suspended); |
| 338 | 334 | ||
| 339 | do { | 335 | do { |
| 340 | seq = read_seqbegin(&timekeeper_lock); | 336 | seq = read_seqcount_begin(&timekeeper_seq); |
| 341 | secs = tk->xtime_sec + tk->wall_to_monotonic.tv_sec; | 337 | secs = tk->xtime_sec + tk->wall_to_monotonic.tv_sec; |
| 342 | nsecs = timekeeping_get_ns(tk) + tk->wall_to_monotonic.tv_nsec; | 338 | nsecs = timekeeping_get_ns(tk) + tk->wall_to_monotonic.tv_nsec; |
| 343 | 339 | ||
| 344 | } while (read_seqretry(&timekeeper_lock, seq)); | 340 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 345 | /* | 341 | /* |
| 346 | * Use ktime_set/ktime_add_ns to create a proper ktime on | 342 | * Use ktime_set/ktime_add_ns to create a proper ktime on |
| 347 | * 32-bit architectures without CONFIG_KTIME_SCALAR. | 343 | * 32-bit architectures without CONFIG_KTIME_SCALAR. |
| @@ -368,12 +364,12 @@ void ktime_get_ts(struct timespec *ts) | |||
| 368 | WARN_ON(timekeeping_suspended); | 364 | WARN_ON(timekeeping_suspended); |
| 369 | 365 | ||
| 370 | do { | 366 | do { |
| 371 | seq = read_seqbegin(&timekeeper_lock); | 367 | seq = read_seqcount_begin(&timekeeper_seq); |
| 372 | ts->tv_sec = tk->xtime_sec; | 368 | ts->tv_sec = tk->xtime_sec; |
| 373 | nsec = timekeeping_get_ns(tk); | 369 | nsec = timekeeping_get_ns(tk); |
| 374 | tomono = tk->wall_to_monotonic; | 370 | tomono = tk->wall_to_monotonic; |
| 375 | 371 | ||
| 376 | } while (read_seqretry(&timekeeper_lock, seq)); | 372 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 377 | 373 | ||
| 378 | ts->tv_sec += tomono.tv_sec; | 374 | ts->tv_sec += tomono.tv_sec; |
| 379 | ts->tv_nsec = 0; | 375 | ts->tv_nsec = 0; |
| @@ -397,12 +393,12 @@ void timekeeping_clocktai(struct timespec *ts) | |||
| 397 | WARN_ON(timekeeping_suspended); | 393 | WARN_ON(timekeeping_suspended); |
| 398 | 394 | ||
| 399 | do { | 395 | do { |
| 400 | seq = read_seqbegin(&timekeeper_lock); | 396 | seq = read_seqcount_begin(&timekeeper_seq); |
| 401 | 397 | ||
| 402 | ts->tv_sec = tk->xtime_sec + tk->tai_offset; | 398 | ts->tv_sec = tk->xtime_sec + tk->tai_offset; |
| 403 | nsecs = timekeeping_get_ns(tk); | 399 | nsecs = timekeeping_get_ns(tk); |
| 404 | 400 | ||
| 405 | } while (read_seqretry(&timekeeper_lock, seq)); | 401 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 406 | 402 | ||
| 407 | ts->tv_nsec = 0; | 403 | ts->tv_nsec = 0; |
| 408 | timespec_add_ns(ts, nsecs); | 404 | timespec_add_ns(ts, nsecs); |
| @@ -445,7 +441,7 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real) | |||
| 445 | WARN_ON_ONCE(timekeeping_suspended); | 441 | WARN_ON_ONCE(timekeeping_suspended); |
| 446 | 442 | ||
| 447 | do { | 443 | do { |
| 448 | seq = read_seqbegin(&timekeeper_lock); | 444 | seq = read_seqcount_begin(&timekeeper_seq); |
| 449 | 445 | ||
| 450 | *ts_raw = tk->raw_time; | 446 | *ts_raw = tk->raw_time; |
| 451 | ts_real->tv_sec = tk->xtime_sec; | 447 | ts_real->tv_sec = tk->xtime_sec; |
| @@ -454,7 +450,7 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real) | |||
| 454 | nsecs_raw = timekeeping_get_ns_raw(tk); | 450 | nsecs_raw = timekeeping_get_ns_raw(tk); |
| 455 | nsecs_real = timekeeping_get_ns(tk); | 451 | nsecs_real = timekeeping_get_ns(tk); |
| 456 | 452 | ||
| 457 | } while (read_seqretry(&timekeeper_lock, seq)); | 453 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 458 | 454 | ||
| 459 | timespec_add_ns(ts_raw, nsecs_raw); | 455 | timespec_add_ns(ts_raw, nsecs_raw); |
| 460 | timespec_add_ns(ts_real, nsecs_real); | 456 | timespec_add_ns(ts_real, nsecs_real); |
| @@ -494,7 +490,8 @@ int do_settimeofday(const struct timespec *tv) | |||
| 494 | if (!timespec_valid_strict(tv)) | 490 | if (!timespec_valid_strict(tv)) |
| 495 | return -EINVAL; | 491 | return -EINVAL; |
| 496 | 492 | ||
| 497 | write_seqlock_irqsave(&timekeeper_lock, flags); | 493 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 494 | write_seqcount_begin(&timekeeper_seq); | ||
| 498 | 495 | ||
| 499 | timekeeping_forward_now(tk); | 496 | timekeeping_forward_now(tk); |
| 500 | 497 | ||
| @@ -508,7 +505,8 @@ int do_settimeofday(const struct timespec *tv) | |||
| 508 | 505 | ||
| 509 | timekeeping_update(tk, true); | 506 | timekeeping_update(tk, true); |
| 510 | 507 | ||
| 511 | write_sequnlock_irqrestore(&timekeeper_lock, flags); | 508 | write_seqcount_end(&timekeeper_seq); |
| 509 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | ||
| 512 | 510 | ||
| 513 | /* signal hrtimers about time change */ | 511 | /* signal hrtimers about time change */ |
| 514 | clock_was_set(); | 512 | clock_was_set(); |
| @@ -533,7 +531,8 @@ int timekeeping_inject_offset(struct timespec *ts) | |||
| 533 | if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC) | 531 | if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC) |
| 534 | return -EINVAL; | 532 | return -EINVAL; |
| 535 | 533 | ||
| 536 | write_seqlock_irqsave(&timekeeper_lock, flags); | 534 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 535 | write_seqcount_begin(&timekeeper_seq); | ||
| 537 | 536 | ||
| 538 | timekeeping_forward_now(tk); | 537 | timekeeping_forward_now(tk); |
| 539 | 538 | ||
| @@ -550,7 +549,8 @@ int timekeeping_inject_offset(struct timespec *ts) | |||
| 550 | error: /* even if we error out, we forwarded the time, so call update */ | 549 | error: /* even if we error out, we forwarded the time, so call update */ |
| 551 | timekeeping_update(tk, true); | 550 | timekeeping_update(tk, true); |
| 552 | 551 | ||
| 553 | write_sequnlock_irqrestore(&timekeeper_lock, flags); | 552 | write_seqcount_end(&timekeeper_seq); |
| 553 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | ||
| 554 | 554 | ||
| 555 | /* signal hrtimers about time change */ | 555 | /* signal hrtimers about time change */ |
| 556 | clock_was_set(); | 556 | clock_was_set(); |
| @@ -571,9 +571,9 @@ s32 timekeeping_get_tai_offset(void) | |||
| 571 | s32 ret; | 571 | s32 ret; |
| 572 | 572 | ||
| 573 | do { | 573 | do { |
| 574 | seq = read_seqbegin(&timekeeper_lock); | 574 | seq = read_seqcount_begin(&timekeeper_seq); |
| 575 | ret = tk->tai_offset; | 575 | ret = tk->tai_offset; |
| 576 | } while (read_seqretry(&timekeeper_lock, seq)); | 576 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 577 | 577 | ||
| 578 | return ret; | 578 | return ret; |
| 579 | } | 579 | } |
| @@ -597,9 +597,11 @@ void timekeeping_set_tai_offset(s32 tai_offset) | |||
| 597 | struct timekeeper *tk = &timekeeper; | 597 | struct timekeeper *tk = &timekeeper; |
| 598 | unsigned long flags; | 598 | unsigned long flags; |
| 599 | 599 | ||
| 600 | write_seqlock_irqsave(&timekeeper_lock, flags); | 600 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 601 | write_seqcount_begin(&timekeeper_seq); | ||
| 601 | __timekeeping_set_tai_offset(tk, tai_offset); | 602 | __timekeeping_set_tai_offset(tk, tai_offset); |
| 602 | write_sequnlock_irqrestore(&timekeeper_lock, flags); | 603 | write_seqcount_end(&timekeeper_seq); |
| 604 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | ||
| 603 | } | 605 | } |
| 604 | 606 | ||
| 605 | /** | 607 | /** |
| @@ -615,7 +617,8 @@ static int change_clocksource(void *data) | |||
| 615 | 617 | ||
| 616 | new = (struct clocksource *) data; | 618 | new = (struct clocksource *) data; |
| 617 | 619 | ||
| 618 | write_seqlock_irqsave(&timekeeper_lock, flags); | 620 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 621 | write_seqcount_begin(&timekeeper_seq); | ||
| 619 | 622 | ||
| 620 | timekeeping_forward_now(tk); | 623 | timekeeping_forward_now(tk); |
| 621 | if (!new->enable || new->enable(new) == 0) { | 624 | if (!new->enable || new->enable(new) == 0) { |
| @@ -626,7 +629,8 @@ static int change_clocksource(void *data) | |||
| 626 | } | 629 | } |
| 627 | timekeeping_update(tk, true); | 630 | timekeeping_update(tk, true); |
| 628 | 631 | ||
| 629 | write_sequnlock_irqrestore(&timekeeper_lock, flags); | 632 | write_seqcount_end(&timekeeper_seq); |
| 633 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | ||
| 630 | 634 | ||
| 631 | return 0; | 635 | return 0; |
| 632 | } | 636 | } |
| @@ -676,11 +680,11 @@ void getrawmonotonic(struct timespec *ts) | |||
| 676 | s64 nsecs; | 680 | s64 nsecs; |
| 677 | 681 | ||
| 678 | do { | 682 | do { |
| 679 | seq = read_seqbegin(&timekeeper_lock); | 683 | seq = read_seqcount_begin(&timekeeper_seq); |
| 680 | nsecs = timekeeping_get_ns_raw(tk); | 684 | nsecs = timekeeping_get_ns_raw(tk); |
| 681 | *ts = tk->raw_time; | 685 | *ts = tk->raw_time; |
| 682 | 686 | ||
| 683 | } while (read_seqretry(&timekeeper_lock, seq)); | 687 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 684 | 688 | ||
| 685 | timespec_add_ns(ts, nsecs); | 689 | timespec_add_ns(ts, nsecs); |
| 686 | } | 690 | } |
| @@ -696,11 +700,11 @@ int timekeeping_valid_for_hres(void) | |||
| 696 | int ret; | 700 | int ret; |
| 697 | 701 | ||
| 698 | do { | 702 | do { |
| 699 | seq = read_seqbegin(&timekeeper_lock); | 703 | seq = read_seqcount_begin(&timekeeper_seq); |
| 700 | 704 | ||
| 701 | ret = tk->clock->flags & CLOCK_SOURCE_VALID_FOR_HRES; | 705 | ret = tk->clock->flags & CLOCK_SOURCE_VALID_FOR_HRES; |
| 702 | 706 | ||
| 703 | } while (read_seqretry(&timekeeper_lock, seq)); | 707 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 704 | 708 | ||
| 705 | return ret; | 709 | return ret; |
| 706 | } | 710 | } |
| @@ -715,11 +719,11 @@ u64 timekeeping_max_deferment(void) | |||
| 715 | u64 ret; | 719 | u64 ret; |
| 716 | 720 | ||
| 717 | do { | 721 | do { |
| 718 | seq = read_seqbegin(&timekeeper_lock); | 722 | seq = read_seqcount_begin(&timekeeper_seq); |
| 719 | 723 | ||
| 720 | ret = tk->clock->max_idle_ns; | 724 | ret = tk->clock->max_idle_ns; |
| 721 | 725 | ||
| 722 | } while (read_seqretry(&timekeeper_lock, seq)); | 726 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 723 | 727 | ||
| 724 | return ret; | 728 | return ret; |
| 725 | } | 729 | } |
| @@ -784,7 +788,8 @@ void __init timekeeping_init(void) | |||
| 784 | 788 | ||
| 785 | ntp_init(); | 789 | ntp_init(); |
| 786 | 790 | ||
| 787 | write_seqlock_irqsave(&timekeeper_lock, flags); | 791 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 792 | write_seqcount_begin(&timekeeper_seq); | ||
| 788 | clock = clocksource_default_clock(); | 793 | clock = clocksource_default_clock(); |
| 789 | if (clock->enable) | 794 | if (clock->enable) |
| 790 | clock->enable(clock); | 795 | clock->enable(clock); |
| @@ -803,7 +808,8 @@ void __init timekeeping_init(void) | |||
| 803 | tmp.tv_nsec = 0; | 808 | tmp.tv_nsec = 0; |
| 804 | tk_set_sleep_time(tk, tmp); | 809 | tk_set_sleep_time(tk, tmp); |
| 805 | 810 | ||
| 806 | write_sequnlock_irqrestore(&timekeeper_lock, flags); | 811 | write_seqcount_end(&timekeeper_seq); |
| 812 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | ||
| 807 | } | 813 | } |
| 808 | 814 | ||
| 809 | /* time in seconds when suspend began */ | 815 | /* time in seconds when suspend began */ |
| @@ -851,7 +857,8 @@ void timekeeping_inject_sleeptime(struct timespec *delta) | |||
| 851 | if (has_persistent_clock()) | 857 | if (has_persistent_clock()) |
| 852 | return; | 858 | return; |
| 853 | 859 | ||
| 854 | write_seqlock_irqsave(&timekeeper_lock, flags); | 860 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 861 | write_seqcount_begin(&timekeeper_seq); | ||
| 855 | 862 | ||
| 856 | timekeeping_forward_now(tk); | 863 | timekeeping_forward_now(tk); |
| 857 | 864 | ||
| @@ -859,7 +866,8 @@ void timekeeping_inject_sleeptime(struct timespec *delta) | |||
| 859 | 866 | ||
| 860 | timekeeping_update(tk, true); | 867 | timekeeping_update(tk, true); |
| 861 | 868 | ||
| 862 | write_sequnlock_irqrestore(&timekeeper_lock, flags); | 869 | write_seqcount_end(&timekeeper_seq); |
| 870 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | ||
| 863 | 871 | ||
| 864 | /* signal hrtimers about time change */ | 872 | /* signal hrtimers about time change */ |
| 865 | clock_was_set(); | 873 | clock_was_set(); |
| @@ -886,7 +894,8 @@ static void timekeeping_resume(void) | |||
| 886 | clockevents_resume(); | 894 | clockevents_resume(); |
| 887 | clocksource_resume(); | 895 | clocksource_resume(); |
| 888 | 896 | ||
| 889 | write_seqlock_irqsave(&timekeeper_lock, flags); | 897 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 898 | write_seqcount_begin(&timekeeper_seq); | ||
| 890 | 899 | ||
| 891 | /* | 900 | /* |
| 892 | * After system resumes, we need to calculate the suspended time and | 901 | * After system resumes, we need to calculate the suspended time and |
| @@ -938,7 +947,8 @@ static void timekeeping_resume(void) | |||
| 938 | tk->ntp_error = 0; | 947 | tk->ntp_error = 0; |
| 939 | timekeeping_suspended = 0; | 948 | timekeeping_suspended = 0; |
| 940 | timekeeping_update(tk, false); | 949 | timekeeping_update(tk, false); |
| 941 | write_sequnlock_irqrestore(&timekeeper_lock, flags); | 950 | write_seqcount_end(&timekeeper_seq); |
| 951 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | ||
| 942 | 952 | ||
| 943 | touch_softlockup_watchdog(); | 953 | touch_softlockup_watchdog(); |
| 944 | 954 | ||
| @@ -957,7 +967,8 @@ static int timekeeping_suspend(void) | |||
| 957 | 967 | ||
| 958 | read_persistent_clock(&timekeeping_suspend_time); | 968 | read_persistent_clock(&timekeeping_suspend_time); |
| 959 | 969 | ||
| 960 | write_seqlock_irqsave(&timekeeper_lock, flags); | 970 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 971 | write_seqcount_begin(&timekeeper_seq); | ||
| 961 | timekeeping_forward_now(tk); | 972 | timekeeping_forward_now(tk); |
| 962 | timekeeping_suspended = 1; | 973 | timekeeping_suspended = 1; |
| 963 | 974 | ||
| @@ -980,7 +991,8 @@ static int timekeeping_suspend(void) | |||
| 980 | timekeeping_suspend_time = | 991 | timekeeping_suspend_time = |
| 981 | timespec_add(timekeeping_suspend_time, delta_delta); | 992 | timespec_add(timekeeping_suspend_time, delta_delta); |
| 982 | } | 993 | } |
| 983 | write_sequnlock_irqrestore(&timekeeper_lock, flags); | 994 | write_seqcount_end(&timekeeper_seq); |
| 995 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | ||
| 984 | 996 | ||
| 985 | clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL); | 997 | clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL); |
| 986 | clocksource_suspend(); | 998 | clocksource_suspend(); |
| @@ -1320,7 +1332,8 @@ static void update_wall_time(void) | |||
| 1320 | int shift = 0, maxshift; | 1332 | int shift = 0, maxshift; |
| 1321 | unsigned long flags; | 1333 | unsigned long flags; |
| 1322 | 1334 | ||
| 1323 | write_seqlock_irqsave(&timekeeper_lock, flags); | 1335 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
| 1336 | write_seqcount_begin(&timekeeper_seq); | ||
| 1324 | 1337 | ||
| 1325 | /* Make sure we're fully resumed: */ | 1338 | /* Make sure we're fully resumed: */ |
| 1326 | if (unlikely(timekeeping_suspended)) | 1339 | if (unlikely(timekeeping_suspended)) |
| @@ -1375,7 +1388,8 @@ static void update_wall_time(void) | |||
| 1375 | timekeeping_update(tk, false); | 1388 | timekeeping_update(tk, false); |
| 1376 | 1389 | ||
| 1377 | out: | 1390 | out: |
| 1378 | write_sequnlock_irqrestore(&timekeeper_lock, flags); | 1391 | write_seqcount_end(&timekeeper_seq); |
| 1392 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | ||
| 1379 | 1393 | ||
| 1380 | } | 1394 | } |
| 1381 | 1395 | ||
| @@ -1423,13 +1437,13 @@ void get_monotonic_boottime(struct timespec *ts) | |||
| 1423 | WARN_ON(timekeeping_suspended); | 1437 | WARN_ON(timekeeping_suspended); |
| 1424 | 1438 | ||
| 1425 | do { | 1439 | do { |
| 1426 | seq = read_seqbegin(&timekeeper_lock); | 1440 | seq = read_seqcount_begin(&timekeeper_seq); |
| 1427 | ts->tv_sec = tk->xtime_sec; | 1441 | ts->tv_sec = tk->xtime_sec; |
| 1428 | nsec = timekeeping_get_ns(tk); | 1442 | nsec = timekeeping_get_ns(tk); |
| 1429 | tomono = tk->wall_to_monotonic; | 1443 | tomono = tk->wall_to_monotonic; |
| 1430 | sleep = tk->total_sleep_time; | 1444 | sleep = tk->total_sleep_time; |
| 1431 | 1445 | ||
| 1432 | } while (read_seqretry(&timekeeper_lock, seq)); | 1446 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 1433 | 1447 | ||
| 1434 | ts->tv_sec += tomono.tv_sec + sleep.tv_sec; | 1448 | ts->tv_sec += tomono.tv_sec + sleep.tv_sec; |
| 1435 | ts->tv_nsec = 0; | 1449 | ts->tv_nsec = 0; |
| @@ -1488,10 +1502,10 @@ struct timespec current_kernel_time(void) | |||
| 1488 | unsigned long seq; | 1502 | unsigned long seq; |
| 1489 | 1503 | ||
| 1490 | do { | 1504 | do { |
| 1491 | seq = read_seqbegin(&timekeeper_lock); | 1505 | seq = read_seqcount_begin(&timekeeper_seq); |
| 1492 | 1506 | ||
| 1493 | now = tk_xtime(tk); | 1507 | now = tk_xtime(tk); |
| 1494 | } while (read_seqretry(&timekeeper_lock, seq)); | 1508 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 1495 | 1509 | ||
| 1496 | return now; | 1510 | return now; |
| 1497 | } | 1511 | } |
| @@ -1504,11 +1518,11 @@ struct timespec get_monotonic_coarse(void) | |||
| 1504 | unsigned long seq; | 1518 | unsigned long seq; |
| 1505 | 1519 | ||
| 1506 | do { | 1520 | do { |
| 1507 | seq = read_seqbegin(&timekeeper_lock); | 1521 | seq = read_seqcount_begin(&timekeeper_seq); |
| 1508 | 1522 | ||
| 1509 | now = tk_xtime(tk); | 1523 | now = tk_xtime(tk); |
| 1510 | mono = tk->wall_to_monotonic; | 1524 | mono = tk->wall_to_monotonic; |
| 1511 | } while (read_seqretry(&timekeeper_lock, seq)); | 1525 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 1512 | 1526 | ||
| 1513 | set_normalized_timespec(&now, now.tv_sec + mono.tv_sec, | 1527 | set_normalized_timespec(&now, now.tv_sec + mono.tv_sec, |
| 1514 | now.tv_nsec + mono.tv_nsec); | 1528 | now.tv_nsec + mono.tv_nsec); |
| @@ -1539,11 +1553,11 @@ void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim, | |||
| 1539 | unsigned long seq; | 1553 | unsigned long seq; |
| 1540 | 1554 | ||
| 1541 | do { | 1555 | do { |
| 1542 | seq = read_seqbegin(&timekeeper_lock); | 1556 | seq = read_seqcount_begin(&timekeeper_seq); |
| 1543 | *xtim = tk_xtime(tk); | 1557 | *xtim = tk_xtime(tk); |
| 1544 | *wtom = tk->wall_to_monotonic; | 1558 | *wtom = tk->wall_to_monotonic; |
| 1545 | *sleep = tk->total_sleep_time; | 1559 | *sleep = tk->total_sleep_time; |
| 1546 | } while (read_seqretry(&timekeeper_lock, seq)); | 1560 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 1547 | } | 1561 | } |
| 1548 | 1562 | ||
| 1549 | #ifdef CONFIG_HIGH_RES_TIMERS | 1563 | #ifdef CONFIG_HIGH_RES_TIMERS |
| @@ -1564,7 +1578,7 @@ ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot, | |||
| 1564 | u64 secs, nsecs; | 1578 | u64 secs, nsecs; |
| 1565 | 1579 | ||
| 1566 | do { | 1580 | do { |
| 1567 | seq = read_seqbegin(&timekeeper_lock); | 1581 | seq = read_seqcount_begin(&timekeeper_seq); |
| 1568 | 1582 | ||
| 1569 | secs = tk->xtime_sec; | 1583 | secs = tk->xtime_sec; |
| 1570 | nsecs = timekeeping_get_ns(tk); | 1584 | nsecs = timekeeping_get_ns(tk); |
| @@ -1572,7 +1586,7 @@ ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot, | |||
| 1572 | *offs_real = tk->offs_real; | 1586 | *offs_real = tk->offs_real; |
| 1573 | *offs_boot = tk->offs_boot; | 1587 | *offs_boot = tk->offs_boot; |
| 1574 | *offs_tai = tk->offs_tai; | 1588 | *offs_tai = tk->offs_tai; |
| 1575 | } while (read_seqretry(&timekeeper_lock, seq)); | 1589 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 1576 | 1590 | ||
| 1577 | now = ktime_add_ns(ktime_set(secs, 0), nsecs); | 1591 | now = ktime_add_ns(ktime_set(secs, 0), nsecs); |
| 1578 | now = ktime_sub(now, *offs_real); | 1592 | now = ktime_sub(now, *offs_real); |
| @@ -1590,9 +1604,9 @@ ktime_t ktime_get_monotonic_offset(void) | |||
| 1590 | struct timespec wtom; | 1604 | struct timespec wtom; |
| 1591 | 1605 | ||
| 1592 | do { | 1606 | do { |
| 1593 | seq = read_seqbegin(&timekeeper_lock); | 1607 | seq = read_seqcount_begin(&timekeeper_seq); |
| 1594 | wtom = tk->wall_to_monotonic; | 1608 | wtom = tk->wall_to_monotonic; |
| 1595 | } while (read_seqretry(&timekeeper_lock, seq)); | 1609 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
| 1596 | 1610 | ||
| 1597 | return timespec_to_ktime(wtom); | 1611 | return timespec_to_ktime(wtom); |
| 1598 | } | 1612 | } |
