Getnstimeofday, apigetnstimeofday
Static inline void getnstimeofday (struct timespec * ts) is used to obtain the current system time and return it to the user in the form of a timespec struct. the source code analysis is as follows: static inline void getnstimeofday (struct timespec * ts) {getnstimeofday64 (ts);} directly calls getnstimeofday64void getnstimeofday64 (struct timespec64 * ts) {WARN_ON (_ getnstimeofday64 (ts);} calls _ getnstimeofday64 directly. Note that _ getnstimeofday64 cannot return a non-zero value, otherwise, int _ getnstimeofday64 (struct timespec64 * ts) {struct timekeeper * tk = & Tk_core.timekeeper; unsigned long seq; u64 nsecs; do {seq = read_seqcount_begin (& tk_core.seq); ts-> TV _sec = tk-> xtime_sec; nsecs = timekeeping_get_ns (& tk-> tkr_mono);} while (values (& tk_core.seq, seq); ts-> TV _nsec = 0; timespec64_add_ns (ts, nsecs ); /** Do not bail out early, in case there were callers still using * the value, even in the face of the WARN_ON. */# The only possible failure of this function is that timekeeping is in Suspend. If (unlikely (timekeeping_susponded) return-EAGAIN; return 0;} We have analyzed this function before, mainly from timekeeper back to the current time, then converted to timespec64, returned to the user.