xref: /freebsd/cddl/contrib/opensolaris/cmd/lockstat/lockstat.1 (revision f53355131f65d64e7643d734dbcd4fb2a5de20ed)
17e1e3d94SStacey Son'\" te
27e1e3d94SStacey Son.\" CDDL HEADER START
37e1e3d94SStacey Son.\"
47e1e3d94SStacey Son.\" The contents of this file are subject to the terms of the
57e1e3d94SStacey Son.\" Common Development and Distribution License (the "License").
67e1e3d94SStacey Son.\" You may not use this file except in compliance with the License.
77e1e3d94SStacey Son.\"
87e1e3d94SStacey Son.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97e1e3d94SStacey Son.\" or http://www.opensolaris.org/os/licensing.
107e1e3d94SStacey Son.\" See the License for the specific language governing permissions
117e1e3d94SStacey Son.\" and limitations under the License.
127e1e3d94SStacey Son.\"
137e1e3d94SStacey Son.\" When distributing Covered Code, include this CDDL HEADER in each
147e1e3d94SStacey Son.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157e1e3d94SStacey Son.\" If applicable, add the following below this CDDL HEADER, with the
167e1e3d94SStacey Son.\" fields enclosed by brackets "[]" replaced with your own identifying
177e1e3d94SStacey Son.\" information: Portions Copyright [yyyy] [name of copyright owner]
187e1e3d94SStacey Son.\"
197e1e3d94SStacey Son.\" CDDL HEADER END
207e1e3d94SStacey Son.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
21a10f58d0SMark Johnston.\"
22*932a690cSGordon Bergling.Dd February 25, 2020
23a10f58d0SMark Johnston.Dt LOCKSTAT 1
24a10f58d0SMark Johnston.Os
25a10f58d0SMark Johnston.Sh NAME
26a10f58d0SMark Johnston.Nm lockstat
27a10f58d0SMark Johnston.Nd report kernel lock and profiling statistics
28a10f58d0SMark Johnston.Sh SYNOPSIS
29a10f58d0SMark Johnston.Nm
309b055b74SMark Johnston.Op Fl ACEHIV
31a10f58d0SMark Johnston.Op Fl e Ar event-list
32a10f58d0SMark Johnston.Op Fl i Ar rate
33a10f58d0SMark Johnston.Op Fl b | t | h | s Ar depth
34a10f58d0SMark Johnston.Op Fl n Ar num-records
35a10f58d0SMark Johnston.Op Fl l Ar lock Oo Ns , Ns Ar size Oc
36a10f58d0SMark Johnston.Op Fl d Ar duration
37a10f58d0SMark Johnston.Op Fl f Ar function Oo Ns , Ns Ar size Oc
38a10f58d0SMark Johnston.Op Fl T
393142b376SMark Johnston.Op Fl kgwWRpP
40a10f58d0SMark Johnston.Op Fl D Ar count
41a10f58d0SMark Johnston.Op Fl o filename
42a10f58d0SMark Johnston.Op Fl x Ar opt Oo Ns = Ns Ar val Oc
43a10f58d0SMark Johnston.Ar command
44a10f58d0SMark Johnston.Op Oo Ar args Oc
45a10f58d0SMark Johnston.Sh DESCRIPTION
46a10f58d0SMark JohnstonThe
47a10f58d0SMark Johnston.Nm
48a10f58d0SMark Johnstonutility gathers and displays kernel locking and profiling statistics.
49a10f58d0SMark Johnston.Nm
50a10f58d0SMark Johnstonallows you to specify which events to watch (for example, spin on adaptive
51a10f58d0SMark Johnstonmutex, block on read access to rwlock due to waiting writers, and so forth), how
52a10f58d0SMark Johnstonmuch data to gather for each event, and how to display the data.
53a10f58d0SMark JohnstonBy default,
54a10f58d0SMark Johnston.Nm
55a10f58d0SMark Johnstonmonitors all lock contention events, gathers frequency and timing data about
56a10f58d0SMark Johnstonthose events, and displays the data in decreasing frequency order, so that the
57a10f58d0SMark Johnstonmost common events appear first.
58a10f58d0SMark Johnston.Pp
59a10f58d0SMark Johnston.Nm
60a10f58d0SMark Johnstongathers data until the specified command completes.
61a10f58d0SMark JohnstonFor example, to gather statistics for a fixed-time interval, use
62a10f58d0SMark Johnston.Xr sleep 1
63a10f58d0SMark Johnstonas the command, as follows:
64a10f58d0SMark Johnston.Pp
65a10f58d0SMark Johnston.Dl # lockstat sleep 5
66a10f58d0SMark Johnston.Pp
67a10f58d0SMark JohnstonWhen the
68a10f58d0SMark Johnston.Fl I
69a10f58d0SMark Johnstonoption is specified,
70a10f58d0SMark Johnston.Nm lockstat
71a10f58d0SMark Johnstonestablishes a per-processor high-level periodic interrupt source to gather
72a10f58d0SMark Johnstonprofiling data.
73a10f58d0SMark JohnstonThe interrupt handler simply generates a
74a10f58d0SMark Johnston.Nm
75a10f58d0SMark Johnstonevent whose caller is the interrupted PC (program counter).
76a10f58d0SMark JohnstonThe profiling event is just like any other
77a10f58d0SMark Johnston.Nm lockstat
78a10f58d0SMark Johnstonevent, so all of the normal
79a10f58d0SMark Johnston.Nm lockstat
80a10f58d0SMark Johnstonoptions are applicable.
81a10f58d0SMark Johnston.Pp
82a10f58d0SMark Johnston.Nm
83a10f58d0SMark Johnstonrelies on DTrace to modify the running kernel's text to intercept events of
84a10f58d0SMark Johnstoninterest.
85a10f58d0SMark JohnstonThis imposes a small but measurable overhead on all system activity, so access
86a10f58d0SMark Johnstonto
87a10f58d0SMark Johnston.Nm
88a10f58d0SMark Johnstonis restricted to super-user by default.
89a10f58d0SMark Johnston.Sh OPTIONS
907e1e3d94SStacey SonThe following options are supported:
919b055b74SMark Johnston.Bl -tag -width indent
929b055b74SMark Johnston.It Fl V
939b055b74SMark JohnstonPrint the D program used to gather the requested data.
949b055b74SMark Johnston.El
95a10f58d0SMark Johnston.Ss Event Selection
96a10f58d0SMark JohnstonIf no event selection options are specified, the default is
97a10f58d0SMark Johnston.Fl C .
98a10f58d0SMark Johnston.Bl -tag -width indent
99a10f58d0SMark Johnston.It Fl A
100a10f58d0SMark JohnstonWatch all lock events.
101a10f58d0SMark Johnston.Fl A
102a10f58d0SMark Johnstonis equivalent to
103a10f58d0SMark Johnston.Fl CH .
104a10f58d0SMark Johnston.It Fl C
1057e1e3d94SStacey SonWatch contention events.
106a10f58d0SMark Johnston.It Fl E
1077e1e3d94SStacey SonWatch error events.
108a10f58d0SMark Johnston.It Fl e Ar event-list
109a10f58d0SMark JohnstonOnly watch the specified events.
110a10f58d0SMark Johnston.Ar event-list
111a10f58d0SMark Johnstonis a comma-separated list of events or ranges of events such as 1,4-7,35.
112a10f58d0SMark JohnstonRun
113a10f58d0SMark Johnston.Nm
114a10f58d0SMark Johnstonwith no arguments to get a brief description of all events.
115a10f58d0SMark Johnston.It Fl H
1167e1e3d94SStacey SonWatch hold events.
117a10f58d0SMark Johnston.It Fl I
1187e1e3d94SStacey SonWatch profiling interrupt events.
119a10f58d0SMark Johnston.It Fl i Ar rate
120a10f58d0SMark JohnstonInterrupt rate (per second) for
121a10f58d0SMark Johnston.Fl I .
122a10f58d0SMark JohnstonThe default is 97 Hz, so that profiling doesn't run in lockstep with the clock
123a10f58d0SMark Johnstoninterrupt (which runs at 100 Hz).
124a10f58d0SMark Johnston.El
125a10f58d0SMark Johnston.Ss Data Gathering
126a10f58d0SMark Johnston.Bl -tag -width indent
127a10f58d0SMark Johnston.It Fl x Ar arg Oo Ns = Ns Ar val Oc
128a10f58d0SMark JohnstonEnable or modify a
129a10f58d0SMark Johnston.Xr dtrace 1
130a10f58d0SMark Johnstonruntime option or D compiler option.
131a10f58d0SMark JohnstonBoolean options are enabled by specifying their name.
132a10f58d0SMark JohnstonOptions with values are set by separating the option name and value with an
133a10f58d0SMark Johnstonequals sign.
134a10f58d0SMark Johnston.El
135a10f58d0SMark Johnston.Ss "Data Gathering (Mutually Exclusive)"
136a10f58d0SMark Johnston.Bl -tag -width indent
137a10f58d0SMark Johnston.It Fl b
1387e1e3d94SStacey SonBasic statistics: lock, caller, number of events.
139a10f58d0SMark Johnston.It Fl h
140a10f58d0SMark JohnstonHistogram: timing plus time-distribution histograms.
141a10f58d0SMark Johnston.It Fl s Ar depth
142a10f58d0SMark JohnstonStack trace: histogram plus stack traces up to
143a10f58d0SMark Johnston.Ar depth
144a10f58d0SMark Johnstonframes deep.
145a10f58d0SMark Johnston.It Fl t
146a10f58d0SMark JohnstonTiming: Basic plus timing for all events (default).
147a10f58d0SMark Johnston.El
148a10f58d0SMark Johnston.Ss "Data Filtering"
149a10f58d0SMark Johnston.Bl -tag -width indent
150a10f58d0SMark Johnston.It Fl d Ar duration
151a10f58d0SMark JohnstonOnly watch events longer than
152a10f58d0SMark Johnston.Ar duration .
153a10f58d0SMark Johnston.It Fl f Ar func Ns Oo Ns , Ns Ar size Oc Ns
154a10f58d0SMark JohnstonOnly watch events generated by
155a10f58d0SMark Johnston.Ar func ,
156a10f58d0SMark Johnstonwhich can be specified as a symbolic name or hex address.
157a10f58d0SMark Johnston.Ar size
158a10f58d0SMark Johnstondefaults to the ELF symbol size if available, or 1 if not.
159a10f58d0SMark Johnston.It Fl l Ar lock Ns Oo Ns , Ns Ar size Oc Ns
160a10f58d0SMark JohnstonOnly watch
161a10f58d0SMark Johnston.Ar lock ,
162a10f58d0SMark Johnstonwhich can be specified as a symbolic name or hex address.
163a10f58d0SMark Johnston.Ar size
164a10f58d0SMark Johnstondefaults to the ELF symbol size or 1 if the symbol size is not available.
165a10f58d0SMark Johnston.It Fl n Ar num-records
1667e1e3d94SStacey SonMaximum number of data records.
167a10f58d0SMark Johnston.It Fl T
168a10f58d0SMark JohnstonTrace (rather than sample) events.
169a10f58d0SMark JohnstonThis is off by default.
170a10f58d0SMark Johnston.El
171a10f58d0SMark Johnston.Ss Data Reporting
172a10f58d0SMark Johnston.Bl -tag -width indent
173a10f58d0SMark Johnston.It Fl D Ar count
174a10f58d0SMark JohnstonOnly display the top
175a10f58d0SMark Johnston.Ar count
176a10f58d0SMark Johnstonevents of each type.
177a10f58d0SMark Johnston.It Fl g
178a10f58d0SMark JohnstonShow total events generated by function.
179a10f58d0SMark JohnstonFor example, if
180a10f58d0SMark Johnston.Fn foo
181a10f58d0SMark Johnstoncalls
182a10f58d0SMark Johnston.Fn bar
183a10f58d0SMark Johnstonin a loop, the work done by
184a10f58d0SMark Johnston.Fn bar
185a10f58d0SMark Johnstoncounts as work generated by
186a10f58d0SMark Johnston.Fn foo
187a10f58d0SMark Johnston(along with any work done by
188a10f58d0SMark Johnston.Fn foo
189a10f58d0SMark Johnstonitself).
190a10f58d0SMark JohnstonThe
191a10f58d0SMark Johnston.Fl g
192a10f58d0SMark Johnstonoption works by counting the total number of stack frames in which each function
193a10f58d0SMark Johnstonappears.
194a10f58d0SMark JohnstonThis implies two things: (1) the data reported by
195a10f58d0SMark Johnston.Fl g
196a10f58d0SMark Johnstoncan be misleading if the stack traces are not deep enough, and (2) functions
197a10f58d0SMark Johnstonthat are called recursively might show greater than 100% activity.
198a10f58d0SMark JohnstonIn light of issue (1), the default data gathering mode when using
199a10f58d0SMark Johnston.Fl g
200a10f58d0SMark Johnstonis
201a10f58d0SMark Johnston.Fl s 50 .
202a10f58d0SMark Johnston.It Fl k
2037e1e3d94SStacey SonCoalesce PCs within functions.
204a10f58d0SMark Johnston.It Fl o Ar filename
205a10f58d0SMark JohnstonDirect output to
206a10f58d0SMark Johnston.Ar filename .
207a10f58d0SMark Johnston.It Fl P
2087e1e3d94SStacey SonSort data by (\fIcount * time\fR) product.
209a10f58d0SMark Johnston.It Fl p
2107e1e3d94SStacey SonParsable output format.
211a10f58d0SMark Johnston.It Fl R
2127e1e3d94SStacey SonDisplay rates (events per second) rather than counts.
213a10f58d0SMark Johnston.It Fl W
2147e1e3d94SStacey SonWhichever: distinguish events only by caller, not by lock.
215a10f58d0SMark Johnston.It Fl w
2167e1e3d94SStacey SonWherever: distinguish events only by lock, not by caller.
217a10f58d0SMark Johnston.El
218a10f58d0SMark Johnston.Sh DISPLAY FORMATS
2197e1e3d94SStacey SonThe following headers appear over various columns of data.
220a10f58d0SMark Johnston.Bl -tag -width indent
221a10f58d0SMark Johnston.It Count or ops/s
222a10f58d0SMark JohnstonNumber of times this event occurred, or the rate (times per second) if
223a10f58d0SMark Johnston.Fl R
224a10f58d0SMark Johnstonwas specified.
225a10f58d0SMark Johnston.It indv
2267e1e3d94SStacey SonPercentage of all events represented by this individual event.
227a10f58d0SMark Johnston.It genr
2287e1e3d94SStacey SonPercentage of all events generated by this function.
229a10f58d0SMark Johnston.It cuml
2307e1e3d94SStacey SonCumulative percentage; a running total of the individuals.
231a10f58d0SMark Johnston.It rcnt
232a10f58d0SMark JohnstonAverage reference count.
233a10f58d0SMark JohnstonThis will always be 1 for exclusive locks (mutexes,
234a10f58d0SMark Johnstonspin locks, rwlocks held as writer) but can be greater than 1 for shared locks
235a10f58d0SMark Johnston(rwlocks held as reader).
236a10f58d0SMark Johnston.It nsec
237a10f58d0SMark JohnstonAverage duration of the events in nanoseconds, as appropriate for the event.
238a10f58d0SMark JohnstonFor the profiling event, duration means interrupt latency.
239a10f58d0SMark Johnston.It Lock
2407e1e3d94SStacey SonAddress of the lock; displayed symbolically if possible.
2419fb83be0SMark Johnston.It CPU+Pri_Class
2429fb83be0SMark JohnstonCPU plus the priority class of the interrupted thread.
2439fb83be0SMark JohnstonFor example, if CPU 4 is interrupted while running a timeshare thread, this
2449fb83be0SMark Johnstonwill be reported as
2459fb83be0SMark Johnston.Ql cpu[4]+TShar .
246a10f58d0SMark Johnston.It Caller
2477e1e3d94SStacey SonAddress of the caller; displayed symbolically if possible.
248a10f58d0SMark Johnston.El
249a10f58d0SMark Johnston.Sh EXAMPLES
250a10f58d0SMark Johnston.Bl -tag -width 0n
251a10f58d0SMark Johnston.It Example 1 Measuring Kernel Lock Contention
252a10f58d0SMark Johnston.Pp
253a10f58d0SMark Johnston.Li # lockstat sleep 5
254a10f58d0SMark Johnston.Bd -literal
255a10f58d0SMark JohnstonAdaptive mutex spin: 41411 events in 5.011 seconds (8263 events/sec)
2567e1e3d94SStacey Son
2577e1e3d94SStacey SonCount indv cuml rcnt     nsec Lock                   Caller
258a10f58d0SMark Johnston-------------------------------------------------------------------------------
259a10f58d0SMark Johnston13750  33%  33% 0.00       72 vm_page_queue_free_mtx vm_page_free_toq+0x12e
260a10f58d0SMark Johnston13648  33%  66% 0.00       66 vm_page_queue_free_mtx vm_page_alloc+0x138
261a10f58d0SMark Johnston 4023  10%  76% 0.00       51 vm_dom+0x80            vm_page_dequeue+0x68
262a10f58d0SMark Johnston 2672   6%  82% 0.00      186 vm_dom+0x80            vm_page_enqueue+0x63
263a10f58d0SMark Johnston  618   1%  84% 0.00       31 0xfffff8000cd83a88     qsyncvp+0x37
264a10f58d0SMark Johnston  506   1%  85% 0.00      164 0xfffff8000cb3f098     vputx+0x5a
265a10f58d0SMark Johnston  477   1%  86% 0.00       69 0xfffff8000c7eb180     uma_dbg_getslab+0x5b
266a10f58d0SMark Johnston  288   1%  87% 0.00       77 0xfffff8000cd8b000     vn_finished_write+0x29
267a10f58d0SMark Johnston  263   1%  88% 0.00      103 0xfffff8000cbad448     vinactive+0xdc
268a10f58d0SMark Johnston  259   1%  88% 0.00       53 0xfffff8000cd8b000     vfs_ref+0x24
269a10f58d0SMark Johnston  237   1%  89% 0.00       20 0xfffff8000cbad448     vfs_hash_get+0xcc
270a10f58d0SMark Johnston  233   1%  89% 0.00       22 0xfffff8000bfd9480     uma_dbg_getslab+0x5b
271a10f58d0SMark Johnston  223   1%  90% 0.00       20 0xfffff8000cb3f098     cache_lookup+0x561
272a10f58d0SMark Johnston  193   0%  90% 0.00       16 0xfffff8000cb40ba8     vref+0x27
273a10f58d0SMark Johnston  175   0%  91% 0.00       34 0xfffff8000cbad448     vputx+0x5a
274a10f58d0SMark Johnston  169   0%  91% 0.00       51 0xfffff8000cd8b000     vfs_unbusy+0x27
275a10f58d0SMark Johnston  164   0%  92% 0.00       31 0xfffff8000cb40ba8     vputx+0x5a
2767e1e3d94SStacey Son[...]
2777e1e3d94SStacey Son
278a10f58d0SMark JohnstonAdaptive mutex block: 10 events in 5.011 seconds (2 events/sec)
2797e1e3d94SStacey Son
2807e1e3d94SStacey SonCount indv cuml rcnt     nsec Lock                   Caller
281a10f58d0SMark Johnston-------------------------------------------------------------------------------
282a10f58d0SMark Johnston    3  30%  30% 0.00    17592 vm_page_queue_free_mtx vm_page_alloc+0x138
283a10f58d0SMark Johnston    2  20%  50% 0.00    20528 vm_dom+0x80            vm_page_enqueue+0x63
284a10f58d0SMark Johnston    2  20%  70% 0.00    55502 0xfffff8000cb40ba8     vputx+0x5a
285a10f58d0SMark Johnston    1  10%  80% 0.00    12007 vm_page_queue_free_mtx vm_page_free_toq+0x12e
286a10f58d0SMark Johnston    1  10%  90% 0.00     9125 0xfffff8000cbad448     vfs_hash_get+0xcc
287a10f58d0SMark Johnston    1  10% 100% 0.00     7864 0xfffff8000cd83a88     qsyncvp+0x37
288a10f58d0SMark Johnston-------------------------------------------------------------------------------
2897e1e3d94SStacey Son[...]
290a10f58d0SMark Johnston.Ed
291a10f58d0SMark Johnston.It Example 2 Measuring Hold Times
292a10f58d0SMark Johnston.Pp
293a10f58d0SMark Johnston.Li # lockstat -H -D 10 sleep 1
294a10f58d0SMark Johnston.Bd -literal
295a10f58d0SMark JohnstonAdaptive mutex hold: 109589 events in 1.039 seconds (105526 events/sec)
2967e1e3d94SStacey Son
2977e1e3d94SStacey SonCount indv cuml rcnt     nsec Lock                   Caller
298a10f58d0SMark Johnston-------------------------------------------------------------------------------
299a10f58d0SMark Johnston 8998   8%   8% 0.00      617 0xfffff8000c7eb180     uma_dbg_getslab+0xd4
300a10f58d0SMark Johnston 5901   5%  14% 0.00      917 vm_page_queue_free_mtx vm_object_terminate+0x16a
301a10f58d0SMark Johnston 5040   5%  18% 0.00      902 vm_dom+0x80            vm_page_free_toq+0x88
302a10f58d0SMark Johnston 4884   4%  23% 0.00     1056 vm_page_queue_free_mtx vm_page_alloc+0x44e
303a10f58d0SMark Johnston 4664   4%  27% 0.00      759 vm_dom+0x80            vm_fault_hold+0x1a13
304a10f58d0SMark Johnston 4011   4%  31% 0.00      888 vm_dom                 vm_page_advise+0x11b
305a10f58d0SMark Johnston 4010   4%  34% 0.00      957 vm_dom+0x80            _vm_page_deactivate+0x5c
306a10f58d0SMark Johnston 3743   3%  38% 0.00      582 0xfffff8000cf04838     pmap_is_prefaultable+0x158
307a10f58d0SMark Johnston 2254   2%  40% 0.00      952 vm_dom                 vm_page_free_toq+0x88
308a10f58d0SMark Johnston 1639   1%  41% 0.00      591 0xfffff800d60065b8     trap_pfault+0x1f7
309a10f58d0SMark Johnston-------------------------------------------------------------------------------
3107e1e3d94SStacey Son[...]
3117e1e3d94SStacey Son
312a10f58d0SMark JohnstonR/W writer hold: 64314 events in 1.039 seconds (61929 events/sec)
3137e1e3d94SStacey Son
3147e1e3d94SStacey SonCount indv cuml rcnt     nsec Lock                   Caller
315a10f58d0SMark Johnston-------------------------------------------------------------------------------
316a10f58d0SMark Johnston 7421  12%  12% 0.00     2994 pvh_global_lock        pmap_page_is_mapped+0xb6
317a10f58d0SMark Johnston 4668   7%  19% 0.00     3313 pvh_global_lock        pmap_enter+0x9ae
318a10f58d0SMark Johnston 1639   3%  21% 0.00      733 0xfffff80168d10200     vm_object_deallocate+0x683
319a10f58d0SMark Johnston 1639   3%  24% 0.00     3061 0xfffff80168d10200     unlock_and_deallocate+0x2b
320a10f58d0SMark Johnston 1639   3%  26% 0.00     2966 0xfffff80168d10200     vm_fault_hold+0x16ee
321a10f58d0SMark Johnston 1567   2%  29% 0.00      733 0xfffff80168d10200     vm_fault_hold+0x19bc
322a10f58d0SMark Johnston  821   1%  30% 0.00      786 0xfffff801eb0cc000     vm_object_madvise+0x32d
323a10f58d0SMark Johnston  649   1%  31% 0.00     4918 0xfffff80191105300     vm_fault_hold+0x16ee
324a10f58d0SMark Johnston  648   1%  32% 0.00     8112 0xfffff80191105300     unlock_and_deallocate+0x2b
325a10f58d0SMark Johnston  647   1%  33% 0.00     1261 0xfffff80191105300     vm_object_deallocate+0x683
326a10f58d0SMark Johnston-------------------------------------------------------------------------------
327a10f58d0SMark Johnston.Ed
328a10f58d0SMark Johnston.It Example 3 Measuring Hold Times for Stack Traces Containing a Specific Function
329a10f58d0SMark Johnston.Pp
330a10f58d0SMark Johnston.Li # lockstat -H -f tcp_input -s 50 -D 10 sleep 1
331a10f58d0SMark Johnston.Bd -literal
332a10f58d0SMark JohnstonAdaptive mutex hold: 68 events in 1.026 seconds (66 events/sec)
333a10f58d0SMark Johnston
334a10f58d0SMark Johnston-------------------------------------------------------------------------------
335a10f58d0SMark JohnstonCount indv cuml rcnt     nsec Lock                   Caller
336a10f58d0SMark Johnston   32  47%  47% 0.00     1631 0xfffff800686f50d8     tcp_do_segment+0x284b
3377e1e3d94SStacey Son
3387e1e3d94SStacey Son      nsec ------ Time Distribution ------ count     Stack
339a10f58d0SMark Johnston      1024 |@@@@@@@@@@                     11        tcp_input+0xf54
340a10f58d0SMark Johnston      2048 |@@@@@@@@@@@@@                  14        ip_input+0xc8
341a10f58d0SMark Johnston      4096 |@@@@@                          6         swi_net+0x192
342a10f58d0SMark Johnston      8192 |                               1         intr_event_execute_handlers+0x93
343a10f58d0SMark Johnston                                                     ithread_loop+0xa6
344a10f58d0SMark Johnston                                                     fork_exit+0x84
345a10f58d0SMark Johnston                                                     0xffffffff808cf9ee
346a10f58d0SMark Johnston-------------------------------------------------------------------------------
3477e1e3d94SStacey SonCount indv cuml rcnt     nsec Lock                   Caller
348a10f58d0SMark Johnston   29  43%  90% 0.00     4851 0xfffff800686f50d8     sowakeup+0xf8
3497e1e3d94SStacey Son
3507e1e3d94SStacey Son      nsec ------ Time Distribution ------ count     Stack
351a10f58d0SMark Johnston      4096 |@@@@@@@@@@@@@@@                15        tcp_do_segment+0x2423
352a10f58d0SMark Johnston      8192 |@@@@@@@@@@@@                   12        tcp_input+0xf54
353a10f58d0SMark Johnston     16384 |@@                             2         ip_input+0xc8
354a10f58d0SMark Johnston                                                     swi_net+0x192
355a10f58d0SMark Johnston                                                     intr_event_execute_handlers+0x93
356a10f58d0SMark Johnston                                                     ithread_loop+0xa6
357a10f58d0SMark Johnston                                                     fork_exit+0x84
358a10f58d0SMark Johnston                                                     0xffffffff808cf9ee
359a10f58d0SMark Johnston-------------------------------------------------------------------------------
3607e1e3d94SStacey Son[...]
361a10f58d0SMark Johnston.Ed
362a10f58d0SMark Johnston.El
363a10f58d0SMark Johnston.Sh SEE ALSO
364a10f58d0SMark Johnston.Xr dtrace 1 ,
365a10f58d0SMark Johnston.Xr ksyms 4 ,
366a10f58d0SMark Johnston.Xr locking 9
367*932a690cSGordon Bergling.Sh HISTORY
368*932a690cSGordon BerglingThe
369*932a690cSGordon Bergling.Nm
370*932a690cSGordon Berglingutility first appeared in
371*932a690cSGordon Bergling.Fx 7.1 .
372a10f58d0SMark Johnston.Sh NOTES
373a10f58d0SMark JohnstonTail-call elimination can affect call sites.
374a10f58d0SMark JohnstonFor example, if
375a10f58d0SMark Johnston.Fn foo Ns +0x50
376a10f58d0SMark Johnstoncalls
377a10f58d0SMark Johnston.Fn bar
378a10f58d0SMark Johnstonand the last thing
379a10f58d0SMark Johnston.Fn bar
380a10f58d0SMark Johnstondoes is call
381a10f58d0SMark Johnston.Fn mtx_unlock ,
382a10f58d0SMark Johnstonthe compiler can arrange for
383a10f58d0SMark Johnston.Fn bar
384a10f58d0SMark Johnstonto branch to
385a10f58d0SMark Johnston.Fn mtx_unlock
386a10f58d0SMark Johnstonwith a return address of
387a10f58d0SMark Johnston.Fn foo Ns +0x58.
388a10f58d0SMark JohnstonThus, the
389a10f58d0SMark Johnston.Fn mtx_unlock
390a10f58d0SMark Johnstonin
391a10f58d0SMark Johnston.Fn bar
392a10f58d0SMark Johnstonwill appear as though it occurred at
393a10f58d0SMark Johnston.Fn foo Ns +0x58.
394a10f58d0SMark Johnston.Pp
395a10f58d0SMark JohnstonThe PC in the stack frame in which an interrupt occurs can be bogus because,
396a10f58d0SMark Johnstonbetween function calls, the compiler is free to use the return address register
397a10f58d0SMark Johnstonfor local storage.
398a10f58d0SMark Johnston.Pp
399a10f58d0SMark JohnstonWhen using the
400a10f58d0SMark Johnston.Fl I
401a10f58d0SMark Johnstonand
402a10f58d0SMark Johnston.Fl s
403a10f58d0SMark Johnstonoptions together, the interrupted PC will usually not appear anywhere in the
404a10f58d0SMark Johnstonstack since the interrupt handler is entered asynchronously, not by a function
405a10f58d0SMark Johnstoncall from that PC.
406