git: 3ba61343f708 - stable/14 - ktrace: Fix the build when options KTRACE is not configured

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 29 Mar 2024 18:11:44 UTC
The branch stable/14 has been updated by markj:

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

commit 3ba61343f708ba9edabe9e3b2a2e4467bfabd2c9
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-03-09 05:11:01 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-03-29 13:53:05 +0000

    ktrace: Fix the build when options KTRACE is not configured
    
    MFC after:      1 week
    Reported by:    John Nielsen <lists@jnielsen.net>
    
    (cherry picked from commit a58813fd701ea4b248cca0dfab9971d863fbcf6a)
---
 sys/kern/kern_condvar.c | 12 ++++++------
 sys/kern/kern_synch.c   |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c
index 2731f581a29f..e4bd1f926c00 100644
--- a/sys/kern/kern_condvar.c
+++ b/sys/kern/kern_condvar.c
@@ -37,13 +37,13 @@
 #include <sys/proc.h>
 #include <sys/kernel.h>
 #include <sys/ktr.h>
+#include <sys/ktrace.h>
 #include <sys/condvar.h>
 #include <sys/sched.h>
 #include <sys/signalvar.h>
 #include <sys/sleepqueue.h>
 #include <sys/resourcevar.h>
 #ifdef KTRACE
-#include <sys/ktrace.h>
 #include <sys/uio.h>
 #include <sys/user.h>
 #endif
@@ -112,7 +112,7 @@ _cv_wait(struct cv *cvp, struct lock_object *lock)
 	char wmesg[WMESGLEN + 1];
 #endif
 	struct lock_class *class;
-	struct thread *td;
+	struct thread *td __ktrace_used;
 	uintptr_t lock_state;
 
 	td = curthread;
@@ -174,7 +174,7 @@ _cv_wait_unlock(struct cv *cvp, struct lock_object *lock)
 	char wmesg[WMESGLEN + 1];
 #endif
 	struct lock_class *class;
-	struct thread *td;
+	struct thread *td __ktrace_used;
 
 	td = curthread;
 	CV_ASSERT(cvp, lock, td);
@@ -232,7 +232,7 @@ _cv_wait_sig(struct cv *cvp, struct lock_object *lock)
 	char wmesg[WMESGLEN + 1];
 #endif
 	struct lock_class *class;
-	struct thread *td;
+	struct thread *td __ktrace_used;
 	uintptr_t lock_state;
 	int rval;
 
@@ -301,7 +301,7 @@ _cv_timedwait_sbt(struct cv *cvp, struct lock_object *lock, sbintime_t sbt,
 	char wmesg[WMESGLEN + 1];
 #endif
 	struct lock_class *class;
-	struct thread *td;
+	struct thread *td __ktrace_used;
 	int lock_state, rval;
 
 	td = curthread;
@@ -371,7 +371,7 @@ _cv_timedwait_sig_sbt(struct cv *cvp, struct lock_object *lock,
 	char wmesg[WMESGLEN + 1];
 #endif
 	struct lock_class *class;
-	struct thread *td;
+	struct thread *td __ktrace_used;
 	int lock_state, rval;
 
 	td = curthread;
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 9f11e9b3ed08..2241162f33ab 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -47,6 +47,7 @@
 #include <sys/kdb.h>
 #include <sys/kernel.h>
 #include <sys/ktr.h>
+#include <sys/ktrace.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/proc.h>
@@ -62,7 +63,6 @@
 #include <sys/vmmeter.h>
 #ifdef KTRACE
 #include <sys/uio.h>
-#include <sys/ktrace.h>
 #endif
 #ifdef EPOCH_TRACE
 #include <sys/epoch.h>
@@ -133,7 +133,7 @@ int
 _sleep(const void *ident, struct lock_object *lock, int priority,
     const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags)
 {
-	struct thread *td;
+	struct thread *td __ktrace_used;
 	struct lock_class *class;
 	uintptr_t lock_state;
 	int catch, pri, rval, sleepq_flags;
@@ -240,7 +240,7 @@ int
 msleep_spin_sbt(const void *ident, struct mtx *mtx, const char *wmesg,
     sbintime_t sbt, sbintime_t pr, int flags)
 {
-	struct thread *td;
+	struct thread *td __ktrace_used;
 	int rval;
 	WITNESS_SAVE_DECL(mtx);