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

ARCv3: Workaround for llock/scond livelock with exponential backoff #173

Merged
merged 5 commits into from
Aug 12, 2024

Conversation

pavelvkozlov
Copy link

Add option ARC_LLSC_BACKOFF which enables delayed retry for failed SCOND instruction, read core id and provide different delays before LLSC retry for each core.
Also add extra delay in spinlock wait loop before next read to prevent the data cache line from getting dirty and to give the other core time to complete the conditional store instruction (scond).

@pavelvkozlov pavelvkozlov force-pushed the pvk-arc32-llsc-backoff branch from 7004bc1 to 7d0ac1b Compare August 6, 2024 18:45
Add an option ARC_LLSC_BACKOFF which enables delayed retries for failed SCOND
instructions. This implementation reads the core ID and applies different
delays before retrying LLSC for each core.

Signed-off-by: Pavel Kozlov <[email protected]>
@pavelvkozlov pavelvkozlov force-pushed the pvk-arc32-llsc-backoff branch from 7d0ac1b to eda52bb Compare August 6, 2024 20:22
@pavelvkozlov pavelvkozlov requested review from abrodkin and xxkent August 7, 2024 11:29
@xxkent
Copy link

xxkent commented Aug 9, 2024

I've reviewed it and think we can merge this.

Add a delay before the next read in the spinlock cycle to prevent the data cache
line from getting dirty and to give other cores time to complete the conditional
store instruction (scond).

This is a workaround for livelock issues when the spinlock and
another atomic operation are on the same cache line.

Signed-off-by: Pavel Kozlov <[email protected]>
Add missed memory clobber to avoid unwanted gcc optimizations.

This change is based on upstream commit 42f51fb
(ARC: atomics: Add compiler barrier to atomic operations...)

Signed-off-by: Pavel Kozlov <[email protected]>
Restore the dependency of HAS_ATLD on HAS_LLSC. This commit reverts the
Kconfig changes introduced by commit bc57bd4 ("ARCv3: add new version
of 32-bit arch_atomic_* with atld.<op> instrs").

The implementation of 32-bit atomic functions with atld.<op> instructions
cannot fully replace the LLSC version and cannot be used as a workaround
for the llock/scond livelock issue. Use the ARC_LLSC_BACKOFF option as a
workaround for the llock/scond livelock issue.

The HAS_ATLD option can only be used for efficient fetch-and-operate atomic
functions implementation.

Signed-off-by: Pavel Kozlov <[email protected]>
Update HS5x defconfigs to disable ATLD instructions by default for UP
systems, and disable ATLD while enabling LLSC for SMP systems.

This commit reverts part of the changes introduced by commit da7891b
("ARCv3: HS5x: update defconfigs for HS5x and enable ATLD").

Signed-off-by: Pavel Kozlov <[email protected]>
@pavelvkozlov pavelvkozlov force-pushed the pvk-arc32-llsc-backoff branch from eda52bb to 7c92021 Compare August 12, 2024 13:19
@pavelvkozlov pavelvkozlov merged commit c45ffc9 into arc64 Aug 12, 2024
20 checks passed
@pavelvkozlov pavelvkozlov deleted the pvk-arc32-llsc-backoff branch August 12, 2024 13:54
@pavelvkozlov
Copy link
Author

Thank you for your review. Merged.

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.

2 participants