git: 0ce82e9346a4 - stable/14 - umtx: Fix a bug in do_lock_pp()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 08 Mar 2025 08:14:00 UTC
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0ce82e9346a4d5ad1d82fac73131afa3a4fc03ac commit 0ce82e9346a4d5ad1d82fac73131afa3a4fc03ac Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2025-02-22 01:23:31 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2025-03-08 00:37:37 +0000 umtx: Fix a bug in do_lock_pp() If the lock is unowned (i.e., owner == UMUTEX_CONTESTED), we might get a spurious failure, and in that case we need to retry the loop. Otherwise, the calling thread can end up sleeping forever. The same problem exists in do_set_ceiling(), which open-codes do_lock_pp(), so fix it there too. Reviewed by: olce Reported by: Daniel King <dmking@adacore.com> MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D49031 (cherry picked from commit 4b79443927ec2c53514e73b06eb2a9d241882585) --- sys/kern/kern_umtx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index f326b9aa691a..7c01586b4dd7 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -2618,6 +2618,10 @@ do_lock_pp(struct thread *td, struct umutex *m, uint32_t flags, } } else if (owner == UMUTEX_RB_NOTRECOV) { error = ENOTRECOVERABLE; + } else if (owner == UMUTEX_CONTESTED) { + /* Spurious failure, retry. */ + umtxq_unbusy_unlocked(&uq->uq_key); + continue; } if (try != 0) @@ -2824,6 +2828,10 @@ do_set_ceiling(struct thread *td, struct umutex *m, uint32_t ceiling, } else if (owner == UMUTEX_RB_NOTRECOV) { error = ENOTRECOVERABLE; break; + } else if (owner == UMUTEX_CONTESTED) { + /* Spurious failure, retry. */ + umtxq_unbusy_unlocked(&uq->uq_key); + continue; } /*