]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Kernel/pridist.d
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Kernel / pridist.d
1 #!/usr/sbin/dtrace -s
2 /*
3  * pridist.d - process priority distribution.
4  *             Written using DTrace (Solaris 10 3/05)
5  *
6  * This is a simple DTrace script that samples at 1000 Hz which process
7  * is on the CPUs, and what the priority is. A distribution plot is printed.
8  *
9  * With priorities, the higher the priority the better chance the process
10  * (actually, thread) has of being scheduled.
11  *
12  * This idea came from the script /usr/demo/dtrace/profpri.d, which
13  * produces similar output for one particular PID.
14  *
15  * $Id: pridist.d 3 2007-08-01 10:50:08Z brendan $
16  *
17  * USAGE:       pridist.d       # hit Ctrl-C to end sampling
18  *
19  * FIELDS:
20  *              CMD             process name
21  *              PID             process ID
22  *              value           process priority
23  *              count           number of samples of at least this priority
24  *
25  * BASED ON: /usr/demo/dtrace/profpri.d
26  *
27  * SEE ALSO:
28  *           DTrace Guide "profile Provider" chapter (docs.sun.com)
29  *           dispadmin(1M)
30  *
31  * PORTIONS: Copyright (c) 2005 Brendan Gregg.
32  *
33  * CDDL HEADER START
34  *
35  *  The contents of this file are subject to the terms of the
36  *  Common Development and Distribution License, Version 1.0 only
37  *  (the "License").  You may not use this file except in compliance
38  *  with the License.
39  *
40  *  You can obtain a copy of the license at Docs/cddl1.txt
41  *  or http://www.opensolaris.org/os/licensing.
42  *  See the License for the specific language governing permissions
43  *  and limitations under the License.
44  *
45  * CDDL HEADER END
46  *
47  * 13-Jun-2005  Brendan Gregg   Created this.
48  * 22-Apr-2006     "      "     Last update.
49  */
50
51 #pragma D option quiet
52
53 dtrace:::BEGIN
54 {
55         printf("Sampling... Hit Ctrl-C to end.\n");
56 }
57
58 profile:::profile-1000hz
59 {
60         @Count[execname, pid] = lquantize(curlwpsinfo->pr_pri, 0, 170, 5);
61 }
62
63 dtrace:::END
64 {
65         printa(" CMD: %-16s PID: %d\n%@d\n", @Count);
66 }