Date: Wed, 3 Mar 2021 00:35:21 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 68b5d0bea6d2 - stable/11 - rmlock: Add a required compiler membar to the rlock slow path Message-ID: <202103030035.1230ZLDe080685@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/11 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=68b5d0bea6d244093e1923ddf350dff1b5a1ebe9 commit 68b5d0bea6d244093e1923ddf350dff1b5a1ebe9 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-02-24 02:15:50 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2021-03-03 00:34:34 +0000 rmlock: Add a required compiler membar to the rlock slow path The tracker flags need to be loaded only after the tracker is removed from its per-CPU queue. Otherwise, readers may fail to synchronize with pending writers attempting to propagate priority to active readers, and readers and writers deadlock on each other. This was observed in a stable/12-based armv7 kernel where the compiler had reordered the load of rmp_flags to before the stores updating the queue. Reviewed by: rlibby, scottl Discussed with: kib Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D28821 (cherry picked from commit 1d44514fcd68809cfd493a7352ace29ddad443d6) --- sys/kern/kern_rmlock.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c index c7661bc30cb3..a630f3b0acb5 100644 --- a/sys/kern/kern_rmlock.c +++ b/sys/kern/kern_rmlock.c @@ -359,7 +359,11 @@ _rm_rlock_hard(struct rmlock *rm, struct rm_priotracker *tracker, int trylock) /* Remove our tracker from the per-cpu list. */ rm_tracker_remove(pc, tracker); - /* Check to see if the IPI granted us the lock after all. */ + /* + * Check to see if the IPI granted us the lock after all. The load of + * rmp_flags must happen after the tracker is removed from the list. + */ + __compiler_membar(); if (tracker->rmp_flags) { /* Just add back tracker - we hold the lock. */ rm_tracker_add(pc, tracker);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103030035.1230ZLDe080685>