Skip to content

Avoid try_shrink_lock spinlock contention#321

Open
aversecat wants to merge 1 commit into
mainfrom
auke/lock_shrink_spin_trylock
Open

Avoid try_shrink_lock spinlock contention#321
aversecat wants to merge 1 commit into
mainfrom
auke/lock_shrink_spin_trylock

Conversation

@aversecat
Copy link
Copy Markdown
Contributor

Every lock_key_range call results in a spinlock on linfo->lock to do housekeeping and reclaim idle locks. This housekeeping is non-critical and can be deferred, but more importantly, while a reclaim pass is ongoing, there's no need to attempt reclaim at the same time.

I ran into this while doing cross-node spam and it caused a near hard lockup with my VM spinning on the lock for 7+ minutes, without making any forward progress.

We can just trylock and give up. If the lock is held, another task is already reclaiming and we're safe to skip. The force flag will still cause a spin_lock to assure shutdown waits for other reclaims, which needs to happen before shutdown can progress anyway.

Every lock_key_range call results in a spinlock on linfo->lock to do
housekeeping and reclaim idle locks. This housekeeping is non-critical
and can be deferred, but more importantly, while a reclaim pass is
ongoing, there's no need to attempt reclaim at the same time.

I ran into this while doing cross-node spam and it caused a near hard
lockup with my VM spinning on the lock for 7+ minutes, without making
any forward progress.

We can just trylock and give up. If the lock is held, another task
is already reclaiming and we're safe to skip. The force flag will
still cause a spin_lock to assure shutdown waits for other reclaims,
which needs to happen before shutdown can progress anyway.

Signed-off-by: Auke Kok <auke.kok@versity.com>
@aversecat aversecat added the Bugfix Fixes a known bug label Jun 2, 2026
@aversecat
Copy link
Copy Markdown
Contributor Author

retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix Fixes a known bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant