ia64/xen-unstable

view xen/common/perfc.c @ 10570:8dc4af3f192c

[IA64] Implement and use DOM0_DOMAIN_STEUP.

DOM0_GETMEMLIST now reads ptes and use gpfn.
Domain builder reworked: calls DOMAIN_SETUP, setup start_info page.
SAL data are now in domain memory.
is_vti field added in domain.arch.
Many cleanups (indentation, static, warnings).

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Wed Jul 05 09:28:32 2006 -0600 (2006-07-05)
parents 808430428622
children 7924b6bd728a
line source
2 #include <xen/lib.h>
3 #include <xen/smp.h>
4 #include <xen/time.h>
5 #include <xen/perfc.h>
6 #include <xen/keyhandler.h>
7 #include <xen/spinlock.h>
8 #include <xen/mm.h>
9 #include <xen/guest_access.h>
10 #include <public/dom0_ops.h>
12 #undef PERFCOUNTER
13 #undef PERFCOUNTER_CPU
14 #undef PERFCOUNTER_ARRAY
15 #undef PERFSTATUS
16 #undef PERFSTATUS_CPU
17 #undef PERFSTATUS_ARRAY
18 #define PERFCOUNTER( var, name ) { name, TYPE_SINGLE, 0 },
19 #define PERFCOUNTER_CPU( var, name ) { name, TYPE_CPU, 0 },
20 #define PERFCOUNTER_ARRAY( var, name, size ) { name, TYPE_ARRAY, size },
21 #define PERFSTATUS( var, name ) { name, TYPE_S_SINGLE, 0 },
22 #define PERFSTATUS_CPU( var, name ) { name, TYPE_S_CPU, 0 },
23 #define PERFSTATUS_ARRAY( var, name, size ) { name, TYPE_S_ARRAY, size },
24 static struct {
25 char *name;
26 enum { TYPE_SINGLE, TYPE_CPU, TYPE_ARRAY,
27 TYPE_S_SINGLE, TYPE_S_CPU, TYPE_S_ARRAY
28 } type;
29 int nr_elements;
30 } perfc_info[] = {
31 #include <xen/perfc_defn.h>
32 };
34 #define NR_PERFCTRS (sizeof(perfc_info) / sizeof(perfc_info[0]))
36 struct perfcounter perfcounters;
38 void perfc_printall(unsigned char key)
39 {
40 unsigned int i, j, sum;
41 s_time_t now = NOW();
42 atomic_t *counters = (atomic_t *)&perfcounters;
44 printk("Xen performance counters SHOW (now = 0x%08X:%08X)\n",
45 (u32)(now>>32), (u32)now);
47 for ( i = 0; i < NR_PERFCTRS; i++ )
48 {
49 printk("%-32s ", perfc_info[i].name);
50 switch ( perfc_info[i].type )
51 {
52 case TYPE_SINGLE:
53 case TYPE_S_SINGLE:
54 printk("TOTAL[%10d]", atomic_read(&counters[0]));
55 counters += 1;
56 break;
57 case TYPE_CPU:
58 case TYPE_S_CPU:
59 sum = 0;
60 for_each_online_cpu ( j )
61 sum += atomic_read(&counters[j]);
62 printk("TOTAL[%10u]", sum);
63 if (sum)
64 {
65 for_each_online_cpu ( j )
66 printk(" CPU%02d[%10d]", j, atomic_read(&counters[j]));
67 }
68 counters += NR_CPUS;
69 break;
70 case TYPE_ARRAY:
71 case TYPE_S_ARRAY:
72 for ( j = sum = 0; j < perfc_info[i].nr_elements; j++ )
73 sum += atomic_read(&counters[j]);
74 printk("TOTAL[%10u]", sum);
75 #ifdef PERF_ARRAYS
76 if (sum)
77 {
78 for ( j = 0; j < perfc_info[i].nr_elements; j++ )
79 {
80 if ( (j % 4) == 0 )
81 printk("\n ");
82 printk(" ARR%02d[%10d]", j, atomic_read(&counters[j]));
83 }
84 }
85 #endif
86 counters += j;
87 break;
88 }
89 printk("\n");
90 }
92 #ifdef PERF_ARRAYS
93 ptwr_eip_stat_print();
94 #endif
95 }
97 void perfc_reset(unsigned char key)
98 {
99 unsigned int i, j;
100 s_time_t now = NOW();
101 atomic_t *counters = (atomic_t *)&perfcounters;
103 if ( key != '\0' )
104 printk("Xen performance counters RESET (now = 0x%08X:%08X)\n",
105 (u32)(now>>32), (u32)now);
107 /* leave STATUS counters alone -- don't reset */
109 for ( i = 0; i < NR_PERFCTRS; i++ )
110 {
111 switch ( perfc_info[i].type )
112 {
113 case TYPE_SINGLE:
114 atomic_set(&counters[0],0);
115 case TYPE_S_SINGLE:
116 counters += 1;
117 break;
118 case TYPE_CPU:
119 for ( j = 0; j < NR_CPUS; j++ )
120 atomic_set(&counters[j],0);
121 case TYPE_S_CPU:
122 counters += NR_CPUS;
123 break;
124 case TYPE_ARRAY:
125 for ( j = 0; j < perfc_info[i].nr_elements; j++ )
126 atomic_set(&counters[j],0);
127 case TYPE_S_ARRAY:
128 counters += perfc_info[i].nr_elements;
129 break;
130 }
131 }
133 #ifdef PERF_ARRAYS
134 ptwr_eip_stat_reset();
135 #endif
136 }
138 static dom0_perfc_desc_t perfc_d[NR_PERFCTRS];
139 static int perfc_init = 0;
140 static int perfc_copy_info(XEN_GUEST_HANDLE(dom0_perfc_desc_t) desc)
141 {
142 unsigned int i, j;
143 atomic_t *counters = (atomic_t *)&perfcounters;
145 if ( guest_handle_is_null(desc) )
146 return 0;
148 /* We only copy the name and array-size information once. */
149 if ( !perfc_init )
150 {
151 for ( i = 0; i < NR_PERFCTRS; i++ )
152 {
153 strncpy(perfc_d[i].name, perfc_info[i].name,
154 sizeof(perfc_d[i].name));
155 perfc_d[i].name[sizeof(perfc_d[i].name)-1] = '\0';
157 switch ( perfc_info[i].type )
158 {
159 case TYPE_SINGLE:
160 case TYPE_S_SINGLE:
161 perfc_d[i].nr_vals = 1;
162 break;
163 case TYPE_CPU:
164 case TYPE_S_CPU:
165 perfc_d[i].nr_vals = num_online_cpus();
166 break;
167 case TYPE_ARRAY:
168 case TYPE_S_ARRAY:
169 perfc_d[i].nr_vals = perfc_info[i].nr_elements;
170 break;
171 }
173 if ( perfc_d[i].nr_vals > ARRAY_SIZE(perfc_d[i].vals) )
174 perfc_d[i].nr_vals = ARRAY_SIZE(perfc_d[i].vals);
175 }
177 perfc_init = 1;
178 }
180 /* We gather the counts together every time. */
181 for ( i = 0; i < NR_PERFCTRS; i++ )
182 {
183 switch ( perfc_info[i].type )
184 {
185 case TYPE_SINGLE:
186 case TYPE_S_SINGLE:
187 perfc_d[i].vals[0] = atomic_read(&counters[0]);
188 counters += 1;
189 break;
190 case TYPE_CPU:
191 case TYPE_S_CPU:
192 for ( j = 0; j < perfc_d[i].nr_vals; j++ )
193 perfc_d[i].vals[j] = atomic_read(&counters[j]);
194 counters += NR_CPUS;
195 break;
196 case TYPE_ARRAY:
197 case TYPE_S_ARRAY:
198 for ( j = 0; j < perfc_d[i].nr_vals; j++ )
199 perfc_d[i].vals[j] = atomic_read(&counters[j]);
200 counters += perfc_info[i].nr_elements;
201 break;
202 }
203 }
205 return (copy_to_guest(desc, (dom0_perfc_desc_t *)perfc_d, NR_PERFCTRS) ?
206 -EFAULT : 0);
207 }
209 /* Dom0 control of perf counters */
210 int perfc_control(dom0_perfccontrol_t *pc)
211 {
212 static DEFINE_SPINLOCK(lock);
213 u32 op = pc->op;
214 int rc;
216 pc->nr_counters = NR_PERFCTRS;
218 spin_lock(&lock);
220 switch ( op )
221 {
222 case DOM0_PERFCCONTROL_OP_RESET:
223 perfc_copy_info(pc->desc);
224 perfc_reset(0);
225 rc = 0;
226 break;
228 case DOM0_PERFCCONTROL_OP_QUERY:
229 perfc_copy_info(pc->desc);
230 rc = 0;
231 break;
233 default:
234 rc = -EINVAL;
235 break;
236 }
238 spin_unlock(&lock);
240 return rc;
241 }
243 /*
244 * Local variables:
245 * mode: C
246 * c-set-style: "BSD"
247 * c-basic-offset: 4
248 * tab-width: 4
249 * indent-tabs-mode: nil
250 * End:
251 */