diff options
author | John Stultz <john.stultz@linaro.org> | 2011-11-14 17:05:44 -0500 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2012-01-26 22:44:27 -0500 |
commit | 92c1d3ed4dc0b8cfb10e85ed0c9934db41efc027 (patch) | |
tree | 233556d74e7bd062d8e174bc0a33fdc2dc7f95b1 /kernel/time | |
parent | bd3312681f69207a40431981c1bce1afdc9b7975 (diff) |
time: Remove most of xtime_lock usage in timekeeping.c
Now that ntp.c's locking is reworked, we can remove most
of the xtime_lock usage in timekeeping.c
The remaining xtime_lock presence is really for jiffies access
and the global load calculation.
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Eric Dumazet <eric.dumazet@gmail.com>
CC: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel/time')
-rw-r--r-- | kernel/time/timekeeping.c | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index cdae24655c8d..74bb5701e0b3 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -172,7 +172,6 @@ static inline s64 timekeeping_get_ns_raw(void) | |||
172 | return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift); | 172 | return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift); |
173 | } | 173 | } |
174 | 174 | ||
175 | /* must hold xtime_lock */ | ||
176 | void timekeeping_leap_insert(int leapsecond) | 175 | void timekeeping_leap_insert(int leapsecond) |
177 | { | 176 | { |
178 | unsigned long flags; | 177 | unsigned long flags; |
@@ -372,13 +371,12 @@ EXPORT_SYMBOL(do_gettimeofday); | |||
372 | int do_settimeofday(const struct timespec *tv) | 371 | int do_settimeofday(const struct timespec *tv) |
373 | { | 372 | { |
374 | struct timespec ts_delta; | 373 | struct timespec ts_delta; |
375 | unsigned long flags1,flags2; | 374 | unsigned long flags; |
376 | 375 | ||
377 | if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC) | 376 | if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC) |
378 | return -EINVAL; | 377 | return -EINVAL; |
379 | 378 | ||
380 | write_seqlock_irqsave(&xtime_lock, flags1); | 379 | write_seqlock_irqsave(&timekeeper.lock, flags); |
381 | write_seqlock_irqsave(&timekeeper.lock, flags2); | ||
382 | 380 | ||
383 | timekeeping_forward_now(); | 381 | timekeeping_forward_now(); |
384 | 382 | ||
@@ -395,8 +393,7 @@ int do_settimeofday(const struct timespec *tv) | |||
395 | update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, | 393 | update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, |
396 | timekeeper.clock, timekeeper.mult); | 394 | timekeeper.clock, timekeeper.mult); |
397 | 395 | ||
398 | write_sequnlock_irqrestore(&timekeeper.lock, flags2); | 396 | write_sequnlock_irqrestore(&timekeeper.lock, flags); |
399 | write_sequnlock_irqrestore(&xtime_lock, flags1); | ||
400 | 397 | ||
401 | /* signal hrtimers about time change */ | 398 | /* signal hrtimers about time change */ |
402 | clock_was_set(); | 399 | clock_was_set(); |
@@ -415,13 +412,12 @@ EXPORT_SYMBOL(do_settimeofday); | |||
415 | */ | 412 | */ |
416 | int timekeeping_inject_offset(struct timespec *ts) | 413 | int timekeeping_inject_offset(struct timespec *ts) |
417 | { | 414 | { |
418 | unsigned long flags1,flags2; | 415 | unsigned long flags; |
419 | 416 | ||
420 | if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC) | 417 | if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC) |
421 | return -EINVAL; | 418 | return -EINVAL; |
422 | 419 | ||
423 | write_seqlock_irqsave(&xtime_lock, flags1); | 420 | write_seqlock_irqsave(&timekeeper.lock, flags); |
424 | write_seqlock_irqsave(&timekeeper.lock, flags2); | ||
425 | 421 | ||
426 | timekeeping_forward_now(); | 422 | timekeeping_forward_now(); |
427 | 423 | ||
@@ -435,8 +431,7 @@ int timekeeping_inject_offset(struct timespec *ts) | |||
435 | update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, | 431 | update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, |
436 | timekeeper.clock, timekeeper.mult); | 432 | timekeeper.clock, timekeeper.mult); |
437 | 433 | ||
438 | write_sequnlock_irqrestore(&timekeeper.lock, flags2); | 434 | write_sequnlock_irqrestore(&timekeeper.lock, flags); |
439 | write_sequnlock_irqrestore(&xtime_lock, flags1); | ||
440 | 435 | ||
441 | /* signal hrtimers about time change */ | 436 | /* signal hrtimers about time change */ |
442 | clock_was_set(); | 437 | clock_was_set(); |
@@ -598,9 +593,7 @@ void __init timekeeping_init(void) | |||
598 | 593 | ||
599 | seqlock_init(&timekeeper.lock); | 594 | seqlock_init(&timekeeper.lock); |
600 | 595 | ||
601 | write_seqlock_irqsave(&xtime_lock, flags); | ||
602 | ntp_init(); | 596 | ntp_init(); |
603 | write_sequnlock_irqrestore(&xtime_lock, flags); | ||
604 | 597 | ||
605 | write_seqlock_irqsave(&timekeeper.lock, flags); | 598 | write_seqlock_irqsave(&timekeeper.lock, flags); |
606 | clock = clocksource_default_clock(); | 599 | clock = clocksource_default_clock(); |
@@ -661,7 +654,7 @@ static void __timekeeping_inject_sleeptime(struct timespec *delta) | |||
661 | */ | 654 | */ |
662 | void timekeeping_inject_sleeptime(struct timespec *delta) | 655 | void timekeeping_inject_sleeptime(struct timespec *delta) |
663 | { | 656 | { |
664 | unsigned long flags1,flags2; | 657 | unsigned long flags; |
665 | struct timespec ts; | 658 | struct timespec ts; |
666 | 659 | ||
667 | /* Make sure we don't set the clock twice */ | 660 | /* Make sure we don't set the clock twice */ |
@@ -669,8 +662,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta) | |||
669 | if (!(ts.tv_sec == 0 && ts.tv_nsec == 0)) | 662 | if (!(ts.tv_sec == 0 && ts.tv_nsec == 0)) |
670 | return; | 663 | return; |
671 | 664 | ||
672 | write_seqlock_irqsave(&xtime_lock, flags1); | 665 | write_seqlock_irqsave(&timekeeper.lock, flags); |
673 | write_seqlock_irqsave(&timekeeper.lock, flags2); | ||
674 | 666 | ||
675 | timekeeping_forward_now(); | 667 | timekeeping_forward_now(); |
676 | 668 | ||
@@ -681,8 +673,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta) | |||
681 | update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, | 673 | update_vsyscall(&timekeeper.xtime, &timekeeper.wall_to_monotonic, |
682 | timekeeper.clock, timekeeper.mult); | 674 | timekeeper.clock, timekeeper.mult); |
683 | 675 | ||
684 | write_sequnlock_irqrestore(&timekeeper.lock, flags2); | 676 | write_sequnlock_irqrestore(&timekeeper.lock, flags); |
685 | write_sequnlock_irqrestore(&xtime_lock, flags1); | ||
686 | 677 | ||
687 | /* signal hrtimers about time change */ | 678 | /* signal hrtimers about time change */ |
688 | clock_was_set(); | 679 | clock_was_set(); |
@@ -698,15 +689,14 @@ void timekeeping_inject_sleeptime(struct timespec *delta) | |||
698 | */ | 689 | */ |
699 | static void timekeeping_resume(void) | 690 | static void timekeeping_resume(void) |
700 | { | 691 | { |
701 | unsigned long flags1,flags2; | 692 | unsigned long flags; |
702 | struct timespec ts; | 693 | struct timespec ts; |
703 | 694 | ||
704 | read_persistent_clock(&ts); | 695 | read_persistent_clock(&ts); |
705 | 696 | ||
706 | clocksource_resume(); | 697 | clocksource_resume(); |
707 | 698 | ||
708 | write_seqlock_irqsave(&xtime_lock, flags1); | 699 | write_seqlock_irqsave(&timekeeper.lock, flags); |
709 | write_seqlock_irqsave(&timekeeper.lock, flags2); | ||
710 | 700 | ||
711 | if (timespec_compare(&ts, &timekeeping_suspend_time) > 0) { | 701 | if (timespec_compare(&ts, &timekeeping_suspend_time) > 0) { |
712 | ts = timespec_sub(ts, timekeeping_suspend_time); | 702 | ts = timespec_sub(ts, timekeeping_suspend_time); |
@@ -716,8 +706,7 @@ static void timekeeping_resume(void) | |||
716 | timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock); | 706 | timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock); |
717 | timekeeper.ntp_error = 0; | 707 | timekeeper.ntp_error = 0; |
718 | timekeeping_suspended = 0; | 708 | timekeeping_suspended = 0; |
719 | write_sequnlock_irqrestore(&timekeeper.lock, flags2); | 709 | write_sequnlock_irqrestore(&timekeeper.lock, flags); |
720 | write_sequnlock_irqrestore(&xtime_lock, flags1); | ||
721 | 710 | ||
722 | touch_softlockup_watchdog(); | 711 | touch_softlockup_watchdog(); |
723 | 712 | ||
@@ -729,14 +718,13 @@ static void timekeeping_resume(void) | |||
729 | 718 | ||
730 | static int timekeeping_suspend(void) | 719 | static int timekeeping_suspend(void) |
731 | { | 720 | { |
732 | unsigned long flags1,flags2; | 721 | unsigned long flags; |
733 | struct timespec delta, delta_delta; | 722 | struct timespec delta, delta_delta; |
734 | static struct timespec old_delta; | 723 | static struct timespec old_delta; |
735 | 724 | ||
736 | read_persistent_clock(&timekeeping_suspend_time); | 725 | read_persistent_clock(&timekeeping_suspend_time); |
737 | 726 | ||
738 | write_seqlock_irqsave(&xtime_lock, flags1); | 727 | write_seqlock_irqsave(&timekeeper.lock, flags); |
739 | write_seqlock_irqsave(&timekeeper.lock, flags2); | ||
740 | timekeeping_forward_now(); | 728 | timekeeping_forward_now(); |
741 | timekeeping_suspended = 1; | 729 | timekeeping_suspended = 1; |
742 | 730 | ||
@@ -759,8 +747,7 @@ static int timekeeping_suspend(void) | |||
759 | timekeeping_suspend_time = | 747 | timekeeping_suspend_time = |
760 | timespec_add(timekeeping_suspend_time, delta_delta); | 748 | timespec_add(timekeeping_suspend_time, delta_delta); |
761 | } | 749 | } |
762 | write_sequnlock_irqrestore(&timekeeper.lock, flags2); | 750 | write_sequnlock_irqrestore(&timekeeper.lock, flags); |
763 | write_sequnlock_irqrestore(&xtime_lock, flags1); | ||
764 | 751 | ||
765 | clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL); | 752 | clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL); |
766 | clocksource_suspend(); | 753 | clocksource_suspend(); |
@@ -1006,7 +993,6 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift) | |||
1006 | /** | 993 | /** |
1007 | * update_wall_time - Uses the current clocksource to increment the wall time | 994 | * update_wall_time - Uses the current clocksource to increment the wall time |
1008 | * | 995 | * |
1009 | * Called from the timer interrupt, must hold a write on xtime_lock. | ||
1010 | */ | 996 | */ |
1011 | static void update_wall_time(void) | 997 | static void update_wall_time(void) |
1012 | { | 998 | { |