git: ecb1f465836a - main - cam: Start adding dtrace provider 'cam'

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 08 Jan 2026 06:24:34 UTC
The branch main has been updated by imp:

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

commit ecb1f465836a40c7cdcbcfb67d7d23c36b48c1eb
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2026-01-08 06:19:03 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-01-08 06:19:03 +0000

    cam: Start adding dtrace provider 'cam'
    
    Start to provide robust tracing in cam now that clang has broken my
    fbt-based dtrace scripts a couple of times.
    
    Sponsored by:           Netflix
    Reviewed by:            adrian
    Differential Revision:  https://reviews.freebsd.org/D54468
---
 sys/cam/cam.c |  5 +++++
 sys/cam/cam.h | 14 ++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/sys/cam/cam.c b/sys/cam/cam.c
index 917197542edc..8e70aacba9a9 100644
--- a/sys/cam/cam.c
+++ b/sys/cam/cam.c
@@ -30,9 +30,13 @@
 
 #include <sys/param.h>
 #ifdef _KERNEL
+#include "opt_kdtrace.h"
+
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/memdesc.h>
+#include <sys/queue.h>
+#include <sys/sdt.h>
 #include <sys/sysctl.h>
 #else /* _KERNEL */
 #include <stdlib.h>
@@ -55,6 +59,7 @@
 
 FEATURE(scbus, "SCSI devices support");
 
+SDT_PROVIDER_DEFINE(cam);
 #endif
 
 static int	camstatusentrycomp(const void *key, const void *member);
diff --git a/sys/cam/cam.h b/sys/cam/cam.h
index 83c1fc7b35ca..4d12debdd86f 100644
--- a/sys/cam/cam.h
+++ b/sys/cam/cam.h
@@ -33,6 +33,9 @@
 
 #ifdef _KERNEL
 #include "opt_cam.h"
+/* Only need the hooks here so no opt_kdtrace.h */
+#include <sys/queue.h>
+#include <sys/sdt.h>
 #endif
 
 #ifndef _KERNEL
@@ -374,6 +377,17 @@ extern const struct cam_status_entry cam_status_table[];
 extern const int num_cam_status_entries;
 #ifdef _KERNEL
 extern int cam_sort_io_queues;
+#ifdef SDT_PROVIDER_DECLARE
+SDT_PROVIDER_DECLARE(cam);
+#endif
+#define CAM_PROBE1(group, probe, arg0)				\
+	SDT_PROBE1(cam, , group, probe, arg0)
+#define CAM_PROBE2(group, probe, arg0, arg1)			\
+	SDT_PROBE2(cam, , group, probe, arg0, arg1)
+#define CAM_PROBE3(group, probe, arg0, arg1, arg2)		\
+	SDT_PROBE3(cam, , group, probe, arg0, arg1, arg2)
+#define CAM_PROBE4(group, probe, arg0, arg1, arg2, arg3)	\
+	SDT_PROBE4(cam, , group, probe, arg0, arg1, arg2, arg3)
 #endif
 union ccb;
 struct sbuf;