Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern softint(9): Sprinkle dtrace probes.



details:   https://anonhg.NetBSD.org/src/rev/8d3a9af95f34
branches:  trunk
changeset: 372144:8d3a9af95f34
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Oct 28 21:52:02 2022 +0000

description:
softint(9): Sprinkle dtrace probes.

diffstat:

 sys/kern/kern_softint.c |  49 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 47 insertions(+), 2 deletions(-)

diffs (119 lines):

diff -r da54912ce1ef -r 8d3a9af95f34 sys/kern/kern_softint.c
--- a/sys/kern/kern_softint.c   Fri Oct 28 20:39:23 2022 +0000
+++ b/sys/kern/kern_softint.c   Fri Oct 28 21:52:02 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_softint.c,v 1.71 2022/09/03 02:48:00 thorpej Exp $        */
+/*     $NetBSD: kern_softint.c,v 1.72 2022/10/28 21:52:02 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -170,7 +170,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.71 2022/09/03 02:48:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.72 2022/10/28 21:52:02 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -184,6 +184,7 @@
 #include <sys/cpu.h>
 #include <sys/xcall.h>
 #include <sys/psref.h>
+#include <sys/sdt.h>
 
 #include <uvm/uvm_extern.h>
 
@@ -223,6 +224,31 @@
 static u_int   softint_max;
 static kmutex_t        softint_lock;
 
+SDT_PROBE_DEFINE4(sdt, kernel, softint, establish,
+    "void *"/*sih*/,
+    "void (*)(void *)"/*func*/,
+    "void *"/*arg*/,
+    "unsigned"/*flags*/);
+
+SDT_PROBE_DEFINE1(sdt, kernel, softint, disestablish,
+    "void *"/*sih*/);
+
+SDT_PROBE_DEFINE2(sdt, kernel, softint, schedule,
+    "void *"/*sih*/,
+    "struct cpu_info *"/*ci*/);
+
+SDT_PROBE_DEFINE4(sdt, kernel, softint, entry,
+    "void *"/*sih*/,
+    "void (*)(void *)"/*func*/,
+    "void *"/*arg*/,
+    "unsigned"/*flags*/);
+
+SDT_PROBE_DEFINE4(sdt, kernel, softint, return,
+    "void *"/*sih*/,
+    "void (*)(void *)"/*func*/,
+    "void *"/*arg*/,
+    "unsigned"/*flags*/);
+
 /*
  * softint_init_isr:
  *
@@ -382,6 +408,8 @@
        }
        mutex_exit(&softint_lock);
 
+       SDT_PROBE4(sdt, kernel, softint, establish,  sih, func, arg, flags);
+
        return sih;
 }
 
@@ -425,6 +453,12 @@
         */
        xc_barrier(XC_HIGHPRI_IPL(sh->sh_isr->si_ipl));
 
+       /*
+        * Notify dtrace probe when the old softint can't be running
+        * any more, but before it can be recycled for a new softint.
+        */
+       SDT_PROBE1(sdt, kernel, softint, disestablish,  arg);
+
        /* Clear the handler on each CPU. */
        mutex_enter(&softint_lock);
        for (CPU_INFO_FOREACH(cii, ci)) {
@@ -451,6 +485,8 @@
        uintptr_t offset;
        int s;
 
+       SDT_PROBE2(sdt, kernel, softint, schedule,  arg, /*ci*/NULL);
+
        /*
         * If this assert fires, rather than disabling preemption explicitly
         * to make it stop, consider that you are probably using a softint
@@ -503,6 +539,7 @@
                const uintptr_t offset = (uintptr_t)arg;
                const softhand_t *sh;
 
+               SDT_PROBE2(sdt, kernel, softint, schedule,  arg, ci);
                sh = (const softhand_t *)((const uint8_t *)sc + offset);
                KASSERT((sh->sh_flags & SOFTINT_RCPU) != 0);
                ipi_trigger(sh->sh_ipi_id, ci);
@@ -550,6 +587,10 @@
                splx(s);
 
                /* Run the handler. */
+               SDT_PROBE4(sdt, kernel, softint, entry,
+                   ((const char *)sh -
+                       (const char *)curcpu()->ci_data.cpu_softcpu),
+                   sh->sh_func, sh->sh_arg, sh->sh_flags);
                if (__predict_true((sh->sh_flags & SOFTINT_MPSAFE) != 0)) {
                        (*sh->sh_func)(sh->sh_arg);
                } else {
@@ -557,6 +598,10 @@
                        (*sh->sh_func)(sh->sh_arg);
                        KERNEL_UNLOCK_ONE(l);
                }
+               SDT_PROBE4(sdt, kernel, softint, return,
+                   ((const char *)sh -
+                       (const char *)curcpu()->ci_data.cpu_softcpu),
+                   sh->sh_func, sh->sh_arg, sh->sh_flags);
 
                /* Diagnostic: check that spin-locks have not leaked. */
                KASSERTMSG(curcpu()->ci_mtx_count == 0,



Home | Main Index | Thread Index | Old Index