4 * Copyright (c) 2011-2012 Alexander Leidinger <netchild@FreeBSD.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer
12 * in this position and unchanged.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * Trace futex operations:
34 * - size of the futex list
35 * - report error conditions (emulation errors, kernel errors,
37 * - execution time (wallclock) of futex related functions
40 #pragma D option specsize=32m
42 /* Error conditions */
43 linuxulator*:futex:futex_get:error,
44 linuxulator*:futex:futex_sleep:requeue_error,
45 linuxulator*:futex:futex_sleep:sleep_error,
46 linuxulator*:futex:futex_wait:copyin_error,
47 linuxulator*:futex:futex_wait:itimerfix_error,
48 linuxulator*:futex:futex_wait:sleep_error,
49 linuxulator*:futex:futex_atomic_op:missing_access_check,
50 linuxulator*:futex:futex_atomic_op:unimplemented_op,
51 linuxulator*:futex:futex_atomic_op:unimplemented_cmp,
52 linuxulator*:futex:linux_sys_futex:unimplemented_clockswitch,
53 linuxulator*:futex:linux_sys_futex:copyin_error,
54 linuxulator*:futex:linux_sys_futex:unhandled_efault,
55 linuxulator*:futex:linux_sys_futex:unimplemented_lock_pi,
56 linuxulator*:futex:linux_sys_futex:unimplemented_unlock_pi,
57 linuxulator*:futex:linux_sys_futex:unimplemented_trylock_pi,
58 linuxulator*:futex:linux_sys_futex:unimplemented_wait_requeue_pi,
59 linuxulator*:futex:linux_sys_futex:unimplemented_cmp_requeue_pi,
60 linuxulator*:futex:linux_sys_futex:unknown_operation,
61 linuxulator*:futex:linux_get_robust_list:copyout_error,
62 linuxulator*:futex:handle_futex_death:copyin_error,
63 linuxulator*:futex:fetch_robust_entry:copyin_error,
64 linuxulator*:futex:release_futexes:copyin_error
66 printf("ERROR: %s in %s:%s:%s\n", probename, probeprov, probemod,
72 linuxulator*:futex:linux_sys_futex:invalid_cmp_requeue_use,
73 linuxulator*:futex:linux_sys_futex:deprecated_requeue,
74 linuxulator*:futex:linux_set_robust_list:size_error
76 printf("WARNING: %s:%s:%s:%s in application %s, maybe an application error?\n",
77 probename, probeprov, probemod, probefunc, execname);
83 /* Per futex checks/statistics */
85 linuxulator*:futex:futex:create
88 @max_futexes = max(futex_count);
91 linuxulator*:futex:futex:destroy
94 printf("ERROR: Request to destroy a futex which was not created,\n");
95 printf(" or this script was started after some futexes where\n");
96 printf(" created. Stack trace:\n");
101 linuxulator*:futex:futex:destroy
109 linuxulator*:locks:futex_mtx:locked
111 ++check[probefunc, arg0];
112 @stats[probefunc] = count();
114 ts[probefunc] = timestamp;
115 spec[probefunc] = speculation();
116 printf("Stacktrace of last lock operation of the %s:\n", probefunc);
120 linuxulator*:locks:futex_mtx:unlock
121 /check[probefunc, arg0] == 0/
123 printf("ERROR: unlock attemt of unlocked %s (%p),", probefunc, arg0);
124 printf(" missing SDT probe in kernel, or dtrace program started");
125 printf(" while the %s was already held (race condition).", probefunc);
126 printf(" Stack trace follows:");
130 linuxulator*:locks:futex_mtx:unlock
132 discard(spec[probefunc]);
134 --check[probefunc, arg0];
137 /* Timeout handling for internal locks */
140 /spec["futex_mtx"] != 0 && timestamp - ts["futex_mtx"] >= 9999999000/
142 commit(spec["futex_mtx"]);
143 spec["futex_mtx"] = 0;
147 /* Timing statistings */
149 linuxulator*:futex::entry
151 self->time[probefunc] = timestamp;
152 @calls[probeprov, execname, probefunc] = count();
155 linuxulator*:futex::return
156 /self->time[probefunc] != 0/
158 this->timediff = self->time[probefunc] - timestamp;
160 @timestats[probeprov, execname, probefunc] = quantize(this->timediff);
161 @longest[probeprov, probefunc] = max(this->timediff);
163 self->time[probefunc] = 0;
171 printf("Number of locks per type:");
173 printf("Number of maximum number of futexes in the futex list:");
174 printa(@max_futexes);
175 printf("Number of futexes still existing: %d", futex_count);
176 printf("Number of calls per provider/application/kernel function:");
178 printf("Wallclock-timing statistics per provider/application/kernel function (in ns):");
180 printf("Longest running (wallclock!) functions per provider (in ns):");