Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| dtrace:examples [2009/02/14 13:41] – Sample output for callout profiling. RobertWatson | dtrace:examples [2020/12/25 15:22] (current) – Update probe name for priv-err RobertWatson | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| < | < | ||
| - | callout_execute::: | + | callout_execute::: |
| { | { | ||
| self-> | self-> | ||
| } | } | ||
| - | callout_execute::: | + | callout_execute::: |
| { | { | ||
| Line 55: | Line 55: | ||
| ===== Measure total time spent in each callout handler over 1-second intervals ===== | ===== Measure total time spent in each callout handler over 1-second intervals ===== | ||
| - | This script is loosely based on a similar one from [[/OpenSolaris|OpenSolaris]]'s sdt Provider page, but due to slight differences in types and probe naming, we can't use theirs verbatim: | + | This script is loosely based on a similar one from %%OpenSolaris%%'s sdt Provider page, but due to slight differences in types and probe naming, we can't use theirs verbatim: |
| < | < | ||
| - | callout_execute::: | + | #pragma D option quiet |
| + | |||
| + | callout_execute::: | ||
| { | { | ||
| self-> | self-> | ||
| } | } | ||
| - | callout_execute::: | + | callout_execute::: |
| { | { | ||
| Line 75: | Line 77: | ||
| clear(@callouts); | clear(@callouts); | ||
| printf(" | printf(" | ||
| + | } | ||
| + | |||
| + | BEGIN | ||
| + | { | ||
| + | printf(" | ||
| } | } | ||
| </ | </ | ||
| Submitted by [[/ | Submitted by [[/ | ||
| + | |||
| + | Note: Probes were named callout_start and callout_end in older versions. | ||
| This script works by measuring the time at the start of a callout, then again on termination and billing that time incrementally to the callout function that ran. Once a second, we print the results and reset the counters. | This script works by measuring the time at the start of a callout, then again on termination and billing that time incrementally to the callout function that ran. Once a second, we print the results and reset the counters. | ||
| + | |||
| + | < | ||
| + | cinnamon-freebsd# | ||
| + | function | nanoseconds per second | ||
| + | kernel`ipport_tick | ||
| + | kernel`nd6_timer | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | kernel`dcons_timeout | ||
| + | 0xc42deeb0 | ||
| + | | ||
| + | kernel`atkbd_timeout | ||
| + | 0xc42d34f0 | ||
| + | | ||
| + | |||
| + | ^C | ||
| + | </ | ||
| ===== Measure total time spent in non-MPSAFE callouts over 10-second intervals ===== | ===== Measure total time spent in non-MPSAFE callouts over 10-second intervals ===== | ||
| Line 121: | Line 152: | ||
| As before, except that only callouts using Giant are measured. | As before, except that only callouts using Giant are measured. | ||
| + | |||
| + | < | ||
| + | cinnamon-freebsd# | ||
| + | dtrace: dynamic variable size lowered to 16m | ||
| + | function | nanoseconds per second | ||
| + | kernel`nd6_timer | ||
| + | | ||
| + | | ||
| + | | ||
| + | kernel`atkbd_timeout | ||
| + | |||
| + | ^C | ||
| + | </ | ||
| ===== Collect stack traces leading to failed priv_check_cred() calls ===== | ===== Collect stack traces leading to failed priv_check_cred() calls ===== | ||
| - | This script captures an array of counters, one for each stack trace leading to a non-zero return from priv_check_cred() using the fbt provider: | + | This script captures an array of counters, one for each stack trace leading to a failed kernel privilege check: |
| < | < | ||
| - | fbt::priv_check_cred:return | + | priv:::priv-err |
| - | /arg1 != 0/ | + | |
| { | { | ||
| @traces[stack()] = count(); | @traces[stack()] = count(); | ||
| Line 135: | Line 178: | ||
| Submitted by [[/ | Submitted by [[/ | ||
| - | Interestingly, | + | < |
| + | dtrace: script ' | ||
| + | dtrace: aggregation size lowered | ||
| + | ^C | ||
| + | |||
| + | kernel`priv_check_cred+0xc3 | ||
| + | kernel`vaccess+0x104 | ||
| + | kernel`ufs_access+0x1e6 | ||
| + | kernel`VOP_ACCESS_APV+0xa5 | ||
| + | kernel`nfsrv_access+0xfa | ||
| + | kernel`nfsrv3_access+0x2fc | ||
| + | kernel`nfssvc_program+0x397 | ||
| + | kernel`svc_run_internal+0x942 | ||
| + | kernel`svc_run+0x7f | ||
| + | kernel`nfssvc_nfsd+0xad | ||
| + | kernel`nfssvc+0x235 | ||
| + | kernel`syscall+0x2d3 | ||
| + | kernel`0xc0b43790 | ||
| + | 32 | ||
| + | |||
| + | kernel`priv_check_cred+0xc3 | ||
| + | kernel`vaccess+0x179 | ||
| + | kernel`ufs_access+0x1e6 | ||
| + | kernel`VOP_ACCESS_APV+0xa5 | ||
| + | kernel`nfsrv_access+0xfa | ||
| + | kernel`nfsrv3_access+0x23f | ||
| + | kernel`nfssvc_program+0x397 | ||
| + | kernel`svc_run_internal+0x942 | ||
| + | kernel`svc_run+0x7f | ||
| + | kernel`nfssvc_nfsd+0xad | ||
| + | kernel`nfssvc+0x235 | ||
| + | kernel`syscall+0x2d3 | ||
| + | kernel`0xc0b43790 | ||
| + | 32 | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | ===== Histogram of time spent waiting on NFSv3 RPCs by system call ===== | ||
| + | This script measures all time spent waiting on RPC replies | ||
| + | |||
| + | Exists in %%FreeBSD%% as '' | ||
| + | |||
| + | < | ||
| + | syscall::: | ||
| + | { | ||
| + | |||
| + | self-> | ||
| + | } | ||
| + | |||
| + | nfsclient: | ||
| + | { | ||
| + | |||
| + | self-> | ||
| + | } | ||
| + | |||
| + | nfsclient: | ||
| + | { | ||
| + | |||
| + | self-> | ||
| + | } | ||
| + | |||
| + | syscall::: | ||
| + | / | ||
| + | |||
| + | @syscalls[probefunc] = quantize(self-> | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Submitted by [[/ | ||
| + | |||
| + | < | ||
| + | dtrace: script ' | ||
| + | dtrace: aggregation size lowered to 6m | ||
| + | ^C | ||
| + | fstatfs | ||
| + | | ||
| + | 131072 | | ||
| + | 262144 |@@@@@@@@@@@@@ | ||
| + | 524288 |@@@@@@@@@@@@@ | ||
| + | | ||
| + | | ||
| + | |||
| + | open | ||
| + | | ||
| + | 4 | | ||
| + | 8 |@ 3 | ||
| + | 16 | | ||
| + | 32 |@ 2 | ||
| + | 64 | | ||
| + | 128 | | ||
| + | 256 | | ||
| + | 512 | | ||
| + | 1024 | | ||
| + | 2048 | | ||
| + | 4096 | | ||
| + | 8192 | | ||
| + | 16384 | | ||
| + | 32768 | | ||
| + | 65536 | | ||
| + | 131072 | | ||
| + | 262144 |@@@@@ | ||
| + | 524288 |@@@@@@@@@@@@@@@@ | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | lstat | ||
| + | | ||
| + | 64 | | ||
| + | 128 | | ||
| + | 256 | | ||
| + | 512 | | ||
| + | 1024 | | ||
| + | 2048 | | ||
| + | 4096 | | ||
| + | 8192 | | ||
| + | 16384 | | ||
| + | 32768 | | ||
| + | 65536 | | ||
| + | 131072 | | ||
| + | 262144 |@@@@@ | ||
| + | 524288 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | 16777216 | | ||
| + | </ | ||
| + | |||
| + | ===== Trace of NFS RPCs and attribute/ | ||
| + | |||
| + | This script creates a trace of NFS RPCs, NFS attribute cache activity, and NFS access cache activity, along with the system call that instigated the activity. | ||
| + | |||
| + | Exists in %%FreeBSD%% as '' | ||
| + | |||
| + | < | ||
| + | syscall::: | ||
| + | { | ||
| + | |||
| + | self-> | ||
| + | } | ||
| + | |||
| + | syscall:::return | ||
| + | { | ||
| + | |||
| + | self-> | ||
| + | } | ||
| + | |||
| + | nfsclient::: | ||
| + | / | ||
| + | { | ||
| + | |||
| + | trace(probemod); | ||
| + | trace(arg0); | ||
| + | trace(execname); | ||
| + | trace(self-> | ||
| + | } | ||
| + | |||
| + | nfsclient::: | ||
| + | / | ||
| + | { | ||
| + | |||
| + | trace(probemod); | ||
| + | trace(arg0); | ||
| + | trace(execname); | ||
| + | trace(" | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Submitted by [[/ | ||
| + | |||
| + | < | ||
| + | 1 531 | ||
| + | 1 527 | ||
| + | 1 531 | ||
| + | 1 527 | ||
| + | 1 530 flush: | ||
| + | 1 532 get: | ||
| + | 1 568 | ||
| + | 1 569 getattr: | ||
| + | 1 533 | ||
| + | 1 527 | ||
| + | 1 531 | ||
| + | 1 527 | ||
| + | 1 530 flush: | ||
| + | 1 532 get: | ||
| + | 1 568 | ||
| + | 1 569 getattr: | ||
| + | 1 533 | ||
| + | 1 531 | ||
| + | 1 602 fsstat: | ||
| + | 1 603 | ||
| + | 1 533 | ||
| + | 1 531 | ||
| + | 1 527 | ||
| + | 1 531 | ||
| + | 1 527 | ||
| + | 1 531 | ||
| + | 1 531 | ||
| + | 1 531 | ||
| + | 1 527 | ||
| + | 1 527 | ||
| + | 1 531 | ||
| + | </ | ||
| + | |||
| + | ===== Distribution of name cache entry string lengths ===== | ||
| + | |||
| + | This example script captures a distribution of the length of strings added to the VFS name cache. | ||
| + | |||
| + | < | ||
| + | vfs: | ||
| + | { | ||
| + | |||
| + | @distribution = quantize(strlen((string)arg1)); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Submitted by [[/ | ||
| + | |||
| + | < | ||
| + | value ------------- Distribution ------------- count | ||
| + | 0 | 0 | ||
| + | 1 | 2 | ||
| + | 2 |@@ 296 | ||
| + | 4 |@@@@@@@@@@@ | ||
| + | 8 |@@@@@@@@@@@@@@@@ | ||
| + | 16 |@@@@@@@@@@@ | ||
| + | 32 | 69 | ||
| + | 64 | 2 | ||
| + | 128 | 0 | ||
| + | </ | ||
| + | |||
| + | A similar script to look at the distribution of lengths in hits could be generated using the probe vfs: | ||
| + | |||
| + | ---- | ||
| + | |||
| + | {{tag> | ||