-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
cannon: Implement thread-safe ll and sc operations #11906
cannon: Implement thread-safe ll and sc operations #11906
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #11906 +/- ##
===========================================
- Coverage 79.52% 79.42% -0.10%
===========================================
Files 41 41
Lines 3287 3412 +125
===========================================
+ Hits 2614 2710 +96
- Misses 511 532 +21
- Partials 162 170 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
The ll/sc changes to MIPS.sol looks good to me. We should be doubly sure we're not introducing any new behavior to that contract. So it'll be good to differentially fuzz both singlethreaded VMs for ll/sc to confirm that we're not introducing new behavior.
One way to do this is to save the bytecode of the current MIPS.sol implementation in develop. And write a test that differentially fuzzes ll/sc inputs on that old bytecode against the new singlethreaded Go VM.
ba4245c
to
5de7fe9
Compare
To double-check, I ran the new ll/sc tests against |
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.
LGTM!
4af1fe6
Description
Modify the behavior of load linked word (
ll
) and store conditional word (sc
) operations in MTCannon. These opcodes provide the primitives used to implement atomic read-modify-write (RMW) operations. Because MTCannon can context-switch between thell
andsc
calls, we need track whether the memory location reserved via thell
call is modified beforesc
is called.This PR adds several new global fields to the MT
State
to track the memory location reserved viall
. Only a single memory reservation can be active at a given time - a new reservation will clear any previous reservation. If the reserved memory location is modified, the memory reservation is cleared. When ansc
operation is executed, it will now only succeed if the memory reservation is intact, otherwisesc
returns a0
for failure.Tests
Added additional differential tests to check
ll
andsc
behavior. Ran the newll
/sc
tests againstdevelop
to validate that the behavior is unchanged for the single-threaded implementation. Also added tests to validate that the memory reservation is cleared as expected when memory is modified.Metadata
Fixes #11757