RISC-V: use RDTIME instead of RDCYCLE
Reported by @aurel32:
Starting with Linux 6.6 [1], RDCYCLE is a privileged instruction on RISC-V and can't be used directly from userland. There is a sysctl option to change that as a transition period, but it will eventually disappear.
Use RDTIME instead, which while less accurate has the advantage of being synchronized between CPU (and thus monotonic) and of constant frequency. It is somehow similar to the virtual timer that is used by GROMACS on Aarch64.
NB: it might be better to use the RDTIME pseudo instruction instead of using the CSRRS instruction with the CSR addresses, but there might be a reason for not using it.
The issue is fixed in %2024.release with !4040 (merged). We need to backport it to %2023.5. In main
, perhaps we can consider changing our asm code to use rdtime