shithub: riscv

Download patch

ref: 14cfa56253beb8a2ad8e4700c8c26a6ff6d16ee7
parent: 473a93d794e0e83295e012dd66969ad569044a8d
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Apr 7 14:37:40 EDT 2025

kernel: add monotonic time to /dev/time, /dev/bintime (thanks rsc)

In many places in the system, from benchmarking to scheduling
events, we want to use monotonic time. We didn't have it, so
until now, we've been using epoch nanoseconds. The problem
with this is that time moves backward when aux/timesync moves
the time-of-day backward.

This change adds an extra field to /dev/time and /dev/bintime
giving a monotonic time in nanoseconds since system boot.
Programs that do long enough reads will get this extra field.
Programs that don't do long enough reads will not.
No programs should be confused.

Speaking of being confused, also rename vlong2le etc to vlong2be
since they are converting to big-endian not little-endian.