xref: /titanic_41/usr/src/cmd/powertop/i386/pt_i386.c (revision 29bd28862cfb8abbd3a0f0a4b17e08bbc3652836)
1 /*
2  * Copyright 2009, Intel Corporation
3  * Copyright 2009, Sun Microsystems, Inc
4  *
5  * This file is part of PowerTOP
6  *
7  * This program file is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program in a file named COPYING; if not, write to the
18  * Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301 USA
21  *
22  * Authors:
23  *	Arjan van de Ven <arjan@linux.intel.com>
24  *	Eric C Saxe <eric.saxe@sun.com>
25  *	Aubrey Li <aubrey.li@intel.com>
26  */
27 
28 /*
29  * GPL Disclaimer
30  *
31  * For the avoidance of doubt, except that if any license choice other
32  * than GPL or LGPL is available it will apply instead, Sun elects to
33  * use only the General Public License version 2 (GPLv2) at this time
34  * for any software where a choice of GPL license versions is made
35  * available with the language indicating that GPLv2 or any later
36  * version may be used, or where a choice of which version of the GPL
37  * is applied is otherwise unspecified.
38  */
39 
40 /*
41  * DTrace scripts for observing interrupts, callouts and cyclic events
42  * that cause CPU activity. Such activity prevents the processor from
43  * entering lower power states and reducing power consumption.
44  *
45  * g_dtp_events is the default script
46  */
47 const char *g_dtp_events =
48 "interrupt-complete"
49 "/arg0 != NULL && arg3 !=0/"
50 "{"
51 "	this->devi = (struct dev_info *)arg0;"
52 "	@interrupts[stringof(`devnamesp[this->devi->devi_major].dn_name),"
53 "	     this->devi->devi_instance] = count();"
54 "}"
55 ""
56 "sdt:::callout-start"
57 "/(caddr_t)((callout_t *)arg0)->c_func == (caddr_t)&`setrun/"
58 "{"
59 "       this->thr = (kthread_t *)(((callout_t *)arg0)->c_arg);"
60 "       @events_u[stringof(this->thr->t_procp->p_user.u_comm)] = count();"
61 "}"
62 ""
63 "sdt:::callout-start"
64 "/(caddr_t)((callout_t *)arg0)->c_func != (caddr_t)&`setrun/"
65 "{"
66 "       @events_k[(caddr_t)((callout_t *)arg0)->c_func] = count();"
67 "}"
68 ""
69 "sdt:::cyclic-start"
70 "/(caddr_t)((cyclic_t *)arg0)->cy_handler == (caddr_t)&`clock/"
71 "{"
72 "	@events_k[(caddr_t)((cyclic_t *)arg0)->cy_handler] = count();"
73 "}"
74 ""
75 "fbt::xc_common:entry"
76 "{"
77 "	self->xc_func = arg0;"
78 "}"
79 ""
80 "sysinfo:::xcalls"
81 "/pid != $pid/"
82 "{"
83 "       @events_x[execname, self->xc_func] = sum(arg0);"
84 "}"
85 ""
86 "fbt::xc_common:return"
87 "/self->xc_func/"
88 "{"
89 "	self->xc_func = 0;"
90 "}";
91 
92 /*
93  * g_dtp_events_v is enabled through the -v option, it includes cyclic events
94  * in the report, allowing a complete view of system activity
95  */
96 const char *g_dtp_events_v =
97 "interrupt-complete"
98 "/arg0 != NULL && arg3 !=0/"
99 "{"
100 "	this->devi = (struct dev_info *)arg0;"
101 "	@interrupts[stringof(`devnamesp[this->devi->devi_major].dn_name),"
102 "	     this->devi->devi_instance] = count();"
103 "}"
104 ""
105 "sdt:::callout-start"
106 "/(caddr_t)((callout_t *)arg0)->c_func == (caddr_t)&`setrun/"
107 "{"
108 "       this->thr = (kthread_t *)(((callout_t *)arg0)->c_arg);"
109 "       @events_u[stringof(this->thr->t_procp->p_user.u_comm)] = count();"
110 "}"
111 ""
112 "sdt:::callout-start"
113 "/(caddr_t)((callout_t *)arg0)->c_func != (caddr_t)&`setrun/"
114 "{"
115 "       @events_k[(caddr_t)((callout_t *)arg0)->c_func] = count();"
116 "}"
117 ""
118 "sdt:::cyclic-start"
119 "/(caddr_t)((cyclic_t *)arg0)->cy_handler != (caddr_t)&`dtrace_state_deadman &&"
120 " (caddr_t)((cyclic_t *)arg0)->cy_handler != (caddr_t)&`dtrace_state_clean/"
121 "{"
122 "	@events_k[(caddr_t)((cyclic_t *)arg0)->cy_handler] = count();"
123 "}"
124 ""
125 "fbt::xc_common:entry"
126 "{"
127 "	self->xc_func = arg0;"
128 "}"
129 ""
130 "sysinfo:::xcalls"
131 "/pid != $pid/"
132 "{"
133 "       @events_x[execname, self->xc_func] = sum(arg0);"
134 "}"
135 ""
136 "fbt::xc_common:return"
137 "/self->xc_func/"
138 "{"
139 "	self->xc_func = 0;"
140 "}";
141 
142 /*
143  * This script is selected through the -c option, it takes the CPU id as
144  * argument and observes activity generated by that CPU
145  */
146 const char *g_dtp_events_c =
147 "interrupt-complete"
148 "/cpu == $0 &&"
149 " arg0 != NULL && arg3 != 0/"
150 "{"
151 "	this->devi = (struct dev_info *)arg0;"
152 "	@interrupts[stringof(`devnamesp[this->devi->devi_major].dn_name),"
153 "	     this->devi->devi_instance] = count();"
154 "}"
155 ""
156 "sdt:::callout-start"
157 "/cpu == $0 &&"
158 " (caddr_t)((callout_t *)arg0)->c_func == (caddr_t)&`setrun/"
159 "{"
160 "       this->thr = (kthread_t *)(((callout_t *)arg0)->c_arg);"
161 "       @events_u[stringof(this->thr->t_procp->p_user.u_comm)] = count();"
162 "}"
163 ""
164 "sdt:::callout-start"
165 "/cpu == $0 &&"
166 " (caddr_t)((callout_t *)arg0)->c_func != (caddr_t)&`setrun/"
167 "{"
168 "       @events_k[(caddr_t)((callout_t *)arg0)->c_func] = count();"
169 "}"
170 ""
171 "sdt:::cyclic-start"
172 "/cpu == $0 &&"
173 " (caddr_t)((cyclic_t *)arg0)->cy_handler == (caddr_t)&`clock/"
174 "{"
175 "	@events_k[(caddr_t)((cyclic_t *)arg0)->cy_handler] = count();"
176 "}"
177 ""
178 "fbt::xc_common:entry"
179 "/cpu == $0/"
180 "{"
181 "	self->xc_func = arg0;"
182 "}"
183 ""
184 "sysinfo:::xcalls"
185 "/pid != $pid &&"
186 " cpu == $0/"
187 "{"
188 "       @events_x[execname, self->xc_func] = count();"
189 "}"
190 ""
191 "fbt::xc_common:return"
192 "/cpu == $0 &&"
193 " self->xc_func/"
194 "{"
195 "	self->xc_func = 0;"
196 "}"
197 ""
198 "fbt::xc_common:entry"
199 "/cpu != $0/"
200 "{"
201 "	self->xc_func = arg0;"
202 "	self->xc_cpu = cpu;"
203 "}"
204 ""
205 "fbt::send_dirint:entry"
206 "/pid != $pid &&"
207 " self->xc_func &&"
208 " arg0 == $0/"
209 "{"
210 "       @events_xc[execname, self->xc_func, self->xc_cpu] = count();"
211 "	self->xc_func = 0;"
212 "	self->xc_cpu = 0;"
213 "}";
214 
215 /*
216  * i386 platform specific display messages
217  */
218 const char *g_msg_idle_state = "C-states (idle power)";
219 const char *g_msg_freq_state = "P-states (frequencies)";
220