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