History

timekeeping: Fix up function documentation for the NMI safe accessors

Alex reported the following warning: kernel/time/timekeeping.c:464: warning: Function parameter or member 'tkf' not described in '__ktime_get_fast_ns' which is not entirely correct because the documented function is ktime_get_mono_fast_ns() which does not have a parameter, but the kernel-doc parser looks at the function declaration which follows the comment and complains about the missing parameter documentation. Aside of that the documentation for the rest of the NMI safe accessors is either incomplete or missing. - Move the function documentation to the right place - Fixup the references and inconsistencies - Add the missing documentation for ktime_get_raw_fast_ns()

Thomas Gleixner committed 6 years ago

Commit c1ce4061 parent e025b031 file · +33 −25Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/time/timekeeping.c+33−25
@@ -437,6 +437,27 @@ static void update_fast_timekeeper(const struct tk_read_base *tkr, · 436 unmodified lines
437437 memcpy(base + 1, base, sizeof(*base));
438438 }
439439
440+static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf)
441+{
442+ struct tk_read_base *tkr;
443+ unsigned int seq;
444+ u64 now;
445+
446+ do {
447+ seq = raw_read_seqcount_latch(&tkf->seq);
448+ tkr = tkf->base + (seq & 0x01);
449+ now = ktime_to_ns(tkr->base);
450+
451+ now += timekeeping_delta_to_ns(tkr,
452+ clocksource_delta(
453+ tk_clock_read(tkr),
454+ tkr->cycle_last,
455+ tkr->mask));
456+ } while (read_seqcount_latch_retry(&tkf->seq, seq));
457+
458+ return now;
459+}
460+
440461 /**
441462 * ktime_get_mono_fast_ns - Fast NMI safe access to clock monotonic
442463 *
@@ -463,39 +484,24 @@ static void update_fast_timekeeper(const struct tk_read_base *tkr, · 20 unmodified lines
463484 *
464485 * So reader 6 will observe time going backwards versus reader 5.
465486 *
466− * While other CPUs are likely to be able observe that, the only way
487+ * While other CPUs are likely to be able to observe that, the only way
467488 * for a CPU local observation is when an NMI hits in the middle of
468489 * the update. Timestamps taken from that NMI context might be ahead
469490 * of the following timestamps. Callers need to be aware of that and
470491 * deal with it.
471492 */
472−static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf)
473−{
474− struct tk_read_base *tkr;
475− unsigned int seq;
476− u64 now;
477−
478− do {
479− seq = raw_read_seqcount_latch(&tkf->seq);
480− tkr = tkf->base + (seq & 0x01);
481− now = ktime_to_ns(tkr->base);
482−
483− now += timekeeping_delta_to_ns(tkr,
484− clocksource_delta(
485− tk_clock_read(tkr),
486− tkr->cycle_last,
487− tkr->mask));
488− } while (read_seqcount_latch_retry(&tkf->seq, seq));
489−
490− return now;
491−}
492−
493493 u64 ktime_get_mono_fast_ns(void)
494494 {
495495 return __ktime_get_fast_ns(&tk_fast_mono);
496496 }
497497 EXPORT_SYMBOL_GPL(ktime_get_mono_fast_ns);
498498
499+/**
500+ * ktime_get_raw_fast_ns - Fast NMI safe access to clock monotonic raw
501+ *
502+ * Contrary to ktime_get_mono_fast_ns() this is always correct because the
503+ * conversion factor is not affected by NTP/PTP correction.
504+ */
499505 u64 ktime_get_raw_fast_ns(void)
500506 {
501507 return __ktime_get_fast_ns(&tk_fast_raw);
@@ -522,6 +528,9 @@ EXPORT_SYMBOL_GPL(ktime_get_raw_fast_ns); · 20 unmodified lines
522528 * (2) On 32-bit systems, the 64-bit boot offset (tk->offs_boot) may be
523529 * partially updated. Since the tk->offs_boot update is a rare event, this
524530 * should be a rare occurrence which postprocessing should be able to handle.
531+ *
532+ * The caveats vs. timestamp ordering as documented for ktime_get_fast_ns()
533+ * apply as well.
525534 */
526535 u64 notrace ktime_get_boot_fast_ns(void)
527536 {
@@ -531,9 +540,6 @@ u64 notrace ktime_get_boot_fast_ns(void) · 3 unmodified lines
531540 }
532541 EXPORT_SYMBOL_GPL(ktime_get_boot_fast_ns);
533542
534−/*
535− * See comment for __ktime_get_fast_ns() vs. timestamp ordering
536− */
537543 static __always_inline u64 __ktime_get_real_fast(struct tk_fast *tkf, u64 *mono)
538544 {
539545 struct tk_read_base *tkr;
@@ -558,6 +564,8 @@ static __always_inline u64 __ktime_get_real_fast(struct tk_fast *tkf, u64 *mono) · 18 unmodified lines
558564
559565 /**
560566 * ktime_get_real_fast_ns: - NMI safe and fast access to clock realtime.
567+ *
568+ * See ktime_get_fast_ns() for documentation of the time stamp ordering.
561569 */
562570 u64 ktime_get_real_fast_ns(void)
563571 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t