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

kernel: use MapCell for Process::stored_state #1826

Merged
merged 1 commit into from May 8, 2020

Conversation

alphan
Copy link
Contributor

@alphan alphan commented May 5, 2020

Pull Request Overview

Currently, Process::stored_state is defined as a Cell. This change
aims 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 this
change 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 sure
if it is OK to silently continue in cases where Process::stored_statecan
possibly be empty, which should never happen. The current
implementation exclusively uses Cell::get, but a take could always
leave a default StoredState behind so this change doesn't seem to be
worse in that regard. I tried to preserve the current behavior but please let
me know if I missed anything.

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make formatall.

Currently, Process::stored_state is defined as a Cell. This change
improves syscall latency by using MapCell instead.

See also: tock#1730, tock#178.
Copy link
Contributor

@hudson-ayers hudson-ayers left a 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?

@bradjc bradjc added the last-call Final review period for a pull request. label May 7, 2020
@alphan
Copy link
Contributor Author

alphan commented May 7, 2020

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.

@bradjc
Copy link
Contributor

bradjc commented May 8, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented May 8, 2020

@bors bors bot merged commit 329275e into tock:master May 8, 2020
@alphan alphan deleted the process-stored-state branch May 11, 2020 14:09
bors bot added a commit that referenced this pull request May 11, 2020
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
last-call Final review period for a pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants