Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern devsw(9): Sprinkle dtrace probes on bdevsw, cdevsw ...
details: https://anonhg.NetBSD.org/src/rev/cddc13c8e94a
branches: trunk
changeset: 372164:cddc13c8e94a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Oct 29 10:52:36 2022 +0000
description:
devsw(9): Sprinkle dtrace probes on bdevsw, cdevsw calls.
This is better than fbt-tracing the bdev_* and cdev_* functions
because this way we can reliably get at the struct bdevsw/cdevsw
pointer after lookup and get at return values.
diffstat:
sys/kern/subr_devsw.c | 294 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 290 insertions(+), 4 deletions(-)
diffs (truncated from 485 to 300 lines):
diff -r dd6926ca644c -r cddc13c8e94a sys/kern/subr_devsw.c
--- a/sys/kern/subr_devsw.c Sat Oct 29 08:52:47 2022 +0000
+++ b/sys/kern/subr_devsw.c Sat Oct 29 10:52:36 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_devsw.c,v 1.48 2022/08/28 12:24:39 riastradh Exp $ */
+/* $NetBSD: subr_devsw.c,v 1.49 2022/10/29 10:52:36 riastradh Exp $ */
/*-
* Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.48 2022/08/28 12:24:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.49 2022/10/29 10:52:36 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_dtrace.h"
@@ -125,6 +125,248 @@
void (*biodone_vfs)(buf_t *) = (void *)nullop;
+/*
+ * bdev probes
+ */
+SDT_PROBE_DEFINE6(sdt, bdev, open, acquire,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/,
+ "int"/*unit*/,
+ "device_t"/*dv*/);
+SDT_PROBE_DEFINE4(sdt, bdev, open, entry,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/);
+SDT_PROBE_DEFINE5(sdt, bdev, open, return,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/,
+ "int"/*error*/);
+SDT_PROBE_DEFINE6(sdt, bdev, open, release,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/,
+ "int"/*unit*/,
+ "device_t"/*dv*/);
+
+SDT_PROBE_DEFINE4(sdt, bdev, cancel, entry,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/);
+SDT_PROBE_DEFINE5(sdt, bdev, cancel, return,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/,
+ "int"/*error*/);
+
+SDT_PROBE_DEFINE4(sdt, bdev, close, entry,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/);
+SDT_PROBE_DEFINE5(sdt, bdev, close, return,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/,
+ "int"/*error*/);
+
+SDT_PROBE_DEFINE3(sdt, bdev, strategy, entry,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "struct buf *"/*bp*/);
+SDT_PROBE_DEFINE3(sdt, bdev, strategy, return,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "struct buf *"/*bp*/);
+
+SDT_PROBE_DEFINE5(sdt, bdev, ioctl, entry,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "unsigned long"/*cmd*/,
+ "void *"/*data*/,
+ "int"/*flag*/);
+SDT_PROBE_DEFINE6(sdt, bdev, ioctl, return,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "unsigned long"/*cmd*/,
+ "void *"/*data*/,
+ "int"/*flag*/,
+ "int"/*error*/);
+
+SDT_PROBE_DEFINE2(sdt, bdev, psize, entry,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/);
+SDT_PROBE_DEFINE3(sdt, bdev, psize, return,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*psize*/);
+
+SDT_PROBE_DEFINE4(sdt, bdev, discard, entry,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "off_t"/*pos*/,
+ "off_t"/*len*/);
+SDT_PROBE_DEFINE5(sdt, bdev, discard, return,
+ "struct bdevsw *"/*bdevsw*/,
+ "dev_t"/*dev*/,
+ "off_t"/*pos*/,
+ "off_t"/*len*/,
+ "int"/*error*/);
+
+/*
+ * cdev probes
+ */
+SDT_PROBE_DEFINE6(sdt, cdev, open, acquire,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/,
+ "int"/*unit*/,
+ "device_t"/*dv*/);
+SDT_PROBE_DEFINE4(sdt, cdev, open, entry,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/);
+SDT_PROBE_DEFINE5(sdt, cdev, open, return,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/,
+ "int"/*error*/);
+SDT_PROBE_DEFINE6(sdt, cdev, open, release,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/,
+ "int"/*unit*/,
+ "device_t"/*dv*/);
+
+SDT_PROBE_DEFINE4(sdt, cdev, cancel, entry,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/);
+SDT_PROBE_DEFINE5(sdt, cdev, cancel, return,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/,
+ "int"/*error*/);
+
+SDT_PROBE_DEFINE4(sdt, cdev, close, entry,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/);
+SDT_PROBE_DEFINE5(sdt, cdev, close, return,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*flag*/,
+ "int"/*devtype*/,
+ "int"/*error*/);
+
+SDT_PROBE_DEFINE4(sdt, cdev, read, entry,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "struct uio *"/*uio*/,
+ "int"/*flag*/);
+SDT_PROBE_DEFINE5(sdt, cdev, read, return,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "struct uio *"/*uio*/,
+ "int"/*flag*/,
+ "int"/*error*/);
+
+SDT_PROBE_DEFINE4(sdt, cdev, write, entry,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "struct uio *"/*uio*/,
+ "int"/*flag*/);
+SDT_PROBE_DEFINE5(sdt, cdev, write, return,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "struct uio *"/*uio*/,
+ "int"/*flag*/,
+ "int"/*error*/);
+
+SDT_PROBE_DEFINE5(sdt, cdev, ioctl, entry,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "unsigned long"/*cmd*/,
+ "void *"/*data*/,
+ "int"/*flag*/);
+SDT_PROBE_DEFINE6(sdt, cdev, ioctl, return,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "unsigned long"/*cmd*/,
+ "void *"/*data*/,
+ "int"/*flag*/,
+ "int"/*error*/);
+
+SDT_PROBE_DEFINE4(sdt, cdev, stop, entry,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "struct tty *"/*tp*/,
+ "int"/*flag*/);
+SDT_PROBE_DEFINE4(sdt, cdev, stop, return,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "struct tty *"/*tp*/,
+ "int"/*flag*/);
+
+SDT_PROBE_DEFINE3(sdt, cdev, poll, entry,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*events*/);
+SDT_PROBE_DEFINE4(sdt, cdev, poll, return,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "int"/*events*/,
+ "int"/*revents*/);
+
+SDT_PROBE_DEFINE4(sdt, cdev, mmap, entry,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "off_t"/*off*/,
+ "int"/*flag*/);
+SDT_PROBE_DEFINE5(sdt, cdev, mmap, return,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "off_t"/*off*/,
+ "int"/*flag*/,
+ "paddr_t"/*mmapcookie*/);
+
+SDT_PROBE_DEFINE3(sdt, cdev, kqfilter, entry,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "struct knote *"/*kn*/);
+SDT_PROBE_DEFINE4(sdt, cdev, kqfilter, return,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "struct knote *"/*kn*/,
+ "int"/*error*/);
+
+SDT_PROBE_DEFINE4(sdt, cdev, discard, entry,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "off_t"/*pos*/,
+ "off_t"/*len*/);
+SDT_PROBE_DEFINE5(sdt, cdev, discard, return,
+ "struct cdevsw *"/*cdevsw*/,
+ "dev_t"/*dev*/,
+ "off_t"/*pos*/,
+ "off_t"/*len*/,
+ "int"/*error*/);
+
void
devsw_init(void)
{
@@ -922,7 +1164,7 @@
const struct bdevsw *d;
struct localcount *lc;
device_t dv = NULL/*XXXGCC*/;
- int unit, rv, mpflag;
+ int unit = -1/*XXXGCC*/, rv, mpflag;
d = bdevsw_lookup_acquire(dev, &lc);
if (d == NULL)
@@ -943,13 +1185,19 @@
return ENXIO;
if ((dv = device_lookup_acquire(d->d_cfdriver, unit)) == NULL)
return ENXIO;
+ SDT_PROBE6(sdt, bdev, open, acquire,
+ d, dev, flag, devtype, unit, dv);
}
DEV_LOCK(d);
+ SDT_PROBE4(sdt, bdev, open, entry, d, dev, flag, devtype);
rv = (*d->d_open)(dev, flag, devtype, l);
+ SDT_PROBE5(sdt, bdev, open, return, d, dev, flag, devtype, rv);
DEV_UNLOCK(d);
if (d->d_devtounit) {
+ SDT_PROBE6(sdt, bdev, open, release,
+ d, dev, flag, devtype, unit, dv);
device_release(dv);
}
@@ -970,7 +1218,9 @@
return ENODEV;
DEV_LOCK(d);
Home |
Main Index |
Thread Index |
Old Index