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

Add fence on yield to preserve HB for lock reservation #16023

Merged
merged 1 commit into from
Oct 3, 2022

Conversation

tajila
Copy link
Contributor

@tajila tajila commented Sep 30, 2022

Add fence on yield to preserve HB for lock reservation

Signed-off-by: Tobi Ajila atobia@ca.ibm.com

@tajila
Copy link
Contributor Author

tajila commented Sep 30, 2022

@gacholio could this be an issue on x86 as well? Currently, I dont think so

@tajila
Copy link
Contributor Author

tajila commented Sep 30, 2022

jenkins test sanity amac jdk19

@tajila tajila changed the title Add fence on yield to preserve HB on for lock reservation Add fence on yield to preserve HB for lock reservation Sep 30, 2022
@gacholio
Copy link
Contributor

gacholio commented Oct 1, 2022

I have no context here - what might HB refer to?

@gacholio
Copy link
Contributor

gacholio commented Oct 1, 2022

Whether this is necessary or not, excluding it on x86 is pointless - yield is already a long operation so an extra fence will never be noticeable.

@gacholio
Copy link
Contributor

gacholio commented Oct 1, 2022

Would be nice to see a detailed description of what you think the problem here might be.

@tajila
Copy link
Contributor Author

tajila commented Oct 1, 2022

@gacholio

I have no context here - what might HB refer to?

HB refers to happens-before relationship. There is a requirement in the memory model that a HB relationship is eforced between synchronization blocks. On PPC lock reservation is on by default, this means we dont do a memory barrier when entering a reserved lock. It works in this case because so long as the thread who owns the reservation is entering the lock, HB happens naturally. If a different thread wants to acquire the lock then the reservation is cancelled which performs a full memory barrier.

With Loom this is complicated by the fact that different virtual threads can run on the same j9vmthread. So virtualthread#1 running on j9vmthread#1 can reserve objectA. Later on, it can yield allowing virtualthread#2 to run on j9vmthread#1. If virtualthread#2 acquires objectA (it will own reservation since j9vmthread determines ownership)on a different core, there is a chance that it will not see the update made by virtualthread#1 since there was no memory barrier required when acquire objectA. So we need to insert a barrier everytime virtualThread yields to ensure a HB between virtualThreads acquire the same lock when lock reservation is enabled.

Would be nice to see a detailed description of what you think the problem here might be.

I added a description in the code. If its not sufficient I can elaborate more.

Signed-off-by: Tobi Ajila <atobia@ca.ibm.com>
@gacholio
Copy link
Contributor

gacholio commented Oct 3, 2022

jenkins compile zlinux jdk19

@gacholio gacholio merged commit c19e426 into eclipse-openj9:master Oct 3, 2022
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.

None yet

2 participants