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

[herd7,aarch64] A failed CAS may write back #1095

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

artkhyzha
Copy link
Collaborator

@artkhyzha artkhyzha commented Dec 6, 2024

The objective of this PR is to amend the instruction semantics for CAS in case when its comparison fails. Broadly speaking, whenever a CAS fails its comparison, it is now allowed to read the original value in memory and then write the same value back. This has consequences: an Explicit Write Effect may be created, a Hardware Update might be created, (with FEAT_MTE_STOREONLY not supported by herd7 presently) a TagCheck may be created.

The following kinds of executions are expected of a failed CAS:

  • CAS generates an Explicit Write Effect of a value that is already in memory and, if -variant vmsa is enabled, that leads to generating a Hardware Update to the dirty bit.
  • CAS does not generate an Explicit Write Effect and, if -variant vmsa is enabled, a candidate execution with a Hardware Update to the dirty bit is generated.
  • CAS does not generate an Explicit Write Effect and, if -variant vmsa is enabled, a candidate execution without a Hardware Update to the dirty bit is generated.

Note that the aforementioned three executions are archetypes: other "alternatives" affect the overall number of executions. Thus, for instance, the test ./herd/tests/instructions/AArch64.kvm/A019.litmus has 5 rather than 3 executions.

@artkhyzha artkhyzha force-pushed the failed-cas-with-writeback branch 3 times, most recently from 3996303 to 9958020 Compare December 6, 2024 16:49
@artkhyzha artkhyzha changed the title [herd7,aarch64] Failed CAS may write back [herd7,aarch64] A failed CAS may write back Dec 6, 2024
@artkhyzha artkhyzha marked this pull request as ready for review December 6, 2024 16:57
herd/AArch64Sem.ml Outdated Show resolved Hide resolved
Copy link
Collaborator

@HadrienRenaud HadrienRenaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @artkhyzha

Thanks a lot for this, sorry a comment escaped my pending review on Friday ...

I have mainly stylistic comments, feel free not to follow them.

herd/AArch64Sem.ml Outdated Show resolved Hide resolved
herd/AArch64Sem.ml Outdated Show resolved Hide resolved
herd/AArch64Sem.ml Outdated Show resolved Hide resolved
@artkhyzha artkhyzha force-pushed the failed-cas-with-writeback branch from 2667ce9 to 6401490 Compare December 9, 2024 11:18
@artkhyzha
Copy link
Collaborator Author

Thank you very much, @HadrienRenaud, the stylistic comments are much appreciated. I found them all helpful to apply.

@artkhyzha artkhyzha force-pushed the failed-cas-with-writeback branch from 6401490 to df8566d Compare December 9, 2024 11:25
@artkhyzha artkhyzha force-pushed the failed-cas-with-writeback branch from df8566d to fe6c738 Compare December 9, 2024 11:26
@artkhyzha
Copy link
Collaborator Author

@jalglave, this PR seems to be in a decent shape, so I am hoping to check with you how to best go about it.

It essentially implements the outcomes of the investigation for the failed CAS: the user-level semantics, the db-bit semantics. One more outcome of that investigation was similar changes to behaviour for Tag Checks when FEAT_MTE_STORE_ONLY is implemented (essentially, to turn off tag checks for loads, with corner cases for CAS). This feature is not yet supported by herd7, so this PR has not attempted to change the semantics of CAS.

Overall, a few questions. Do we want more reviews before merging? Do we want to put FEAT_MTE_STORE_ONLY on the todo list? Is it alright to keep this feature of MTE out of scope of this PR? All feedback is very welcome!

@artkhyzha artkhyzha requested review from jalglave and removed request for relokin December 9, 2024 13:33
@murzinv
Copy link

murzinv commented Dec 12, 2024

Overall, a few questions. Do we want more reviews before merging? Do we want to put FEAT_MTE_STORE_ONLY on the todo list? Is it alright to keep this feature of MTE out of scope of this PR? All feedback is very welcome!

Actually I was waiting for this PR merged to restart my work on FEAT_MTE_STORE_ONLY. If it helps, I can rebase my work on top of this PR asap and report back...

@artkhyzha
Copy link
Collaborator Author

Ah, super to hear that's something you are working on, @murzinv. Rebasing on top of this would be great, but also if you think another strategy could be more helpful, don't hesitate to let me know.

@artkhyzha
Copy link
Collaborator Author

As this seems reasonably mature, I'll be aiming to merge this by the end of the day. @HadrienRenaud, @jalglave, @murzinv -- if any reason not to merge this comes up, please let me know.

@murzinv
Copy link

murzinv commented Dec 13, 2024

Ah, super to hear that's something you are working on, @murzinv. Rebasing on top of this would be great, but also if you think another strategy could be more helpful, don't hesitate to let me know.

@artkhyzha here is change for FEAT_MTE_STOREONLY . Feel free to cherry-pick in your series or I can make separate PR

@murzinv
Copy link

murzinv commented Dec 13, 2024

As this seems reasonably mature, I'll be aiming to merge this by the end of the day. @HadrienRenaud, @jalglave, @murzinv -- if any reason not to merge this comes up, please let me know.

@artkhyzha should we do anything for CASP?

@artkhyzha
Copy link
Collaborator Author

Excellent point about CASP, @murzinv! This should have been within the scope, and its support should look similar. I'll update the PR.

@artkhyzha
Copy link
Collaborator Author

I've pushed an update for CASP essentially copying the solution for CAS.

Perhaps, overly pedantically, but reading CASP description I am not sure CASP behaves exactly like CAS (i.e., has two options for present/absent Explicit Effect rather than, say, four). Hence, I'd like to hold off merging this for a little bit.

@artkhyzha
Copy link
Collaborator Author

Apologies, a follow-up to this fell between the cracks. I had concerns that perhaps there are more sophisticated single-copy atomicity rules. However, having double checked the letter of the Arm ARM and confirmed the reading of it with architects, I believe CASP is intended to always be single-copy-atomic to its full size, for both the read effect and the write effect (if the write effect does actually occur) -- or is subject to an alignment fault. To the best of my understanding, the current status of this PR treats CASP fairly.

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.

3 participants