Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arch/risc-v/riscv_mtimer: Update the mtimecmp value once per interrup… #12433

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

g2gps
Copy link
Contributor

@g2gps g2gps commented May 31, 2024

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.

…t event.

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.
@g2gps
Copy link
Contributor Author

g2gps commented May 31, 2024

Resolves #12407

@xiaoxiang781216 xiaoxiang781216 linked an issue May 31, 2024 that may be closed by this pull request
@acassis acassis merged commit e3056c7 into apache:master Jun 2, 2024
26 checks passed
@g2gps g2gps deleted the mtimer-cache-value branch June 5, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

riscv m-timer is schduled multiple times per interrupt.
2 participants