git: b5e502026085 - stable/13 - rmslock: Update td_locks during lock and unlock operations

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 03 Nov 2021 13:15:34 UTC
The branch stable/13 has been updated by markj:

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

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

    rmslock: Update td_locks during lock and unlock operations
    
    Reviewed by:    mjg
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 71f31d784e1816a155cafbccf4b28291200097aa)
---
 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