1235368Sgnn#!/usr/sbin/dtrace -s
2235368Sgnn/*
3235368Sgnn * dispqlen.d - dispatcher queue length by CPU.
4235368Sgnn *              Written using DTrace (Solaris 10 3/05).
5235368Sgnn *
6235368Sgnn * $Id: dispqlen.d 3 2007-08-01 10:50:08Z brendan $
7235368Sgnn *
8235368Sgnn * USAGE:	dispqlen.d		# hit Ctrl-C to end sample
9235368Sgnn *
10235368Sgnn * NOTES: The dispatcher queue length is an indication of CPU saturation.
11235368Sgnn * It is not an indicatior of utilisation - the CPUs may or may not be
12235368Sgnn * utilised when the dispatcher queue reports a length of zero.
13235368Sgnn *
14235368Sgnn * SEE ALSO:    uptime(1M)
15235368Sgnn *
16235368Sgnn * COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
17235368Sgnn *
18235368Sgnn * CDDL HEADER START
19235368Sgnn *
20235368Sgnn *  The contents of this file are subject to the terms of the
21235368Sgnn *  Common Development and Distribution License, Version 1.0 only
22235368Sgnn *  (the "License").  You may not use this file except in compliance
23235368Sgnn *  with the License.
24235368Sgnn *
25235368Sgnn *  You can obtain a copy of the license at Docs/cddl1.txt
26235368Sgnn *  or http://www.opensolaris.org/os/licensing.
27235368Sgnn *  See the License for the specific language governing permissions
28235368Sgnn *  and limitations under the License.
29235368Sgnn *
30235368Sgnn * CDDL HEADER END
31235368Sgnn *
32235368Sgnn * 27-Jun-2005  Brendan Gregg   Created this.
33235368Sgnn * 14-Feb-2006	   "      "	Last update.
34235368Sgnn */
35235368Sgnn
36235368Sgnn#pragma D option quiet
37235368Sgnn
38235368Sgnndtrace:::BEGIN
39235368Sgnn{
40235368Sgnn	printf("Sampling... Hit Ctrl-C to end.\n");
41235368Sgnn}
42235368Sgnn
43235368Sgnnprofile:::profile-1000hz
44235368Sgnn{
45235368Sgnn	@queue[cpu] =
46235368Sgnn	    lquantize(curthread->t_cpu->cpu_disp->disp_nrunnable, 0, 64, 1);
47235368Sgnn}
48235368Sgnn
49235368Sgnndtrace:::END
50235368Sgnn{
51235368Sgnn	printa(" CPU %d%@d\n", @queue);
52235368Sgnn}
53