xref: /titanic_41/usr/src/cmd/powertop/sparcv9/pt_sparcv9.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::xt_all:entry,"
76b47b5b34SRafael Vanoni "fbt::xc_all:entry"
77b47b5b34SRafael Vanoni "{"
78b47b5b34SRafael Vanoni "	self->xc_func = arg0;"
79b47b5b34SRafael Vanoni "}"
80b47b5b34SRafael Vanoni ""
81b47b5b34SRafael Vanoni "fbt::xt_one_unchecked:entry,"
82b47b5b34SRafael Vanoni "fbt::xt_some:entry,"
83b47b5b34SRafael Vanoni "fbt::xc_one:entry,"
84b47b5b34SRafael Vanoni "fbt::xc_some:entry"
85b47b5b34SRafael Vanoni "{"
86b47b5b34SRafael Vanoni "	self->xc_func = arg1;"
87b47b5b34SRafael Vanoni "}"
88b47b5b34SRafael Vanoni ""
89b47b5b34SRafael Vanoni "sysinfo:::xcalls"
90b47b5b34SRafael Vanoni "/pid != $pid/"
91b47b5b34SRafael Vanoni "{"
92b47b5b34SRafael Vanoni "       @events_x[execname, self->xc_func] = sum(arg0);"
93b47b5b34SRafael Vanoni "	self->xc_func = 0;"
94b47b5b34SRafael Vanoni "}";
95b47b5b34SRafael Vanoni 
96b47b5b34SRafael Vanoni /*
97b47b5b34SRafael Vanoni  * g_dtp_events_v is enabled through the -v option, it includes cyclic events
98b47b5b34SRafael Vanoni  * in the report, allowing a complete view of system activity
99b47b5b34SRafael Vanoni  */
100b47b5b34SRafael Vanoni const char *g_dtp_events_v =
101b47b5b34SRafael Vanoni "interrupt-complete"
102b47b5b34SRafael Vanoni "/arg0 != NULL && arg3 !=0/"
103b47b5b34SRafael Vanoni "{"
104b47b5b34SRafael Vanoni "	this->devi = (struct dev_info *)arg0;"
105b47b5b34SRafael Vanoni "	@interrupts[stringof(`devnamesp[this->devi->devi_major].dn_name),"
106b47b5b34SRafael Vanoni "	     this->devi->devi_instance] = count();"
107b47b5b34SRafael Vanoni "}"
108b47b5b34SRafael Vanoni ""
109b47b5b34SRafael Vanoni "sdt:::callout-start"
110b47b5b34SRafael Vanoni "/(caddr_t)((callout_t *)arg0)->c_func == (caddr_t)&`setrun/"
111b47b5b34SRafael Vanoni "{"
112b47b5b34SRafael Vanoni "       this->thr = (kthread_t *)(((callout_t *)arg0)->c_arg);"
113b47b5b34SRafael Vanoni "       @events_u[stringof(this->thr->t_procp->p_user.u_comm)] = count();"
114b47b5b34SRafael Vanoni "}"
115b47b5b34SRafael Vanoni ""
116b47b5b34SRafael Vanoni "sdt:::callout-start"
117b47b5b34SRafael Vanoni "/(caddr_t)((callout_t *)arg0)->c_func != (caddr_t)&`setrun/"
118b47b5b34SRafael Vanoni "{"
119b47b5b34SRafael Vanoni "       @events_k[(caddr_t)((callout_t *)arg0)->c_func] = count();"
120b47b5b34SRafael Vanoni "}"
121b47b5b34SRafael Vanoni ""
122b47b5b34SRafael Vanoni "sdt:::cyclic-start"
123b47b5b34SRafael Vanoni "/(caddr_t)((cyclic_t *)arg0)->cy_handler != (caddr_t)&`dtrace_state_deadman &&"
124b47b5b34SRafael Vanoni " (caddr_t)((cyclic_t *)arg0)->cy_handler != (caddr_t)&`dtrace_state_clean/"
125b47b5b34SRafael Vanoni "{"
126b47b5b34SRafael Vanoni "	@events_k[(caddr_t)((cyclic_t *)arg0)->cy_handler] = count();"
127b47b5b34SRafael Vanoni "}"
128b47b5b34SRafael Vanoni ""
129b47b5b34SRafael Vanoni "fbt::xt_all:entry,"
130b47b5b34SRafael Vanoni "fbt::xc_all:entry"
131b47b5b34SRafael Vanoni "{"
132b47b5b34SRafael Vanoni "	self->xc_func = arg0;"
133b47b5b34SRafael Vanoni "}"
134b47b5b34SRafael Vanoni ""
135b47b5b34SRafael Vanoni "fbt::xt_one_unchecked:entry,"
136b47b5b34SRafael Vanoni "fbt::xt_some:entry,"
137b47b5b34SRafael Vanoni "fbt::xc_one:entry,"
138b47b5b34SRafael Vanoni "fbt::xc_some:entry"
139b47b5b34SRafael Vanoni "{"
140b47b5b34SRafael Vanoni "	self->xc_func = arg1;"
141b47b5b34SRafael Vanoni "}"
142b47b5b34SRafael Vanoni ""
143b47b5b34SRafael Vanoni "sysinfo:::xcalls"
144b47b5b34SRafael Vanoni "/pid != $pid/"
145b47b5b34SRafael Vanoni "{"
146b47b5b34SRafael Vanoni "       @events_x[execname, self->xc_func] = sum(arg0);"
147b47b5b34SRafael Vanoni "	self->xc_func = 0;"
148b47b5b34SRafael Vanoni "}";
149b47b5b34SRafael Vanoni 
150b47b5b34SRafael Vanoni /*
151b47b5b34SRafael Vanoni  * This script is selected through the -c option, it takes the CPU id as
152b47b5b34SRafael Vanoni  * argument and observes activity generated by that CPU
153b47b5b34SRafael Vanoni  */
154b47b5b34SRafael Vanoni const char *g_dtp_events_c =
155b47b5b34SRafael Vanoni "interrupt-complete"
156b47b5b34SRafael Vanoni "/cpu == $0 &&"
157b47b5b34SRafael Vanoni " arg0 != NULL && arg3 != 0/"
158b47b5b34SRafael Vanoni "{"
159b47b5b34SRafael Vanoni "	this->devi = (struct dev_info *)arg0;"
160b47b5b34SRafael Vanoni "	@interrupts[stringof(`devnamesp[this->devi->devi_major].dn_name),"
161b47b5b34SRafael Vanoni "	     this->devi->devi_instance] = 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 "       this->thr = (kthread_t *)(((callout_t *)arg0)->c_arg);"
169b47b5b34SRafael Vanoni "       @events_u[stringof(this->thr->t_procp->p_user.u_comm)] = count();"
170b47b5b34SRafael Vanoni "}"
171b47b5b34SRafael Vanoni ""
172b47b5b34SRafael Vanoni "sdt:::callout-start"
173b47b5b34SRafael Vanoni "/cpu == $0 &&"
174b47b5b34SRafael Vanoni " (caddr_t)((callout_t *)arg0)->c_func != (caddr_t)&`setrun/"
175b47b5b34SRafael Vanoni "{"
176b47b5b34SRafael Vanoni "       @events_k[(caddr_t)((callout_t *)arg0)->c_func] = count();"
177b47b5b34SRafael Vanoni "}"
178b47b5b34SRafael Vanoni ""
179b47b5b34SRafael Vanoni "sdt:::cyclic-start"
180b47b5b34SRafael Vanoni "/cpu == $0 &&"
181b47b5b34SRafael Vanoni " (caddr_t)((cyclic_t *)arg0)->cy_handler == (caddr_t)&`clock/"
182b47b5b34SRafael Vanoni "{"
183b47b5b34SRafael Vanoni "	@events_k[(caddr_t)((cyclic_t *)arg0)->cy_handler] = count();"
184b47b5b34SRafael Vanoni "}"
185b47b5b34SRafael Vanoni ""
186b47b5b34SRafael Vanoni /*
187b47b5b34SRafael Vanoni  * xcalls to all CPUs. We're only interested in firings from other CPUs since
188b47b5b34SRafael Vanoni  * the system doesn't xcall itself
189b47b5b34SRafael Vanoni  */
190b47b5b34SRafael Vanoni "fbt::xt_all:entry,"
191b47b5b34SRafael Vanoni "fbt::xc_all:entry"
192b47b5b34SRafael Vanoni "/pid != $pid &&"
193b47b5b34SRafael Vanoni " cpu != $0/"
194b47b5b34SRafael Vanoni "{"
195b47b5b34SRafael Vanoni "	self->xc_func = arg0;"
196b47b5b34SRafael Vanoni "	self->xc_cpu = cpu;"
197b47b5b34SRafael Vanoni "	self->cpu_known = 1;"
198b47b5b34SRafael Vanoni "}"
199b47b5b34SRafael Vanoni ""
200b47b5b34SRafael Vanoni /*
201b47b5b34SRafael Vanoni  * xcalls to a subset of CPUs. No way of knowing if the observed CPU is in
202b47b5b34SRafael Vanoni  * it, so account it in the generic @events_x aggregation. Again, we don't
203b47b5b34SRafael Vanoni  * xcall the current CPU.
204b47b5b34SRafael Vanoni  */
205b47b5b34SRafael Vanoni "fbt::xt_some:entry,"
206b47b5b34SRafael Vanoni "fbt::xc_some:entry"
207b47b5b34SRafael Vanoni "/pid != $pid &&"
208b47b5b34SRafael Vanoni " cpu != $0/"
209b47b5b34SRafael Vanoni "{"
210b47b5b34SRafael Vanoni "	self->xc_func = arg1;"
211b47b5b34SRafael Vanoni "}"
212b47b5b34SRafael Vanoni ""
213b47b5b34SRafael Vanoni /*
214b47b5b34SRafael Vanoni  * xcalls to a specific CPU, with all the necessary information
215b47b5b34SRafael Vanoni  */
216b47b5b34SRafael Vanoni "fbt::xt_one_unchecked:entry,"
217b47b5b34SRafael Vanoni "fbt::xc_one:entry"
218b47b5b34SRafael Vanoni "/arg0 == $0/"
219b47b5b34SRafael Vanoni "{"
220b47b5b34SRafael Vanoni "	self->xc_func = arg1;"
221b47b5b34SRafael Vanoni "	self->xc_cpu = arg0;"
222b47b5b34SRafael Vanoni "	self->cpu_known = 1;"
223b47b5b34SRafael Vanoni "}"
224b47b5b34SRafael Vanoni ""
225b47b5b34SRafael Vanoni "sysinfo:::xcalls"
226b47b5b34SRafael Vanoni "/pid != $pid &&"
227b47b5b34SRafael Vanoni " self->xc_func &&"
228b47b5b34SRafael Vanoni " !self->cpu_known/"
229b47b5b34SRafael Vanoni "{"
230b47b5b34SRafael Vanoni "       @events_x[execname, self->xc_func] = sum(arg0);"
231b47b5b34SRafael Vanoni "	self->xc_func = 0;"
232b47b5b34SRafael Vanoni "}"
233b47b5b34SRafael Vanoni ""
234b47b5b34SRafael Vanoni "sysinfo:::xcalls"
235b47b5b34SRafael Vanoni "/pid != $pid &&"
236b47b5b34SRafael Vanoni " self->xc_func &&"
237b47b5b34SRafael Vanoni " self->cpu_known/"
238b47b5b34SRafael Vanoni "{"
239b47b5b34SRafael Vanoni "       @events_xc[execname, self->xc_func, self->xc_cpu] = sum(arg0);"
240b47b5b34SRafael Vanoni "	self->xc_func = 0;"
241b47b5b34SRafael Vanoni "	self->xc_cpu = 0;"
242b47b5b34SRafael Vanoni "	self->cpu_known = 0;"
243b47b5b34SRafael Vanoni "}";
244b47b5b34SRafael Vanoni 
245b47b5b34SRafael Vanoni /*
246b47b5b34SRafael Vanoni  * sparcv9 platform specific display messages
247b47b5b34SRafael Vanoni  */
248*9bbf5ba1SRafael Vanoni const char *g_msg_idle_state = "Idle Power States";
249b47b5b34SRafael Vanoni const char *g_msg_freq_state = "Frequency Levels";
250*9bbf5ba1SRafael Vanoni const char *g_msg_freq_enable = "P - Enable CPU PM";
251