@@ -485,90 +485,29 @@ u64 notrace ktime_get_tai_fast_ns(void)
485
485
}
486
486
EXPORT_SYMBOL_GPL (ktime_get_tai_fast_ns );
487
487
488
- static __always_inline u64 __ktime_get_real_fast (struct tk_fast * tkf , u64 * mono )
488
+ /**
489
+ * ktime_get_real_fast_ns: - NMI safe and fast access to clock realtime.
490
+ *
491
+ * See ktime_get_mono_fast_ns() for documentation of the time stamp ordering.
492
+ */
493
+ u64 ktime_get_real_fast_ns (void )
489
494
{
495
+ struct tk_fast * tkf = & tk_fast_mono ;
490
496
struct tk_read_base * tkr ;
491
- u64 basem , baser , delta ;
497
+ u64 baser , delta ;
492
498
unsigned int seq ;
493
499
494
500
do {
495
501
seq = raw_read_seqcount_latch (& tkf -> seq );
496
502
tkr = tkf -> base + (seq & 0x01 );
497
- basem = ktime_to_ns (tkr -> base );
498
503
baser = ktime_to_ns (tkr -> base_real );
499
504
delta = timekeeping_get_ns (tkr );
500
505
} while (raw_read_seqcount_latch_retry (& tkf -> seq , seq ));
501
506
502
- if (mono )
503
- * mono = basem + delta ;
504
507
return baser + delta ;
505
508
}
506
-
507
- /**
508
- * ktime_get_real_fast_ns: - NMI safe and fast access to clock realtime.
509
- *
510
- * See ktime_get_mono_fast_ns() for documentation of the time stamp ordering.
511
- */
512
- u64 ktime_get_real_fast_ns (void )
513
- {
514
- return __ktime_get_real_fast (& tk_fast_mono , NULL );
515
- }
516
509
EXPORT_SYMBOL_GPL (ktime_get_real_fast_ns );
517
510
518
- /**
519
- * ktime_get_fast_timestamps: - NMI safe timestamps
520
- * @snapshot: Pointer to timestamp storage
521
- *
522
- * Stores clock monotonic, boottime and realtime timestamps.
523
- *
524
- * Boot time is a racy access on 32bit systems if the sleep time injection
525
- * happens late during resume and not in timekeeping_resume(). That could
526
- * be avoided by expanding struct tk_read_base with boot offset for 32bit
527
- * and adding more overhead to the update. As this is a hard to observe
528
- * once per resume event which can be filtered with reasonable effort using
529
- * the accurate mono/real timestamps, it's probably not worth the trouble.
530
- *
531
- * Aside of that it might be possible on 32 and 64 bit to observe the
532
- * following when the sleep time injection happens late:
533
- *
534
- * CPU 0 CPU 1
535
- * timekeeping_resume()
536
- * ktime_get_fast_timestamps()
537
- * mono, real = __ktime_get_real_fast()
538
- * inject_sleep_time()
539
- * update boot offset
540
- * boot = mono + bootoffset;
541
- *
542
- * That means that boot time already has the sleep time adjustment, but
543
- * real time does not. On the next readout both are in sync again.
544
- *
545
- * Preventing this for 64bit is not really feasible without destroying the
546
- * careful cache layout of the timekeeper because the sequence count and
547
- * struct tk_read_base would then need two cache lines instead of one.
548
- *
549
- * Access to the time keeper clock source is disabled across the innermost
550
- * steps of suspend/resume. The accessors still work, but the timestamps
551
- * are frozen until time keeping is resumed which happens very early.
552
- *
553
- * For regular suspend/resume there is no observable difference vs. sched
554
- * clock, but it might affect some of the nasty low level debug printks.
555
- *
556
- * OTOH, access to sched clock is not guaranteed across suspend/resume on
557
- * all systems either so it depends on the hardware in use.
558
- *
559
- * If that turns out to be a real problem then this could be mitigated by
560
- * using sched clock in a similar way as during early boot. But it's not as
561
- * trivial as on early boot because it needs some careful protection
562
- * against the clock monotonic timestamp jumping backwards on resume.
563
- */
564
- void ktime_get_fast_timestamps (struct ktime_timestamps * snapshot )
565
- {
566
- struct timekeeper * tk = & tk_core .timekeeper ;
567
-
568
- snapshot -> real = __ktime_get_real_fast (& tk_fast_mono , & snapshot -> mono );
569
- snapshot -> boot = snapshot -> mono + ktime_to_ns (data_race (tk -> offs_boot ));
570
- }
571
-
572
511
/**
573
512
* halt_fast_timekeeper - Prevent fast timekeeper from accessing clocksource.
574
513
* @tk: Timekeeper to snapshot.
0 commit comments