Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern callout(9): Sprinkle dtrace probes.
details: https://anonhg.NetBSD.org/src/rev/f46ea0681704
branches: trunk
changeset: 372146:f46ea0681704
user: riastradh <riastradh%NetBSD.org@localhost>
date: Fri Oct 28 21:53:26 2022 +0000
description:
callout(9): Sprinkle dtrace probes.
diffstat:
sys/kern/kern_timeout.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 82 insertions(+), 2 deletions(-)
diffs (219 lines):
diff -r c2efe7927633 -r f46ea0681704 sys/kern/kern_timeout.c
--- a/sys/kern/kern_timeout.c Fri Oct 28 21:52:22 2022 +0000
+++ b/sys/kern/kern_timeout.c Fri Oct 28 21:53:26 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_timeout.c,v 1.71 2022/10/28 21:52:22 riastradh Exp $ */
+/* $NetBSD: kern_timeout.c,v 1.72 2022/10/28 21:53:26 riastradh Exp $ */
/*-
* Copyright (c) 2003, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.71 2022/10/28 21:52:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.72 2022/10/28 21:53:26 riastradh Exp $");
/*
* Timeouts are kept in a hierarchical timing wheel. The c_time is the
@@ -96,6 +96,7 @@
#include <sys/intr.h>
#include <sys/cpu.h>
#include <sys/kmem.h>
+#include <sys/sdt.h>
#ifdef DDB
#include <machine/db_machdep.h>
@@ -180,6 +181,7 @@
struct callout_circq cc_wheel[BUCKETS]; /* Queues of timeouts */
char cc_name1[12];
char cc_name2[12];
+ struct cpu_info *cc_cpu;
};
#ifdef DDB
@@ -193,6 +195,57 @@
static struct callout_cpu callout_cpu0 __cacheline_aligned;
static void *callout_sih __read_mostly;
+SDT_PROBE_DEFINE2(sdt, kernel, callout, init,
+ "struct callout *"/*ch*/,
+ "unsigned"/*flags*/);
+SDT_PROBE_DEFINE1(sdt, kernel, callout, destroy,
+ "struct callout *"/*ch*/);
+SDT_PROBE_DEFINE4(sdt, kernel, callout, setfunc,
+ "struct callout *"/*ch*/,
+ "void (*)(void *)"/*func*/,
+ "void *"/*arg*/,
+ "unsigned"/*flags*/);
+SDT_PROBE_DEFINE5(sdt, kernel, callout, schedule,
+ "struct callout *"/*ch*/,
+ "void (*)(void *)"/*func*/,
+ "void *"/*arg*/,
+ "unsigned"/*flags*/,
+ "int"/*ticks*/);
+SDT_PROBE_DEFINE6(sdt, kernel, callout, migrate,
+ "struct callout *"/*ch*/,
+ "void (*)(void *)"/*func*/,
+ "void *"/*arg*/,
+ "unsigned"/*flags*/,
+ "struct cpu_info *"/*ocpu*/,
+ "struct cpu_info *"/*ncpu*/);
+SDT_PROBE_DEFINE4(sdt, kernel, callout, entry,
+ "struct callout *"/*ch*/,
+ "void (*)(void *)"/*func*/,
+ "void *"/*arg*/,
+ "unsigned"/*flags*/);
+SDT_PROBE_DEFINE4(sdt, kernel, callout, return,
+ "struct callout *"/*ch*/,
+ "void (*)(void *)"/*func*/,
+ "void *"/*arg*/,
+ "unsigned"/*flags*/);
+SDT_PROBE_DEFINE5(sdt, kernel, callout, stop,
+ "struct callout *"/*ch*/,
+ "void (*)(void *)"/*func*/,
+ "void *"/*arg*/,
+ "unsigned"/*flags*/,
+ "bool"/*expired*/);
+SDT_PROBE_DEFINE4(sdt, kernel, callout, halt,
+ "struct callout *"/*ch*/,
+ "void (*)(void *)"/*func*/,
+ "void *"/*arg*/,
+ "unsigned"/*flags*/);
+SDT_PROBE_DEFINE5(sdt, kernel, callout, halt__done,
+ "struct callout *"/*ch*/,
+ "void (*)(void *)"/*func*/,
+ "void *"/*arg*/,
+ "unsigned"/*flags*/,
+ "bool"/*expired*/);
+
static inline kmutex_t *
callout_lock(callout_impl_t *c)
{
@@ -270,6 +323,7 @@
evcnt_attach_dynamic(&cc->cc_ev_block, EVCNT_TYPE_MISC,
NULL, "callout", cc->cc_name2);
+ cc->cc_cpu = ci;
ci->ci_data.cpu_callout = cc;
}
@@ -287,6 +341,8 @@
KASSERT((flags & ~CALLOUT_FLAGMASK) == 0);
+ SDT_PROBE2(sdt, kernel, callout, init, cs, flags);
+
cc = curcpu()->ci_data.cpu_callout;
c->c_func = NULL;
c->c_magic = CALLOUT_MAGIC;
@@ -309,6 +365,8 @@
{
callout_impl_t *c = (callout_impl_t *)cs;
+ SDT_PROBE1(sdt, kernel, callout, destroy, cs);
+
KASSERTMSG(c->c_magic == CALLOUT_MAGIC,
"callout %p: c_magic (%#x) != CALLOUT_MAGIC (%#x)",
c, c->c_magic, CALLOUT_MAGIC);
@@ -339,6 +397,9 @@
struct callout_cpu *cc, *occ;
int old_time;
+ SDT_PROBE5(sdt, kernel, callout, schedule,
+ c, c->c_func, c->c_arg, c->c_flags, to_ticks);
+
KASSERT(to_ticks >= 0);
KASSERT(c->c_func != NULL);
@@ -377,6 +438,9 @@
c->c_flags |= CALLOUT_PENDING;
CIRCQ_INSERT(&c->c_list, &cc->cc_todo);
mutex_spin_exit(cc->cc_lock);
+ SDT_PROBE6(sdt, kernel, callout, migrate,
+ c, c->c_func, c->c_arg, c->c_flags,
+ occ->cc_cpu, cc->cc_cpu);
}
mutex_spin_exit(lock);
}
@@ -397,6 +461,7 @@
KASSERT(func != NULL);
lock = callout_lock(c);
+ SDT_PROBE4(sdt, kernel, callout, setfunc, cs, func, arg, c->c_flags);
c->c_func = func;
c->c_arg = arg;
callout_schedule_locked(c, lock, to_ticks);
@@ -454,6 +519,9 @@
cc->cc_cancel = c;
}
+ SDT_PROBE5(sdt, kernel, callout, stop,
+ c, c->c_func, c->c_arg, c->c_flags, expired);
+
mutex_spin_exit(lock);
return expired;
@@ -482,6 +550,8 @@
/* Fast path. */
lock = callout_lock(c);
+ SDT_PROBE4(sdt, kernel, callout, halt,
+ c, c->c_func, c->c_arg, c->c_flags);
flags = c->c_flags;
if ((flags & CALLOUT_PENDING) != 0)
CIRCQ_REMOVE(&c->c_list);
@@ -490,6 +560,8 @@
callout_wait(c, interlock, lock);
return true;
}
+ SDT_PROBE5(sdt, kernel, callout, halt__done,
+ c, c->c_func, c->c_arg, c->c_flags, /*expired*/false);
mutex_spin_exit(lock);
return false;
}
@@ -557,6 +629,9 @@
c->c_flags &= ~(CALLOUT_PENDING|CALLOUT_FIRED);
}
+ SDT_PROBE5(sdt, kernel, callout, halt__done,
+ c, c->c_func, c->c_arg, c->c_flags, /*expired*/true);
+
mutex_spin_exit(lock);
if (__predict_false(relock != NULL))
mutex_enter(relock);
@@ -611,6 +686,7 @@
KASSERT(func != NULL);
lock = callout_lock(c);
+ SDT_PROBE4(sdt, kernel, callout, setfunc, cs, func, arg, c->c_flags);
c->c_func = func;
c->c_arg = arg;
mutex_spin_exit(lock);
@@ -741,6 +817,7 @@
void (*func)(void *);
void *arg;
int mpsafe, count, ticks, delta;
+ u_int flags;
lwp_t *l;
l = curlwp;
@@ -774,15 +851,18 @@
func = c->c_func;
arg = c->c_arg;
cc->cc_active = c;
+ flags = c->c_flags;
mutex_spin_exit(cc->cc_lock);
KASSERT(func != NULL);
+ SDT_PROBE4(sdt, kernel, callout, entry, c, func, arg, flags);
if (__predict_false(!mpsafe)) {
KERNEL_LOCK(1, NULL);
(*func)(arg);
KERNEL_UNLOCK_ONE(NULL);
} else
(*func)(arg);
+ SDT_PROBE4(sdt, kernel, callout, return, c, func, arg, flags);
KASSERTMSG(l->l_blcnt == 0,
"callout %p func %p leaked %d biglocks",
c, func, l->l_blcnt);
Home |
Main Index |
Thread Index |
Old Index