nuttx
nuttx copied to clipboard
arch/risc-v/riscv_mtimer: Update the mtimecmp value once per interrup…
Summary
Cache the next timeout value in the drivers instance and update the mtimecmp value once. This is advantageous as the opensbi ecall to set the timer is expensive in systems which don't have the supervisor mode timer extension.
Impact
Mild reduction in the mtimer interrupt time, when CONFIG_SCHED_TICKLESS is used, on the Litex platform.
Before
IRQ HANDLER ARGUMENT COUNT RATE (s) TOTAL TIME(us) MEAN TIME(us) MAX TIME(us)
21 40015396 40434f10 1204 12.607 162752 135 463 // os test
21 40015396 40434f10 2669 850.426 580978 217 718 // custom application
With this change
IRQ HANDLER ARGUMENT COUNT RATE (s) TOTAL TIME(us) MEAN TIME(us) MAX TIME(us)
21 40015396 40434f10 1217 11.898 142299 116 390 // os test
21 40015396 40434f10 2043 808.788 372405 182 619 // custom application
Testing
ostest_knsh32_new.txt ostest_knsh32_old.txt ostest_knsh64_new.txt ostest_knsh64_old.txt ostest_litex.txt
Note: OS test on qemu32 and qemu64 both return -1 before and after this change.
It would be great if this change could be tested on another hardware platform.