|
@@ -55,22 +55,6 @@ notrace static noinline int do_realtime(struct timespec *ts)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-/* Copy of the version in kernel/time.c which we cannot directly access */
|
|
|
|
-notrace static void
|
|
|
|
-vset_normalized_timespec(struct timespec *ts, long sec, long nsec)
|
|
|
|
-{
|
|
|
|
- while (nsec >= NSEC_PER_SEC) {
|
|
|
|
- nsec -= NSEC_PER_SEC;
|
|
|
|
- ++sec;
|
|
|
|
- }
|
|
|
|
- while (nsec < 0) {
|
|
|
|
- nsec += NSEC_PER_SEC;
|
|
|
|
- --sec;
|
|
|
|
- }
|
|
|
|
- ts->tv_sec = sec;
|
|
|
|
- ts->tv_nsec = nsec;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
notrace static noinline int do_monotonic(struct timespec *ts)
|
|
notrace static noinline int do_monotonic(struct timespec *ts)
|
|
{
|
|
{
|
|
unsigned long seq, ns, secs;
|
|
unsigned long seq, ns, secs;
|
|
@@ -81,7 +65,17 @@ notrace static noinline int do_monotonic(struct timespec *ts)
|
|
secs += gtod->wall_to_monotonic.tv_sec;
|
|
secs += gtod->wall_to_monotonic.tv_sec;
|
|
ns += gtod->wall_to_monotonic.tv_nsec;
|
|
ns += gtod->wall_to_monotonic.tv_nsec;
|
|
} while (unlikely(read_seqretry(>od->lock, seq)));
|
|
} while (unlikely(read_seqretry(>od->lock, seq)));
|
|
- vset_normalized_timespec(ts, secs, ns);
|
|
|
|
|
|
+
|
|
|
|
+ /* wall_time_nsec, vgetns(), and wall_to_monotonic.tv_nsec
|
|
|
|
+ * are all guaranteed to be nonnegative.
|
|
|
|
+ */
|
|
|
|
+ while (ns >= NSEC_PER_SEC) {
|
|
|
|
+ ns -= NSEC_PER_SEC;
|
|
|
|
+ ++secs;
|
|
|
|
+ }
|
|
|
|
+ ts->tv_sec = secs;
|
|
|
|
+ ts->tv_nsec = ns;
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -106,7 +100,17 @@ notrace static noinline int do_monotonic_coarse(struct timespec *ts)
|
|
secs += gtod->wall_to_monotonic.tv_sec;
|
|
secs += gtod->wall_to_monotonic.tv_sec;
|
|
ns += gtod->wall_to_monotonic.tv_nsec;
|
|
ns += gtod->wall_to_monotonic.tv_nsec;
|
|
} while (unlikely(read_seqretry(>od->lock, seq)));
|
|
} while (unlikely(read_seqretry(>od->lock, seq)));
|
|
- vset_normalized_timespec(ts, secs, ns);
|
|
|
|
|
|
+
|
|
|
|
+ /* wall_time_nsec and wall_to_monotonic.tv_nsec are
|
|
|
|
+ * guaranteed to be between 0 and NSEC_PER_SEC.
|
|
|
|
+ */
|
|
|
|
+ if (ns >= NSEC_PER_SEC) {
|
|
|
|
+ ns -= NSEC_PER_SEC;
|
|
|
|
+ ++secs;
|
|
|
|
+ }
|
|
|
|
+ ts->tv_sec = secs;
|
|
|
|
+ ts->tv_nsec = ns;
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|