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

Refactor cache line unlock #855

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

Conversation

mmichal10
Copy link
Contributor

No description provided.

@mmichal10 mmichal10 force-pushed the alock branch 3 times, most recently from 755629f to 9c513c7 Compare October 16, 2024 16:33
@mmichal10 mmichal10 force-pushed the alock branch 2 times, most recently from b69abb3 to c929fbf Compare February 6, 2025 10:09
In the original loop, if a cache line had multiple waiters, there was
a redundant trylock() after admitting the write lock to the first waiter.
Returning just after write-locking the cache line eliminates the redundant
trylock() and reduces the number of accesses to atomic variables.

The second issue with the original code was caused by sharing waiter lists
between different cache lines. Even if the first waiter was admitted the write
lock, the loop was iterating over the waiter list until:
  a) finding another waiter to the same cache line; in this case it tried to
     lock the cache line which has just been write-locked so the operation
     always failed
  b) reaching the end of the waiter list.
In both cases it makes no sense to continue iterating after admitting the write
lock to the first watier.

Signed-off-by: Michal Mielewczyk <[email protected]>
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.

1 participant