Module Name:    src
Committed By:   riastradh
Date:           Wed Feb 19 16:05:41 UTC 2020

Modified Files:
        src/sys/dev/scsipi: scsipi_base.c
Added Files:
        src/sys/dev/scsipi: scsi_sdt.h

Log Message:
Sprinkle some dtrace probes into scsi(4).


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/scsipi/scsi_sdt.h
cvs rdiff -u -r1.184 -r1.185 src/sys/dev/scsipi/scsipi_base.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/scsipi/scsipi_base.c
diff -u src/sys/dev/scsipi/scsipi_base.c:1.184 src/sys/dev/scsipi/scsipi_base.c:1.185
--- src/sys/dev/scsipi/scsipi_base.c:1.184	Sun Nov 10 21:16:37 2019
+++ src/sys/dev/scsipi/scsipi_base.c	Wed Feb 19 16:05:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsipi_base.c,v 1.184 2019/11/10 21:16:37 chs Exp $	*/
+/*	$NetBSD: scsipi_base.c,v 1.185 2020/02/19 16:05:41 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.184 2019/11/10 21:16:37 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.185 2020/02/19 16:05:41 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -51,6 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: scsipi_base.
 #include <sys/hash.h>
 #include <sys/atomic.h>
 
+#include <dev/scsipi/scsi_sdt.h>
 #include <dev/scsipi/scsi_spc.h>
 #include <dev/scsipi/scsipi_all.h>
 #include <dev/scsipi/scsipi_disk.h>
@@ -62,6 +63,38 @@ __KERNEL_RCSID(0, "$NetBSD: scsipi_base.
 
 #include <machine/param.h>
 
+SDT_PROVIDER_DEFINE(scsi);
+
+SDT_PROBE_DEFINE3(scsi, base, tag, get,
+    "struct scsipi_xfer *"/*xs*/, "uint8_t"/*tag*/, "uint8_t"/*type*/);
+SDT_PROBE_DEFINE3(scsi, base, tag, put,
+    "struct scsipi_xfer *"/*xs*/, "uint8_t"/*tag*/, "uint8_t"/*type*/);
+
+SDT_PROBE_DEFINE3(scsi, base, adapter, request__start,
+    "struct scsipi_channel *"/*chan*/,
+    "scsipi_adapter_req_t"/*req*/,
+    "void *"/*arg*/);
+SDT_PROBE_DEFINE3(scsi, base, adapter, request__done,
+    "struct scsipi_channel *"/*chan*/,
+    "scsipi_adapter_req_t"/*req*/,
+    "void *"/*arg*/);
+
+SDT_PROBE_DEFINE1(scsi, base, queue, batch__start,
+    "struct scsipi_channel *"/*chan*/);
+SDT_PROBE_DEFINE2(scsi, base, queue, run,
+    "struct scsipi_channel *"/*chan*/,
+    "struct scsipi_xfer *"/*xs*/);
+SDT_PROBE_DEFINE1(scsi, base, queue, batch__done,
+    "struct scsipi_channel *"/*chan*/);
+
+SDT_PROBE_DEFINE1(scsi, base, xfer, execute,  "struct scsipi_xfer *"/*xs*/);
+SDT_PROBE_DEFINE1(scsi, base, xfer, enqueue,  "struct scsipi_xfer *"/*xs*/);
+SDT_PROBE_DEFINE1(scsi, base, xfer, done,  "struct scsipi_xfer *"/*xs*/);
+SDT_PROBE_DEFINE1(scsi, base, xfer, redone,  "struct scsipi_xfer *"/*xs*/);
+SDT_PROBE_DEFINE1(scsi, base, xfer, complete,  "struct scsipi_xfer *"/*xs*/);
+SDT_PROBE_DEFINE1(scsi, base, xfer, restart,  "struct scsipi_xfer *"/*xs*/);
+SDT_PROBE_DEFINE1(scsi, base, xfer, free,  "struct scsipi_xfer *"/*xs*/);
+
 static int	scsipi_complete(struct scsipi_xfer *);
 static void	scsipi_request_sense(struct scsipi_xfer *);
 static int	scsipi_enqueue(struct scsipi_xfer *);
@@ -378,6 +411,8 @@ scsipi_get_tag(struct scsipi_xfer *xs)
 	}
 
 	xs->xs_tag_id = tag;
+	SDT_PROBE3(scsi, base, tag, get,
+	    xs, xs->xs_tag_id, xs->xs_tag_type);
 }
 
 /*
@@ -395,6 +430,9 @@ scsipi_put_tag(struct scsipi_xfer *xs)
 
 	KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
 
+	SDT_PROBE3(scsi, base, tag, put,
+	    xs, xs->xs_tag_id, xs->xs_tag_type);
+
 	word = xs->xs_tag_id >> 5;
 	bit = xs->xs_tag_id & 0x1f;
 
@@ -541,6 +579,7 @@ scsipi_put_xs(struct scsipi_xfer *xs)
 	struct scsipi_periph *periph = xs->xs_periph;
 	int flags = xs->xs_control;
 
+	SDT_PROBE1(scsi, base, xfer, free,  xs);
 	SC_DEBUG(periph, SCSIPI_DB3, ("scsipi_free_xs\n"));
 	KASSERT(mutex_owned(chan_mtx(periph->periph_channel)));
 
@@ -1559,6 +1598,7 @@ scsipi_done(struct scsipi_xfer *xs)
 #endif
 
 	mutex_enter(chan_mtx(chan));
+	SDT_PROBE1(scsi, base, xfer, done,  xs);
 	/*
 	 * The resource this command was using is now free.
 	 */
