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
kernel: use MapCell for Process::stored_state #1826
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! This also enables us to remove the Copy bound from the StoredState
associated type, and the concrete implementations of it (RiscvimacStoredState
, CortexMStoredState
) as we no longer copy StoredState
objects anywhere -- that might be a good change to add to this PR?
Good point! Created #1833, happy to take care of it, please feel free to assign to me. |
bors r+ |
Build succeeded: |
1842: remove clone/copy from StoredState r=ppannuto a=hudson-ayers ### Pull Request Overview This pull request removes the Copy trait requirement for the `StoredState` trait, possible thanks to #1826 . This should help prevent performance regressions from somewhat expensive copying (at least on risc-v) of this object now that it is stored in a MapCell. Closes #1833 . ### Testing Strategy This pull request was tested by compiling. I think this is fine as we no longer seem to be using copies of `StoredState` objects anywhere. ### TODO or Help Wanted N/A ### Documentation Updated - [x] No updates are required. ### Formatting - [x] Ran `make formatall`. Co-authored-by: Hudson Ayers <hayers@stanford.edu>
Pull Request Overview
Currently,
Process::stored_state
is defined as aCell
. This changeaims to improve syscall latency by using
MapCell
instead.See also: #1730, #178.
Testing Strategy
I ran the same
libtock-rs
app used to test #1822 with and without thischange on opentitan on verilator. This change saves ~1200 cycles for
a
command
syscall.TODO or Help Wanted
The main goal of
MapCell
is to avoid panics at runtime, but I'm not sureif it is OK to silently continue in cases where
Process::stored_state
canpossibly be empty, which should never happen. The current
implementation exclusively uses
Cell::get
, but atake
could alwaysleave a
default
StoredState
behind so this change doesn't seem to beworse in that regard. I tried to preserve the current behavior but please let
me know if I missed anything.
Documentation Updated
/docs
, or no updates are required.Formatting
make formatall
.