git: 71f31d784e18 - main - rmslock: Update td_locks during lock and unlock operations

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 27 Oct 2021 15:19:10 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=71f31d784e1816a155cafbccf4b28291200097aa

commit 71f31d784e1816a155cafbccf4b28291200097aa
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-10-27 15:18:13 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-10-27 15:18:13 +0000

    rmslock: Update td_locks during lock and unlock operations
    
    Reviewed by:    mjg
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D32692
---
 sys/kern/kern_rmlock.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c
index 7230a00e357b..f9b5559a648c 100644
--- a/sys/kern/kern_rmlock.c
+++ b/sys/kern/kern_rmlock.c
@@ -1017,6 +1017,7 @@ rms_rlock_fallback(struct rmslock *rms)
 	rms_int_readers_inc(rms, rms_int_pcpu(rms));
 	mtx_unlock(&rms->mtx);
 	critical_exit();
+	TD_LOCKS_INC(curthread);
 }
 
 void
@@ -1040,6 +1041,7 @@ rms_rlock(struct rmslock *rms)
 	atomic_interrupt_fence();
 	rms_int_influx_exit(rms, pcpu);
 	critical_exit();
+	TD_LOCKS_INC(curthread);
 }
 
 int
@@ -1063,6 +1065,7 @@ rms_try_rlock(struct rmslock *rms)
 	atomic_interrupt_fence();
 	rms_int_influx_exit(rms, pcpu);
 	critical_exit();
+	TD_LOCKS_INC(curthread);
 	return (1);
 }
 
@@ -1082,6 +1085,7 @@ rms_runlock_fallback(struct rmslock *rms)
 	if (rms->readers == 0)
 		wakeup_one(&rms->writers);
 	mtx_unlock(&rms->mtx);
+	TD_LOCKS_DEC(curthread);
 }
 
 void
@@ -1102,6 +1106,7 @@ rms_runlock(struct rmslock *rms)
 	atomic_interrupt_fence();
 	rms_int_influx_exit(rms, pcpu);
 	critical_exit();
+	TD_LOCKS_DEC(curthread);
 }
 
 struct rmslock_ipi {
@@ -1219,6 +1224,7 @@ out_grab:
 	rms_assert_no_pcpu_readers(rms);
 	mtx_unlock(&rms->mtx);
 	MPASS(rms->readers == 0);
+	TD_LOCKS_INC(curthread);
 }
 
 void
@@ -1239,6 +1245,7 @@ rms_wunlock(struct rmslock *rms)
 		rms->owner = RMS_NOOWNER;
 	}
 	mtx_unlock(&rms->mtx);
+	TD_LOCKS_DEC(curthread);
 }
 
 void