Skip to content

Fix fence completion race in virtio-gpu worker#608

Merged
slp merged 1 commit intocontainers:mainfrom
aford173:upstream-main/fix-fence-race
Mar 27, 2026
Merged

Fix fence completion race in virtio-gpu worker#608
slp merged 1 commit intocontainers:mainfrom
aford173:upstream-main/fix-fence-race

Conversation

@aford173
Copy link
Copy Markdown

When fences complete out of order (e.g., an immediate-retire for fence N+1 arrives before the timeline signal for fence N), the unconditional insert() would overwrite the higher fence_id with the lower one. This causes fence N+1 to appear incomplete forever, hanging the guest.

Use entry().or_insert() with a max check so only strictly higher fence_ids update the completed_fences map.

Note to maintainers: The previous submission was targeting 1.17.x branch, this is effectively the same patch with requested fixes targeting main instead if the 1.17x. branch. Please forgive the noise if this is not the proper way to submit.

When fences complete out of order (e.g., an immediate-retire for fence
N+1 arrives before the timeline signal for fence N), the unconditional
insert() would overwrite the higher fence_id with the lower one. This
causes fence N+1 to appear incomplete forever, hanging the guest.

Use entry().or_insert() with a max check so only strictly higher
fence_ids update the completed_fences map.

Signed-off-by: Adam Ford <adam.ford@anodize.com>
Copy link
Copy Markdown
Collaborator

@slp slp left a comment

Choose a reason for hiding this comment

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

Nice catch, thanks!

@slp slp merged commit 3fc7d1c into containers:main Mar 27, 2026
11 checks passed
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