diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2014-07-16 17:04:07 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2014-07-23 13:17:56 -0400 |
commit | 3fdb14fd1df70325e1e91e1203a699a4803ed741 (patch) | |
tree | 9b3d581e4c666ea4dcf356da35473406bf5164e0 | |
parent | c905fae43f61c2b4508fc01722e8db61b6b8ac0b (diff) |
timekeeping: Cache optimize struct timekeeper
struct timekeeper is quite badly sorted for the hot readout path. Most
time access functions need to load two cache lines.
Rearrange it so ktime_get() and getnstimeofday() are happy with a
single cache line.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r-- | include/linux/timekeeper_internal.h | 84 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 185 |
2 files changed, 143 insertions, 126 deletions
diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h index 16de6d7c240a..2cb96235c249 100644 --- a/include/linux/timekeeper_internal.h +++ b/include/linux/timekeeper_internal.h | |||
@@ -10,7 +10,22 @@ | |||
10 | #include <linux/jiffies.h> | 10 | #include <linux/jiffies.h> |
11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
12 | 12 | ||
13 | /* Structure holding internal timekeeping values. */ | 13 | /* |
14 | * Structure holding internal timekeeping values. | ||
15 | * | ||
16 | * Note: wall_to_monotonic is what we need to add to xtime (or xtime | ||
17 | * corrected for sub jiffie times) to get to monotonic time. | ||
18 | * Monotonic is pegged at zero at system boot time, so | ||
19 | * wall_to_monotonic will be negative, however, we will ALWAYS keep | ||
20 | * the tv_nsec part positive so we can use the usual normalization. | ||
21 | * | ||
22 | * wall_to_monotonic is moved after resume from suspend for the | ||
23 | * monotonic time not to jump. We need to add total_sleep_time to | ||
24 | * wall_to_monotonic to get the real boot based time offset. | ||
25 | * | ||
26 | * - wall_to_monotonic is no longer the boot time, getboottime must be | ||
27 | * used instead. | ||
28 | */ | ||
14 | struct timekeeper { | 29 | struct timekeeper { |
15 | /* Current clocksource used for timekeeping. */ | 30 | /* Current clocksource used for timekeeping. */ |
16 | struct clocksource *clock; | 31 | struct clocksource *clock; |
@@ -18,6 +33,29 @@ struct timekeeper { | |||
18 | u32 mult; | 33 | u32 mult; |
19 | /* The shift value of the current clocksource. */ | 34 | /* The shift value of the current clocksource. */ |
20 | u32 shift; | 35 | u32 shift; |
36 | /* Clock shifted nano seconds */ | ||
37 | u64 xtime_nsec; | ||
38 | |||
39 | /* Current CLOCK_REALTIME time in seconds */ | ||
40 | u64 xtime_sec; | ||
41 | /* CLOCK_REALTIME to CLOCK_MONOTONIC offset */ | ||
42 | struct timespec64 wall_to_monotonic; | ||
43 | |||
44 | /* Offset clock monotonic -> clock realtime */ | ||
45 | ktime_t offs_real; | ||
46 | /* Offset clock monotonic -> clock boottime */ | ||
47 | ktime_t offs_boot; | ||
48 | /* Offset clock monotonic -> clock tai */ | ||
49 | ktime_t offs_tai; | ||
50 | |||
51 | /* time spent in suspend */ | ||
52 | struct timespec64 total_sleep_time; | ||
53 | /* The current UTC to TAI offset in seconds */ | ||
54 | s32 tai_offset; | ||
55 | |||
56 | /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */ | ||
57 | struct timespec64 raw_time; | ||
58 | |||
21 | /* Number of clock cycles in one NTP interval. */ | 59 | /* Number of clock cycles in one NTP interval. */ |
22 | cycle_t cycle_interval; | 60 | cycle_t cycle_interval; |
23 | /* Last cycle value (also stored in clock->cycle_last) */ | 61 | /* Last cycle value (also stored in clock->cycle_last) */ |
@@ -29,46 +67,16 @@ struct timekeeper { | |||
29 | /* Raw nano seconds accumulated per NTP interval. */ | 67 | /* Raw nano seconds accumulated per NTP interval. */ |
30 | u32 raw_interval; | 68 | u32 raw_interval; |
31 | 69 | ||
32 | /* Current CLOCK_REALTIME time in seconds */ | 70 | /* |
33 | u64 xtime_sec; | 71 | * Difference between accumulated time and NTP time in ntp |
34 | /* Clock shifted nano seconds */ | 72 | * shifted nano seconds. |
35 | u64 xtime_nsec; | 73 | */ |
36 | |||
37 | /* Difference between accumulated time and NTP time in ntp | ||
38 | * shifted nano seconds. */ | ||
39 | s64 ntp_error; | 74 | s64 ntp_error; |
40 | /* Shift conversion between clock shifted nano seconds and | ||
41 | * ntp shifted nano seconds. */ | ||
42 | u32 ntp_error_shift; | ||
43 | |||
44 | /* | 75 | /* |
45 | * wall_to_monotonic is what we need to add to xtime (or xtime corrected | 76 | * Shift conversion between clock shifted nano seconds and |
46 | * for sub jiffie times) to get to monotonic time. Monotonic is pegged | 77 | * ntp shifted nano seconds. |
47 | * at zero at system boot time, so wall_to_monotonic will be negative, | ||
48 | * however, we will ALWAYS keep the tv_nsec part positive so we can use | ||
49 | * the usual normalization. | ||
50 | * | ||
51 | * wall_to_monotonic is moved after resume from suspend for the | ||
52 | * monotonic time not to jump. We need to add total_sleep_time to | ||
53 | * wall_to_monotonic to get the real boot based time offset. | ||
54 | * | ||
55 | * - wall_to_monotonic is no longer the boot time, getboottime must be | ||
56 | * used instead. | ||
57 | */ | 78 | */ |
58 | struct timespec64 wall_to_monotonic; | 79 | u32 ntp_error_shift; |
59 | /* Offset clock monotonic -> clock realtime */ | ||
60 | ktime_t offs_real; | ||
61 | /* time spent in suspend */ | ||
62 | struct timespec64 total_sleep_time; | ||
63 | /* Offset clock monotonic -> clock boottime */ | ||
64 | ktime_t offs_boot; | ||
65 | /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */ | ||
66 | struct timespec64 raw_time; | ||
67 | /* The current UTC to TAI offset in seconds */ | ||
68 | s32 tai_offset; | ||
69 | /* Offset clock monotonic -> clock tai */ | ||
70 | ktime_t offs_tai; | ||
71 | |||
72 | }; | 80 | }; |
73 | 81 | ||
74 | #ifdef CONFIG_GENERIC_TIME_VSYSCALL | 82 | #ifdef CONFIG_GENERIC_TIME_VSYSCALL |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 983d67b388d7..7ca150ad387d 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -32,9 +32,16 @@ | |||
32 | #define TK_MIRROR (1 << 1) | 32 | #define TK_MIRROR (1 << 1) |
33 | #define TK_CLOCK_WAS_SET (1 << 2) | 33 | #define TK_CLOCK_WAS_SET (1 << 2) |
34 | 34 | ||
35 | static struct timekeeper timekeeper; | 35 | /* |
36 | * The most important data for readout fits into a single 64 byte | ||
37 | * cache line. | ||
38 | */ | ||
39 | static struct { | ||
40 | seqcount_t seq; | ||
41 | struct timekeeper timekeeper; | ||
42 | } tk_core ____cacheline_aligned; | ||
43 | |||
36 | static DEFINE_RAW_SPINLOCK(timekeeper_lock); | 44 | static DEFINE_RAW_SPINLOCK(timekeeper_lock); |
37 | static seqcount_t timekeeper_seq; | ||
38 | static struct timekeeper shadow_timekeeper; | 45 | static struct timekeeper shadow_timekeeper; |
39 | 46 | ||
40 | /* flag for if timekeeping is suspended */ | 47 | /* flag for if timekeeping is suspended */ |
@@ -254,7 +261,7 @@ static void update_pvclock_gtod(struct timekeeper *tk, bool was_set) | |||
254 | */ | 261 | */ |
255 | int pvclock_gtod_register_notifier(struct notifier_block *nb) | 262 | int pvclock_gtod_register_notifier(struct notifier_block *nb) |
256 | { | 263 | { |
257 | struct timekeeper *tk = &timekeeper; | 264 | struct timekeeper *tk = &tk_core.timekeeper; |
258 | unsigned long flags; | 265 | unsigned long flags; |
259 | int ret; | 266 | int ret; |
260 | 267 | ||
@@ -295,7 +302,8 @@ static void timekeeping_update(struct timekeeper *tk, unsigned int action) | |||
295 | update_pvclock_gtod(tk, action & TK_CLOCK_WAS_SET); | 302 | update_pvclock_gtod(tk, action & TK_CLOCK_WAS_SET); |
296 | 303 | ||
297 | if (action & TK_MIRROR) | 304 | if (action & TK_MIRROR) |
298 | memcpy(&shadow_timekeeper, &timekeeper, sizeof(timekeeper)); | 305 | memcpy(&shadow_timekeeper, &tk_core.timekeeper, |
306 | sizeof(tk_core.timekeeper)); | ||
299 | } | 307 | } |
300 | 308 | ||
301 | /** | 309 | /** |
@@ -336,17 +344,17 @@ static void timekeeping_forward_now(struct timekeeper *tk) | |||
336 | */ | 344 | */ |
337 | int __getnstimeofday64(struct timespec64 *ts) | 345 | int __getnstimeofday64(struct timespec64 *ts) |
338 | { | 346 | { |
339 | struct timekeeper *tk = &timekeeper; | 347 | struct timekeeper *tk = &tk_core.timekeeper; |
340 | unsigned long seq; | 348 | unsigned long seq; |
341 | s64 nsecs = 0; | 349 | s64 nsecs = 0; |
342 | 350 | ||
343 | do { | 351 | do { |
344 | seq = read_seqcount_begin(&timekeeper_seq); | 352 | seq = read_seqcount_begin(&tk_core.seq); |
345 | 353 | ||
346 | ts->tv_sec = tk->xtime_sec; | 354 | ts->tv_sec = tk->xtime_sec; |
347 | nsecs = timekeeping_get_ns(tk); | 355 | nsecs = timekeeping_get_ns(tk); |
348 | 356 | ||
349 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 357 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
350 | 358 | ||
351 | ts->tv_nsec = 0; | 359 | ts->tv_nsec = 0; |
352 | timespec64_add_ns(ts, nsecs); | 360 | timespec64_add_ns(ts, nsecs); |
@@ -375,18 +383,18 @@ EXPORT_SYMBOL(getnstimeofday64); | |||
375 | 383 | ||
376 | ktime_t ktime_get(void) | 384 | ktime_t ktime_get(void) |
377 | { | 385 | { |
378 | struct timekeeper *tk = &timekeeper; | 386 | struct timekeeper *tk = &tk_core.timekeeper; |
379 | unsigned int seq; | 387 | unsigned int seq; |
380 | s64 secs, nsecs; | 388 | s64 secs, nsecs; |
381 | 389 | ||
382 | WARN_ON(timekeeping_suspended); | 390 | WARN_ON(timekeeping_suspended); |
383 | 391 | ||
384 | do { | 392 | do { |
385 | seq = read_seqcount_begin(&timekeeper_seq); | 393 | seq = read_seqcount_begin(&tk_core.seq); |
386 | secs = tk->xtime_sec + tk->wall_to_monotonic.tv_sec; | 394 | secs = tk->xtime_sec + tk->wall_to_monotonic.tv_sec; |
387 | nsecs = timekeeping_get_ns(tk) + tk->wall_to_monotonic.tv_nsec; | 395 | nsecs = timekeeping_get_ns(tk) + tk->wall_to_monotonic.tv_nsec; |
388 | 396 | ||
389 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 397 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
390 | 398 | ||
391 | return ktime_set(secs, nsecs); | 399 | return ktime_set(secs, nsecs); |
392 | } | 400 | } |
@@ -402,7 +410,7 @@ EXPORT_SYMBOL_GPL(ktime_get); | |||
402 | */ | 410 | */ |
403 | void ktime_get_ts64(struct timespec64 *ts) | 411 | void ktime_get_ts64(struct timespec64 *ts) |
404 | { | 412 | { |
405 | struct timekeeper *tk = &timekeeper; | 413 | struct timekeeper *tk = &tk_core.timekeeper; |
406 | struct timespec64 tomono; | 414 | struct timespec64 tomono; |
407 | s64 nsec; | 415 | s64 nsec; |
408 | unsigned int seq; | 416 | unsigned int seq; |
@@ -410,12 +418,12 @@ void ktime_get_ts64(struct timespec64 *ts) | |||
410 | WARN_ON(timekeeping_suspended); | 418 | WARN_ON(timekeeping_suspended); |
411 | 419 | ||
412 | do { | 420 | do { |
413 | seq = read_seqcount_begin(&timekeeper_seq); | 421 | seq = read_seqcount_begin(&tk_core.seq); |
414 | ts->tv_sec = tk->xtime_sec; | 422 | ts->tv_sec = tk->xtime_sec; |
415 | nsec = timekeeping_get_ns(tk); | 423 | nsec = timekeeping_get_ns(tk); |
416 | tomono = tk->wall_to_monotonic; | 424 | tomono = tk->wall_to_monotonic; |
417 | 425 | ||
418 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 426 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
419 | 427 | ||
420 | ts->tv_sec += tomono.tv_sec; | 428 | ts->tv_sec += tomono.tv_sec; |
421 | ts->tv_nsec = 0; | 429 | ts->tv_nsec = 0; |
@@ -432,7 +440,7 @@ EXPORT_SYMBOL_GPL(ktime_get_ts64); | |||
432 | */ | 440 | */ |
433 | void timekeeping_clocktai(struct timespec *ts) | 441 | void timekeeping_clocktai(struct timespec *ts) |
434 | { | 442 | { |
435 | struct timekeeper *tk = &timekeeper; | 443 | struct timekeeper *tk = &tk_core.timekeeper; |
436 | struct timespec64 ts64; | 444 | struct timespec64 ts64; |
437 | unsigned long seq; | 445 | unsigned long seq; |
438 | u64 nsecs; | 446 | u64 nsecs; |
@@ -440,12 +448,12 @@ void timekeeping_clocktai(struct timespec *ts) | |||
440 | WARN_ON(timekeeping_suspended); | 448 | WARN_ON(timekeeping_suspended); |
441 | 449 | ||
442 | do { | 450 | do { |
443 | seq = read_seqcount_begin(&timekeeper_seq); | 451 | seq = read_seqcount_begin(&tk_core.seq); |
444 | 452 | ||
445 | ts64.tv_sec = tk->xtime_sec + tk->tai_offset; | 453 | ts64.tv_sec = tk->xtime_sec + tk->tai_offset; |
446 | nsecs = timekeeping_get_ns(tk); | 454 | nsecs = timekeeping_get_ns(tk); |
447 | 455 | ||
448 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 456 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
449 | 457 | ||
450 | ts64.tv_nsec = 0; | 458 | ts64.tv_nsec = 0; |
451 | timespec64_add_ns(&ts64, nsecs); | 459 | timespec64_add_ns(&ts64, nsecs); |
@@ -482,14 +490,14 @@ EXPORT_SYMBOL(ktime_get_clocktai); | |||
482 | */ | 490 | */ |
483 | void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real) | 491 | void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real) |
484 | { | 492 | { |
485 | struct timekeeper *tk = &timekeeper; | 493 | struct timekeeper *tk = &tk_core.timekeeper; |
486 | unsigned long seq; | 494 | unsigned long seq; |
487 | s64 nsecs_raw, nsecs_real; | 495 | s64 nsecs_raw, nsecs_real; |
488 | 496 | ||
489 | WARN_ON_ONCE(timekeeping_suspended); | 497 | WARN_ON_ONCE(timekeeping_suspended); |
490 | 498 | ||
491 | do { | 499 | do { |
492 | seq = read_seqcount_begin(&timekeeper_seq); | 500 | seq = read_seqcount_begin(&tk_core.seq); |
493 | 501 | ||
494 | *ts_raw = timespec64_to_timespec(tk->raw_time); | 502 | *ts_raw = timespec64_to_timespec(tk->raw_time); |
495 | ts_real->tv_sec = tk->xtime_sec; | 503 | ts_real->tv_sec = tk->xtime_sec; |
@@ -498,7 +506,7 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real) | |||
498 | nsecs_raw = timekeeping_get_ns_raw(tk); | 506 | nsecs_raw = timekeeping_get_ns_raw(tk); |
499 | nsecs_real = timekeeping_get_ns(tk); | 507 | nsecs_real = timekeeping_get_ns(tk); |
500 | 508 | ||
501 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 509 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
502 | 510 | ||
503 | timespec_add_ns(ts_raw, nsecs_raw); | 511 | timespec_add_ns(ts_raw, nsecs_raw); |
504 | timespec_add_ns(ts_real, nsecs_real); | 512 | timespec_add_ns(ts_real, nsecs_real); |
@@ -531,7 +539,7 @@ EXPORT_SYMBOL(do_gettimeofday); | |||
531 | */ | 539 | */ |
532 | int do_settimeofday(const struct timespec *tv) | 540 | int do_settimeofday(const struct timespec *tv) |
533 | { | 541 | { |
534 | struct timekeeper *tk = &timekeeper; | 542 | struct timekeeper *tk = &tk_core.timekeeper; |
535 | struct timespec64 ts_delta, xt, tmp; | 543 | struct timespec64 ts_delta, xt, tmp; |
536 | unsigned long flags; | 544 | unsigned long flags; |
537 | 545 | ||
@@ -539,7 +547,7 @@ int do_settimeofday(const struct timespec *tv) | |||
539 | return -EINVAL; | 547 | return -EINVAL; |
540 | 548 | ||
541 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 549 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
542 | write_seqcount_begin(&timekeeper_seq); | 550 | write_seqcount_begin(&tk_core.seq); |
543 | 551 | ||
544 | timekeeping_forward_now(tk); | 552 | timekeeping_forward_now(tk); |
545 | 553 | ||
@@ -554,7 +562,7 @@ int do_settimeofday(const struct timespec *tv) | |||
554 | 562 | ||
555 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); | 563 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); |
556 | 564 | ||
557 | write_seqcount_end(&timekeeper_seq); | 565 | write_seqcount_end(&tk_core.seq); |
558 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 566 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
559 | 567 | ||
560 | /* signal hrtimers about time change */ | 568 | /* signal hrtimers about time change */ |
@@ -572,7 +580,7 @@ EXPORT_SYMBOL(do_settimeofday); | |||
572 | */ | 580 | */ |
573 | int timekeeping_inject_offset(struct timespec *ts) | 581 | int timekeeping_inject_offset(struct timespec *ts) |
574 | { | 582 | { |
575 | struct timekeeper *tk = &timekeeper; | 583 | struct timekeeper *tk = &tk_core.timekeeper; |
576 | unsigned long flags; | 584 | unsigned long flags; |
577 | struct timespec64 ts64, tmp; | 585 | struct timespec64 ts64, tmp; |
578 | int ret = 0; | 586 | int ret = 0; |
@@ -583,7 +591,7 @@ int timekeeping_inject_offset(struct timespec *ts) | |||
583 | ts64 = timespec_to_timespec64(*ts); | 591 | ts64 = timespec_to_timespec64(*ts); |
584 | 592 | ||
585 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 593 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
586 | write_seqcount_begin(&timekeeper_seq); | 594 | write_seqcount_begin(&tk_core.seq); |
587 | 595 | ||
588 | timekeeping_forward_now(tk); | 596 | timekeeping_forward_now(tk); |
589 | 597 | ||
@@ -600,7 +608,7 @@ int timekeeping_inject_offset(struct timespec *ts) | |||
600 | error: /* even if we error out, we forwarded the time, so call update */ | 608 | error: /* even if we error out, we forwarded the time, so call update */ |
601 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); | 609 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); |
602 | 610 | ||
603 | write_seqcount_end(&timekeeper_seq); | 611 | write_seqcount_end(&tk_core.seq); |
604 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 612 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
605 | 613 | ||
606 | /* signal hrtimers about time change */ | 614 | /* signal hrtimers about time change */ |
@@ -617,14 +625,14 @@ EXPORT_SYMBOL(timekeeping_inject_offset); | |||
617 | */ | 625 | */ |
618 | s32 timekeeping_get_tai_offset(void) | 626 | s32 timekeeping_get_tai_offset(void) |
619 | { | 627 | { |
620 | struct timekeeper *tk = &timekeeper; | 628 | struct timekeeper *tk = &tk_core.timekeeper; |
621 | unsigned int seq; | 629 | unsigned int seq; |
622 | s32 ret; | 630 | s32 ret; |
623 | 631 | ||
624 | do { | 632 | do { |
625 | seq = read_seqcount_begin(&timekeeper_seq); | 633 | seq = read_seqcount_begin(&tk_core.seq); |
626 | ret = tk->tai_offset; | 634 | ret = tk->tai_offset; |
627 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 635 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
628 | 636 | ||
629 | return ret; | 637 | return ret; |
630 | } | 638 | } |
@@ -645,14 +653,14 @@ static void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset) | |||
645 | */ | 653 | */ |
646 | void timekeeping_set_tai_offset(s32 tai_offset) | 654 | void timekeeping_set_tai_offset(s32 tai_offset) |
647 | { | 655 | { |
648 | struct timekeeper *tk = &timekeeper; | 656 | struct timekeeper *tk = &tk_core.timekeeper; |
649 | unsigned long flags; | 657 | unsigned long flags; |
650 | 658 | ||
651 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 659 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
652 | write_seqcount_begin(&timekeeper_seq); | 660 | write_seqcount_begin(&tk_core.seq); |
653 | __timekeeping_set_tai_offset(tk, tai_offset); | 661 | __timekeeping_set_tai_offset(tk, tai_offset); |
654 | timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); | 662 | timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); |
655 | write_seqcount_end(&timekeeper_seq); | 663 | write_seqcount_end(&tk_core.seq); |
656 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 664 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
657 | clock_was_set(); | 665 | clock_was_set(); |
658 | } | 666 | } |
@@ -664,14 +672,14 @@ void timekeeping_set_tai_offset(s32 tai_offset) | |||
664 | */ | 672 | */ |
665 | static int change_clocksource(void *data) | 673 | static int change_clocksource(void *data) |
666 | { | 674 | { |
667 | struct timekeeper *tk = &timekeeper; | 675 | struct timekeeper *tk = &tk_core.timekeeper; |
668 | struct clocksource *new, *old; | 676 | struct clocksource *new, *old; |
669 | unsigned long flags; | 677 | unsigned long flags; |
670 | 678 | ||
671 | new = (struct clocksource *) data; | 679 | new = (struct clocksource *) data; |
672 | 680 | ||
673 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 681 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
674 | write_seqcount_begin(&timekeeper_seq); | 682 | write_seqcount_begin(&tk_core.seq); |
675 | 683 | ||
676 | timekeeping_forward_now(tk); | 684 | timekeeping_forward_now(tk); |
677 | /* | 685 | /* |
@@ -691,7 +699,7 @@ static int change_clocksource(void *data) | |||
691 | } | 699 | } |
692 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); | 700 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); |
693 | 701 | ||
694 | write_seqcount_end(&timekeeper_seq); | 702 | write_seqcount_end(&tk_core.seq); |
695 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 703 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
696 | 704 | ||
697 | return 0; | 705 | return 0; |
@@ -706,7 +714,7 @@ static int change_clocksource(void *data) | |||
706 | */ | 714 | */ |
707 | int timekeeping_notify(struct clocksource *clock) | 715 | int timekeeping_notify(struct clocksource *clock) |
708 | { | 716 | { |
709 | struct timekeeper *tk = &timekeeper; | 717 | struct timekeeper *tk = &tk_core.timekeeper; |
710 | 718 | ||
711 | if (tk->clock == clock) | 719 | if (tk->clock == clock) |
712 | return 0; | 720 | return 0; |
@@ -738,17 +746,17 @@ EXPORT_SYMBOL_GPL(ktime_get_real); | |||
738 | */ | 746 | */ |
739 | void getrawmonotonic(struct timespec *ts) | 747 | void getrawmonotonic(struct timespec *ts) |
740 | { | 748 | { |
741 | struct timekeeper *tk = &timekeeper; | 749 | struct timekeeper *tk = &tk_core.timekeeper; |
742 | struct timespec64 ts64; | 750 | struct timespec64 ts64; |
743 | unsigned long seq; | 751 | unsigned long seq; |
744 | s64 nsecs; | 752 | s64 nsecs; |
745 | 753 | ||
746 | do { | 754 | do { |
747 | seq = read_seqcount_begin(&timekeeper_seq); | 755 | seq = read_seqcount_begin(&tk_core.seq); |
748 | nsecs = timekeeping_get_ns_raw(tk); | 756 | nsecs = timekeeping_get_ns_raw(tk); |
749 | ts64 = tk->raw_time; | 757 | ts64 = tk->raw_time; |
750 | 758 | ||
751 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 759 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
752 | 760 | ||
753 | timespec64_add_ns(&ts64, nsecs); | 761 | timespec64_add_ns(&ts64, nsecs); |
754 | *ts = timespec64_to_timespec(ts64); | 762 | *ts = timespec64_to_timespec(ts64); |
@@ -760,16 +768,16 @@ EXPORT_SYMBOL(getrawmonotonic); | |||
760 | */ | 768 | */ |
761 | int timekeeping_valid_for_hres(void) | 769 | int timekeeping_valid_for_hres(void) |
762 | { | 770 | { |
763 | struct timekeeper *tk = &timekeeper; | 771 | struct timekeeper *tk = &tk_core.timekeeper; |
764 | unsigned long seq; | 772 | unsigned long seq; |
765 | int ret; | 773 | int ret; |
766 | 774 | ||
767 | do { | 775 | do { |
768 | seq = read_seqcount_begin(&timekeeper_seq); | 776 | seq = read_seqcount_begin(&tk_core.seq); |
769 | 777 | ||
770 | ret = tk->clock->flags & CLOCK_SOURCE_VALID_FOR_HRES; | 778 | ret = tk->clock->flags & CLOCK_SOURCE_VALID_FOR_HRES; |
771 | 779 | ||
772 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 780 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
773 | 781 | ||
774 | return ret; | 782 | return ret; |
775 | } | 783 | } |
@@ -779,16 +787,16 @@ int timekeeping_valid_for_hres(void) | |||
779 | */ | 787 | */ |
780 | u64 timekeeping_max_deferment(void) | 788 | u64 timekeeping_max_deferment(void) |
781 | { | 789 | { |
782 | struct timekeeper *tk = &timekeeper; | 790 | struct timekeeper *tk = &tk_core.timekeeper; |
783 | unsigned long seq; | 791 | unsigned long seq; |
784 | u64 ret; | 792 | u64 ret; |
785 | 793 | ||
786 | do { | 794 | do { |
787 | seq = read_seqcount_begin(&timekeeper_seq); | 795 | seq = read_seqcount_begin(&tk_core.seq); |
788 | 796 | ||
789 | ret = tk->clock->max_idle_ns; | 797 | ret = tk->clock->max_idle_ns; |
790 | 798 | ||
791 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 799 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
792 | 800 | ||
793 | return ret; | 801 | return ret; |
794 | } | 802 | } |
@@ -828,7 +836,7 @@ void __weak read_boot_clock(struct timespec *ts) | |||
828 | */ | 836 | */ |
829 | void __init timekeeping_init(void) | 837 | void __init timekeeping_init(void) |
830 | { | 838 | { |
831 | struct timekeeper *tk = &timekeeper; | 839 | struct timekeeper *tk = &tk_core.timekeeper; |
832 | struct clocksource *clock; | 840 | struct clocksource *clock; |
833 | unsigned long flags; | 841 | unsigned long flags; |
834 | struct timespec64 now, boot, tmp; | 842 | struct timespec64 now, boot, tmp; |
@@ -854,7 +862,7 @@ void __init timekeeping_init(void) | |||
854 | } | 862 | } |
855 | 863 | ||
856 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 864 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
857 | write_seqcount_begin(&timekeeper_seq); | 865 | write_seqcount_begin(&tk_core.seq); |
858 | ntp_init(); | 866 | ntp_init(); |
859 | 867 | ||
860 | clock = clocksource_default_clock(); | 868 | clock = clocksource_default_clock(); |
@@ -875,9 +883,10 @@ void __init timekeeping_init(void) | |||
875 | tmp.tv_nsec = 0; | 883 | tmp.tv_nsec = 0; |
876 | tk_set_sleep_time(tk, tmp); | 884 | tk_set_sleep_time(tk, tmp); |
877 | 885 | ||
878 | memcpy(&shadow_timekeeper, &timekeeper, sizeof(timekeeper)); | 886 | memcpy(&shadow_timekeeper, &tk_core.timekeeper, |
887 | sizeof(tk_core.timekeeper)); | ||
879 | 888 | ||
880 | write_seqcount_end(&timekeeper_seq); | 889 | write_seqcount_end(&tk_core.seq); |
881 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 890 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
882 | } | 891 | } |
883 | 892 | ||
@@ -918,7 +927,7 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk, | |||
918 | */ | 927 | */ |
919 | void timekeeping_inject_sleeptime(struct timespec *delta) | 928 | void timekeeping_inject_sleeptime(struct timespec *delta) |
920 | { | 929 | { |
921 | struct timekeeper *tk = &timekeeper; | 930 | struct timekeeper *tk = &tk_core.timekeeper; |
922 | struct timespec64 tmp; | 931 | struct timespec64 tmp; |
923 | unsigned long flags; | 932 | unsigned long flags; |
924 | 933 | ||
@@ -930,7 +939,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta) | |||
930 | return; | 939 | return; |
931 | 940 | ||
932 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 941 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
933 | write_seqcount_begin(&timekeeper_seq); | 942 | write_seqcount_begin(&tk_core.seq); |
934 | 943 | ||
935 | timekeeping_forward_now(tk); | 944 | timekeeping_forward_now(tk); |
936 | 945 | ||
@@ -939,7 +948,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta) | |||
939 | 948 | ||
940 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); | 949 | timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); |
941 | 950 | ||
942 | write_seqcount_end(&timekeeper_seq); | 951 | write_seqcount_end(&tk_core.seq); |
943 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 952 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
944 | 953 | ||
945 | /* signal hrtimers about time change */ | 954 | /* signal hrtimers about time change */ |
@@ -955,7 +964,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta) | |||
955 | */ | 964 | */ |
956 | static void timekeeping_resume(void) | 965 | static void timekeeping_resume(void) |
957 | { | 966 | { |
958 | struct timekeeper *tk = &timekeeper; | 967 | struct timekeeper *tk = &tk_core.timekeeper; |
959 | struct clocksource *clock = tk->clock; | 968 | struct clocksource *clock = tk->clock; |
960 | unsigned long flags; | 969 | unsigned long flags; |
961 | struct timespec64 ts_new, ts_delta; | 970 | struct timespec64 ts_new, ts_delta; |
@@ -970,7 +979,7 @@ static void timekeeping_resume(void) | |||
970 | clocksource_resume(); | 979 | clocksource_resume(); |
971 | 980 | ||
972 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 981 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
973 | write_seqcount_begin(&timekeeper_seq); | 982 | write_seqcount_begin(&tk_core.seq); |
974 | 983 | ||
975 | /* | 984 | /* |
976 | * After system resumes, we need to calculate the suspended time and | 985 | * After system resumes, we need to calculate the suspended time and |
@@ -1022,7 +1031,7 @@ static void timekeeping_resume(void) | |||
1022 | tk->ntp_error = 0; | 1031 | tk->ntp_error = 0; |
1023 | timekeeping_suspended = 0; | 1032 | timekeeping_suspended = 0; |
1024 | timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); | 1033 | timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); |
1025 | write_seqcount_end(&timekeeper_seq); | 1034 | write_seqcount_end(&tk_core.seq); |
1026 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 1035 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
1027 | 1036 | ||
1028 | touch_softlockup_watchdog(); | 1037 | touch_softlockup_watchdog(); |
@@ -1035,7 +1044,7 @@ static void timekeeping_resume(void) | |||
1035 | 1044 | ||
1036 | static int timekeeping_suspend(void) | 1045 | static int timekeeping_suspend(void) |
1037 | { | 1046 | { |
1038 | struct timekeeper *tk = &timekeeper; | 1047 | struct timekeeper *tk = &tk_core.timekeeper; |
1039 | unsigned long flags; | 1048 | unsigned long flags; |
1040 | struct timespec64 delta, delta_delta; | 1049 | struct timespec64 delta, delta_delta; |
1041 | static struct timespec64 old_delta; | 1050 | static struct timespec64 old_delta; |
@@ -1053,7 +1062,7 @@ static int timekeeping_suspend(void) | |||
1053 | persistent_clock_exist = true; | 1062 | persistent_clock_exist = true; |
1054 | 1063 | ||
1055 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 1064 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
1056 | write_seqcount_begin(&timekeeper_seq); | 1065 | write_seqcount_begin(&tk_core.seq); |
1057 | timekeeping_forward_now(tk); | 1066 | timekeeping_forward_now(tk); |
1058 | timekeeping_suspended = 1; | 1067 | timekeeping_suspended = 1; |
1059 | 1068 | ||
@@ -1078,7 +1087,7 @@ static int timekeeping_suspend(void) | |||
1078 | } | 1087 | } |
1079 | 1088 | ||
1080 | timekeeping_update(tk, TK_MIRROR); | 1089 | timekeeping_update(tk, TK_MIRROR); |
1081 | write_seqcount_end(&timekeeper_seq); | 1090 | write_seqcount_end(&tk_core.seq); |
1082 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 1091 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
1083 | 1092 | ||
1084 | clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL); | 1093 | clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL); |
@@ -1380,7 +1389,7 @@ static cycle_t logarithmic_accumulation(struct timekeeper *tk, cycle_t offset, | |||
1380 | void update_wall_time(void) | 1389 | void update_wall_time(void) |
1381 | { | 1390 | { |
1382 | struct clocksource *clock; | 1391 | struct clocksource *clock; |
1383 | struct timekeeper *real_tk = &timekeeper; | 1392 | struct timekeeper *real_tk = &tk_core.timekeeper; |
1384 | struct timekeeper *tk = &shadow_timekeeper; | 1393 | struct timekeeper *tk = &shadow_timekeeper; |
1385 | cycle_t offset; | 1394 | cycle_t offset; |
1386 | int shift = 0, maxshift; | 1395 | int shift = 0, maxshift; |
@@ -1440,7 +1449,7 @@ void update_wall_time(void) | |||
1440 | */ | 1449 | */ |
1441 | clock_set |= accumulate_nsecs_to_secs(tk); | 1450 | clock_set |= accumulate_nsecs_to_secs(tk); |
1442 | 1451 | ||
1443 | write_seqcount_begin(&timekeeper_seq); | 1452 | write_seqcount_begin(&tk_core.seq); |
1444 | /* Update clock->cycle_last with the new value */ | 1453 | /* Update clock->cycle_last with the new value */ |
1445 | clock->cycle_last = tk->cycle_last; | 1454 | clock->cycle_last = tk->cycle_last; |
1446 | /* | 1455 | /* |
@@ -1450,12 +1459,12 @@ void update_wall_time(void) | |||
1450 | * requires changes to all other timekeeper usage sites as | 1459 | * requires changes to all other timekeeper usage sites as |
1451 | * well, i.e. move the timekeeper pointer getter into the | 1460 | * well, i.e. move the timekeeper pointer getter into the |
1452 | * spinlocked/seqcount protected sections. And we trade this | 1461 | * spinlocked/seqcount protected sections. And we trade this |
1453 | * memcpy under the timekeeper_seq against one before we start | 1462 | * memcpy under the tk_core.seq against one before we start |
1454 | * updating. | 1463 | * updating. |
1455 | */ | 1464 | */ |
1456 | memcpy(real_tk, tk, sizeof(*tk)); | 1465 | memcpy(real_tk, tk, sizeof(*tk)); |
1457 | timekeeping_update(real_tk, clock_set); | 1466 | timekeeping_update(real_tk, clock_set); |
1458 | write_seqcount_end(&timekeeper_seq); | 1467 | write_seqcount_end(&tk_core.seq); |
1459 | out: | 1468 | out: |
1460 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 1469 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
1461 | if (clock_set) | 1470 | if (clock_set) |
@@ -1476,7 +1485,7 @@ out: | |||
1476 | */ | 1485 | */ |
1477 | void getboottime(struct timespec *ts) | 1486 | void getboottime(struct timespec *ts) |
1478 | { | 1487 | { |
1479 | struct timekeeper *tk = &timekeeper; | 1488 | struct timekeeper *tk = &tk_core.timekeeper; |
1480 | struct timespec boottime = { | 1489 | struct timespec boottime = { |
1481 | .tv_sec = tk->wall_to_monotonic.tv_sec + | 1490 | .tv_sec = tk->wall_to_monotonic.tv_sec + |
1482 | tk->total_sleep_time.tv_sec, | 1491 | tk->total_sleep_time.tv_sec, |
@@ -1499,7 +1508,7 @@ EXPORT_SYMBOL_GPL(getboottime); | |||
1499 | */ | 1508 | */ |
1500 | void get_monotonic_boottime(struct timespec *ts) | 1509 | void get_monotonic_boottime(struct timespec *ts) |
1501 | { | 1510 | { |
1502 | struct timekeeper *tk = &timekeeper; | 1511 | struct timekeeper *tk = &tk_core.timekeeper; |
1503 | struct timespec64 tomono, sleep, ret; | 1512 | struct timespec64 tomono, sleep, ret; |
1504 | s64 nsec; | 1513 | s64 nsec; |
1505 | unsigned int seq; | 1514 | unsigned int seq; |
@@ -1507,13 +1516,13 @@ void get_monotonic_boottime(struct timespec *ts) | |||
1507 | WARN_ON(timekeeping_suspended); | 1516 | WARN_ON(timekeeping_suspended); |
1508 | 1517 | ||
1509 | do { | 1518 | do { |
1510 | seq = read_seqcount_begin(&timekeeper_seq); | 1519 | seq = read_seqcount_begin(&tk_core.seq); |
1511 | ret.tv_sec = tk->xtime_sec; | 1520 | ret.tv_sec = tk->xtime_sec; |
1512 | nsec = timekeeping_get_ns(tk); | 1521 | nsec = timekeeping_get_ns(tk); |
1513 | tomono = tk->wall_to_monotonic; | 1522 | tomono = tk->wall_to_monotonic; |
1514 | sleep = tk->total_sleep_time; | 1523 | sleep = tk->total_sleep_time; |
1515 | 1524 | ||
1516 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 1525 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
1517 | 1526 | ||
1518 | ret.tv_sec += tomono.tv_sec + sleep.tv_sec; | 1527 | ret.tv_sec += tomono.tv_sec + sleep.tv_sec; |
1519 | ret.tv_nsec = 0; | 1528 | ret.tv_nsec = 0; |
@@ -1545,7 +1554,7 @@ EXPORT_SYMBOL_GPL(ktime_get_boottime); | |||
1545 | */ | 1554 | */ |
1546 | void monotonic_to_bootbased(struct timespec *ts) | 1555 | void monotonic_to_bootbased(struct timespec *ts) |
1547 | { | 1556 | { |
1548 | struct timekeeper *tk = &timekeeper; | 1557 | struct timekeeper *tk = &tk_core.timekeeper; |
1549 | struct timespec64 ts64; | 1558 | struct timespec64 ts64; |
1550 | 1559 | ||
1551 | ts64 = timespec_to_timespec64(*ts); | 1560 | ts64 = timespec_to_timespec64(*ts); |
@@ -1556,7 +1565,7 @@ EXPORT_SYMBOL_GPL(monotonic_to_bootbased); | |||
1556 | 1565 | ||
1557 | unsigned long get_seconds(void) | 1566 | unsigned long get_seconds(void) |
1558 | { | 1567 | { |
1559 | struct timekeeper *tk = &timekeeper; | 1568 | struct timekeeper *tk = &tk_core.timekeeper; |
1560 | 1569 | ||
1561 | return tk->xtime_sec; | 1570 | return tk->xtime_sec; |
1562 | } | 1571 | } |
@@ -1564,22 +1573,22 @@ EXPORT_SYMBOL(get_seconds); | |||
1564 | 1573 | ||
1565 | struct timespec __current_kernel_time(void) | 1574 | struct timespec __current_kernel_time(void) |
1566 | { | 1575 | { |
1567 | struct timekeeper *tk = &timekeeper; | 1576 | struct timekeeper *tk = &tk_core.timekeeper; |
1568 | 1577 | ||
1569 | return timespec64_to_timespec(tk_xtime(tk)); | 1578 | return timespec64_to_timespec(tk_xtime(tk)); |
1570 | } | 1579 | } |
1571 | 1580 | ||
1572 | struct timespec current_kernel_time(void) | 1581 | struct timespec current_kernel_time(void) |
1573 | { | 1582 | { |
1574 | struct timekeeper *tk = &timekeeper; | 1583 | struct timekeeper *tk = &tk_core.timekeeper; |
1575 | struct timespec64 now; | 1584 | struct timespec64 now; |
1576 | unsigned long seq; | 1585 | unsigned long seq; |
1577 | 1586 | ||
1578 | do { | 1587 | do { |
1579 | seq = read_seqcount_begin(&timekeeper_seq); | 1588 | seq = read_seqcount_begin(&tk_core.seq); |
1580 | 1589 | ||
1581 | now = tk_xtime(tk); | 1590 | now = tk_xtime(tk); |
1582 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 1591 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
1583 | 1592 | ||
1584 | return timespec64_to_timespec(now); | 1593 | return timespec64_to_timespec(now); |
1585 | } | 1594 | } |
@@ -1587,16 +1596,16 @@ EXPORT_SYMBOL(current_kernel_time); | |||
1587 | 1596 | ||
1588 | struct timespec get_monotonic_coarse(void) | 1597 | struct timespec get_monotonic_coarse(void) |
1589 | { | 1598 | { |
1590 | struct timekeeper *tk = &timekeeper; | 1599 | struct timekeeper *tk = &tk_core.timekeeper; |
1591 | struct timespec64 now, mono; | 1600 | struct timespec64 now, mono; |
1592 | unsigned long seq; | 1601 | unsigned long seq; |
1593 | 1602 | ||
1594 | do { | 1603 | do { |
1595 | seq = read_seqcount_begin(&timekeeper_seq); | 1604 | seq = read_seqcount_begin(&tk_core.seq); |
1596 | 1605 | ||
1597 | now = tk_xtime(tk); | 1606 | now = tk_xtime(tk); |
1598 | mono = tk->wall_to_monotonic; | 1607 | mono = tk->wall_to_monotonic; |
1599 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 1608 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
1600 | 1609 | ||
1601 | set_normalized_timespec64(&now, now.tv_sec + mono.tv_sec, | 1610 | set_normalized_timespec64(&now, now.tv_sec + mono.tv_sec, |
1602 | now.tv_nsec + mono.tv_nsec); | 1611 | now.tv_nsec + mono.tv_nsec); |
@@ -1624,19 +1633,19 @@ void do_timer(unsigned long ticks) | |||
1624 | ktime_t ktime_get_update_offsets_tick(ktime_t *offs_real, ktime_t *offs_boot, | 1633 | ktime_t ktime_get_update_offsets_tick(ktime_t *offs_real, ktime_t *offs_boot, |
1625 | ktime_t *offs_tai) | 1634 | ktime_t *offs_tai) |
1626 | { | 1635 | { |
1627 | struct timekeeper *tk = &timekeeper; | 1636 | struct timekeeper *tk = &tk_core.timekeeper; |
1628 | struct timespec64 ts; | 1637 | struct timespec64 ts; |
1629 | ktime_t now; | 1638 | ktime_t now; |
1630 | unsigned int seq; | 1639 | unsigned int seq; |
1631 | 1640 | ||
1632 | do { | 1641 | do { |
1633 | seq = read_seqcount_begin(&timekeeper_seq); | 1642 | seq = read_seqcount_begin(&tk_core.seq); |
1634 | 1643 | ||
1635 | ts = tk_xtime(tk); | 1644 | ts = tk_xtime(tk); |
1636 | *offs_real = tk->offs_real; | 1645 | *offs_real = tk->offs_real; |
1637 | *offs_boot = tk->offs_boot; | 1646 | *offs_boot = tk->offs_boot; |
1638 | *offs_tai = tk->offs_tai; | 1647 | *offs_tai = tk->offs_tai; |
1639 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 1648 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
1640 | 1649 | ||
1641 | now = ktime_set(ts.tv_sec, ts.tv_nsec); | 1650 | now = ktime_set(ts.tv_sec, ts.tv_nsec); |
1642 | now = ktime_sub(now, *offs_real); | 1651 | now = ktime_sub(now, *offs_real); |
@@ -1656,13 +1665,13 @@ ktime_t ktime_get_update_offsets_tick(ktime_t *offs_real, ktime_t *offs_boot, | |||
1656 | ktime_t ktime_get_update_offsets_now(ktime_t *offs_real, ktime_t *offs_boot, | 1665 | ktime_t ktime_get_update_offsets_now(ktime_t *offs_real, ktime_t *offs_boot, |
1657 | ktime_t *offs_tai) | 1666 | ktime_t *offs_tai) |
1658 | { | 1667 | { |
1659 | struct timekeeper *tk = &timekeeper; | 1668 | struct timekeeper *tk = &tk_core.timekeeper; |
1660 | ktime_t now; | 1669 | ktime_t now; |
1661 | unsigned int seq; | 1670 | unsigned int seq; |
1662 | u64 secs, nsecs; | 1671 | u64 secs, nsecs; |
1663 | 1672 | ||
1664 | do { | 1673 | do { |
1665 | seq = read_seqcount_begin(&timekeeper_seq); | 1674 | seq = read_seqcount_begin(&tk_core.seq); |
1666 | 1675 | ||
1667 | secs = tk->xtime_sec; | 1676 | secs = tk->xtime_sec; |
1668 | nsecs = timekeeping_get_ns(tk); | 1677 | nsecs = timekeeping_get_ns(tk); |
@@ -1670,7 +1679,7 @@ ktime_t ktime_get_update_offsets_now(ktime_t *offs_real, ktime_t *offs_boot, | |||
1670 | *offs_real = tk->offs_real; | 1679 | *offs_real = tk->offs_real; |
1671 | *offs_boot = tk->offs_boot; | 1680 | *offs_boot = tk->offs_boot; |
1672 | *offs_tai = tk->offs_tai; | 1681 | *offs_tai = tk->offs_tai; |
1673 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 1682 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
1674 | 1683 | ||
1675 | now = ktime_add_ns(ktime_set(secs, 0), nsecs); | 1684 | now = ktime_add_ns(ktime_set(secs, 0), nsecs); |
1676 | now = ktime_sub(now, *offs_real); | 1685 | now = ktime_sub(now, *offs_real); |
@@ -1683,14 +1692,14 @@ ktime_t ktime_get_update_offsets_now(ktime_t *offs_real, ktime_t *offs_boot, | |||
1683 | */ | 1692 | */ |
1684 | ktime_t ktime_get_monotonic_offset(void) | 1693 | ktime_t ktime_get_monotonic_offset(void) |
1685 | { | 1694 | { |
1686 | struct timekeeper *tk = &timekeeper; | 1695 | struct timekeeper *tk = &tk_core.timekeeper; |
1687 | unsigned long seq; | 1696 | unsigned long seq; |
1688 | struct timespec64 wtom; | 1697 | struct timespec64 wtom; |
1689 | 1698 | ||
1690 | do { | 1699 | do { |
1691 | seq = read_seqcount_begin(&timekeeper_seq); | 1700 | seq = read_seqcount_begin(&tk_core.seq); |
1692 | wtom = tk->wall_to_monotonic; | 1701 | wtom = tk->wall_to_monotonic; |
1693 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 1702 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
1694 | 1703 | ||
1695 | return timespec64_to_ktime(wtom); | 1704 | return timespec64_to_ktime(wtom); |
1696 | } | 1705 | } |
@@ -1701,7 +1710,7 @@ EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset); | |||
1701 | */ | 1710 | */ |
1702 | int do_adjtimex(struct timex *txc) | 1711 | int do_adjtimex(struct timex *txc) |
1703 | { | 1712 | { |
1704 | struct timekeeper *tk = &timekeeper; | 1713 | struct timekeeper *tk = &tk_core.timekeeper; |
1705 | unsigned long flags; | 1714 | unsigned long flags; |
1706 | struct timespec64 ts; | 1715 | struct timespec64 ts; |
1707 | s32 orig_tai, tai; | 1716 | s32 orig_tai, tai; |
@@ -1726,7 +1735,7 @@ int do_adjtimex(struct timex *txc) | |||
1726 | getnstimeofday64(&ts); | 1735 | getnstimeofday64(&ts); |
1727 | 1736 | ||
1728 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 1737 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
1729 | write_seqcount_begin(&timekeeper_seq); | 1738 | write_seqcount_begin(&tk_core.seq); |
1730 | 1739 | ||
1731 | orig_tai = tai = tk->tai_offset; | 1740 | orig_tai = tai = tk->tai_offset; |
1732 | ret = __do_adjtimex(txc, &ts, &tai); | 1741 | ret = __do_adjtimex(txc, &ts, &tai); |
@@ -1735,7 +1744,7 @@ int do_adjtimex(struct timex *txc) | |||
1735 | __timekeeping_set_tai_offset(tk, tai); | 1744 | __timekeeping_set_tai_offset(tk, tai); |
1736 | timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); | 1745 | timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); |
1737 | } | 1746 | } |
1738 | write_seqcount_end(&timekeeper_seq); | 1747 | write_seqcount_end(&tk_core.seq); |
1739 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 1748 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
1740 | 1749 | ||
1741 | if (tai != orig_tai) | 1750 | if (tai != orig_tai) |
@@ -1755,11 +1764,11 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) | |||
1755 | unsigned long flags; | 1764 | unsigned long flags; |
1756 | 1765 | ||
1757 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 1766 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
1758 | write_seqcount_begin(&timekeeper_seq); | 1767 | write_seqcount_begin(&tk_core.seq); |
1759 | 1768 | ||
1760 | __hardpps(phase_ts, raw_ts); | 1769 | __hardpps(phase_ts, raw_ts); |
1761 | 1770 | ||
1762 | write_seqcount_end(&timekeeper_seq); | 1771 | write_seqcount_end(&tk_core.seq); |
1763 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 1772 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
1764 | } | 1773 | } |
1765 | EXPORT_SYMBOL(hardpps); | 1774 | EXPORT_SYMBOL(hardpps); |