@@ -1573,6 +1613,7 @@ scsipi_done(struct scsipi_xfer *xs)
 		 * that this won't ever happen (and can be turned into
 		 * a KASSERT().
 		 */
+		SDT_PROBE1(scsi, base, xfer, redone,  xs);
 		mutex_exit(chan_mtx(chan));
 		goto out;
 	}
@@ -1704,6 +1745,8 @@ scsipi_complete(struct scsipi_xfer *xs)
 	struct scsipi_channel *chan = periph->periph_channel;
 	int error;
 
+	SDT_PROBE1(scsi, base, xfer, complete,  xs);
+
 #ifdef DIAGNOSTIC
 	if ((xs->xs_control & XS_CTL_ASYNC) != 0 && xs->bp == NULL)
 		panic("scsipi_complete: XS_CTL_ASYNC but no buf");
@@ -1872,6 +1915,7 @@ scsipi_complete(struct scsipi_xfer *xs)
 
 	mutex_enter(chan_mtx(chan));
 	if (error == ERESTART) {
+		SDT_PROBE1(scsi, base, xfer, restart,  xs);
 		/*
 		 * If we get here, the periph has been thawed and frozen
 		 * again if we had to issue recovery commands.  Alternatively,
@@ -1981,6 +2025,8 @@ scsipi_enqueue(struct scsipi_xfer *xs)
 	struct scsipi_channel *chan = xs->xs_periph->periph_channel;
 	struct scsipi_xfer *qxs;
 
+	SDT_PROBE1(scsi, base, xfer, enqueue,  xs);
+
 	/*
 	 * If the xfer is to be polled, and there are already jobs on
 	 * the queue, we can't proceed.
@@ -2042,6 +2088,7 @@ scsipi_run_queue(struct scsipi_channel *
 	struct scsipi_xfer *xs;
 	struct scsipi_periph *periph;
 
+	SDT_PROBE1(scsi, base, queue, batch__start,  chan);
 	for (;;) {
 		mutex_enter(chan_mtx(chan));
 
@@ -2051,7 +2098,7 @@ scsipi_run_queue(struct scsipi_channel *
 		 */
 		if (chan->chan_qfreeze != 0) {
 			mutex_exit(chan_mtx(chan));
-			return;
+			break;
 		}
 
 		/*
@@ -2081,7 +2128,7 @@ scsipi_run_queue(struct scsipi_channel *
 		 * Can't find any work to do right now.
 		 */
 		mutex_exit(chan_mtx(chan));
-		return;
+		break;
 
  got_one:
 		/*
@@ -2111,7 +2158,7 @@ scsipi_run_queue(struct scsipi_channel *
 				 * XXX: We should be able to note that
 				 * XXX: that resources are needed here!
 				 */
-				return;
+				break;
 			}
 			/*
 			 * scsipi_grow_resources() allocated the resource
@@ -2135,11 +2182,10 @@ scsipi_run_queue(struct scsipi_channel *
 		periph->periph_sent++;
 		mutex_exit(chan_mtx(chan));
 
+		SDT_PROBE2(scsi, base, queue, run,  chan, xs);
 		scsipi_adapter_request(chan, ADAPTER_REQ_RUN_XFER, xs);
 	}
-#ifdef DIAGNOSTIC
-	panic("scsipi_run_queue: impossible");
-#endif
+	SDT_PROBE1(scsi, base, queue, batch__done,  chan);
 }
 
 /*
@@ -2164,6 +2210,7 @@ scsipi_execute_xs(struct scsipi_xfer *xs
 	xs->error = XS_NOERROR;
 	xs->resid = xs->datalen;
 	xs->status = SCSI_OK;
+	SDT_PROBE1(scsi, base, xfer, execute,  xs);
 
 #ifdef SCSIPI_DEBUG
 	if (xs->xs_periph->periph_dbflags & SCSIPI_DB3) {
@@ -2783,7 +2830,9 @@ scsipi_adapter_request(struct scsipi_cha
 	struct scsipi_adapter *adapt = chan->chan_adapter;
 
 	scsipi_adapter_lock(adapt);
+	SDT_PROBE3(scsi, base, adapter, request__start,  chan, req, arg);
 	(adapt->adapt_request)(chan, req, arg);
+	SDT_PROBE3(scsi, base, adapter, request__done,  chan, req, arg);
 	scsipi_adapter_unlock(adapt);
 }
 

Added files:

Index: src/sys/dev/scsipi/scsi_sdt.h
diff -u /dev/null src/sys/dev/scsipi/scsi_sdt.h:1.1
--- /dev/null	Wed Feb 19 16:05:41 2020
+++ src/sys/dev/scsipi/scsi_sdt.h	Wed Feb 19 16:05:41 2020
@@ -0,0 +1,36 @@
+/*	$NetBSD: scsi_sdt.h,v 1.1 2020/02/19 16:05:41 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef	_DEV_SCSIPI_SCSI_SDT_H_
+#define	_DEV_SCSIPI_SCSI_SDT_H_
+
+#include <sys/sdt.h>
+
+SDT_PROVIDER_DECLARE(scsi);
+
+#endif	/* _DEV_SCSIPI_SCSI_SDT_H_ */

Reply via email to