ot_otp_engine: Replace BHs with short timers#310
Merged
Conversation
jwnrt
approved these changes
Dec 8, 2025
pamaury
approved these changes
Dec 8, 2025
pamaury
left a comment
There was a problem hiding this comment.
Not an expert of this part of the code but the change looks reasonable.
rivos-eblot
reviewed
Dec 8, 2025
rivos-eblot
left a comment
There was a problem hiding this comment.
Being OT-offboarded tonight, keeping the review as comment-only :-)
From testing, it seems that the use of Bottom Halves on hosts under higher processing loads (where QEMU is more often pre-empted) can produce inconsistent / slow results. Timers with a short timeout provide the same decoupling functionality as the BH but with more consistency and expedience. This could be especially problematic for SW which expects digest writes to be processed within a certain time. If handling of the BH was deferred long enough, then enough guest code could be processed for it to look like e.g. 10 ms had passed, exceeding common SW timeouts. This could be seen happening occasionally under high processing loads. Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
From testing, it seems that the use of Bottom Halves on hosts under higher processing loads (where QEMU is more often pre-empted) can produce inconsistent / slow results. Timers with a short timeout provide the same decoupling functionality as the BH but with more consistency and expedience. Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
88d7131 to
a4f79c6
Compare
Author
|
CI failures are unrelated (the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See also some relevant discussion in this comment: #178 (comment). In general without a multithreaded implementation we currently prefer using a short (~100ns or so) timer over Bottom Halves for decoupling larger processing tasks and yielding back to the vCPU for a short while.
From personal testing of more involved OpenTitan integration flows, I found that when running under heavy processing loads (running many tests in parallel, such that QEMU is being pre-empted quite often), these BHs could occasionally be quite inconsistent and take a surprisingly long time to be scheduled. This was contributing to unexpected test failures due to timing - while timing is not expected to be accurate, the BH was inconsistently causing an order of magnitude difference than what is expected for some OTP operations.