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

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
437 memcpy(base + 1, base, sizeof(*base));437 memcpy(base + 1, base, sizeof(*base));
438}438}
439 439
440static __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
440/**461/**
441 * ktime_get_mono_fast_ns - Fast NMI safe access to clock monotonic462 * ktime_get_mono_fast_ns - Fast NMI safe access to clock monotonic
442 *463 *
@@ -463,39 +484,24 @@ static void update_fast_timekeeper(const struct tk_read_base *tkr, · 20 unmodified lines
463 *484 *
464 * So reader 6 will observe time going backwards versus reader 5.485 * So reader 6 will observe time going backwards versus reader 5.
465 *486 *
466 * While other CPUs are likely to be able observe that, the only way487 * While other CPUs are likely to be able to observe that, the only way
467 * for a CPU local observation is when an NMI hits in the middle of488 * for a CPU local observation is when an NMI hits in the middle of
468 * the update. Timestamps taken from that NMI context might be ahead489 * the update. Timestamps taken from that NMI context might be ahead
469 * of the following timestamps. Callers need to be aware of that and490 * of the following timestamps. Callers need to be aware of that and
470 * deal with it.491 * deal with it.
471 */492 */
472static __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
493u64 ktime_get_mono_fast_ns(void)493u64 ktime_get_mono_fast_ns(void)
494{494{
495 return __ktime_get_fast_ns(&tk_fast_mono);495 return __ktime_get_fast_ns(&tk_fast_mono);
496}496}
497EXPORT_SYMBOL_GPL(ktime_get_mono_fast_ns);497EXPORT_SYMBOL_GPL(ktime_get_mono_fast_ns);
498 498
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 */
499u64 ktime_get_raw_fast_ns(void)505u64 ktime_get_raw_fast_ns(void)
500{506{
501 return __ktime_get_fast_ns(&tk_fast_raw);507 return __ktime_get_fast_ns(&tk_fast_raw);
@@ -522,6 +528,9 @@ EXPORT_SYMBOL_GPL(ktime_get_raw_fast_ns); · 20 unmodified lines
522 * (2) On 32-bit systems, the 64-bit boot offset (tk->offs_boot) may be528 * (2) On 32-bit systems, the 64-bit boot offset (tk->offs_boot) may be
523 * partially updated. Since the tk->offs_boot update is a rare event, this529 * partially updated. Since the tk->offs_boot update is a rare event, this
524 * should be a rare occurrence which postprocessing should be able to handle.530 * 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.
525 */534 */
526u64 notrace ktime_get_boot_fast_ns(void)535u64 notrace ktime_get_boot_fast_ns(void)
527{536{
@@ -531,9 +540,6 @@ u64 notrace ktime_get_boot_fast_ns(void) · 3 unmodified lines
531}540}
532EXPORT_SYMBOL_GPL(ktime_get_boot_fast_ns);541EXPORT_SYMBOL_GPL(ktime_get_boot_fast_ns);
533 542
534/*
535 * See comment for __ktime_get_fast_ns() vs. timestamp ordering
536 */
537static __always_inline u64 __ktime_get_real_fast(struct tk_fast *tkf, u64 *mono)543static __always_inline u64 __ktime_get_real_fast(struct tk_fast *tkf, u64 *mono)
538{544{
539 struct tk_read_base *tkr;545 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
558 564
559/**565/**
560 * ktime_get_real_fast_ns: - NMI safe and fast access to clock realtime.566 * 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.
561 */569 */
562u64 ktime_get_real_fast_ns(void)570u64 ktime_get_real_fast_ns(void)
563{571{

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