ia64/xen-unstable

view xen/arch/ia64/xen/privop_stat.c @ 10929:7cde0d938ef4

[IA64] convert more privop_stat to perfc

Convert most privop stats to perfc.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Fri Aug 04 09:02:43 2006 -0600 (2006-08-04)
parents 3d6c1af609bf
children 7c79d49033c6
line source
1 #include <asm/privop_stat.h>
2 #include <asm/vhpt.h>
3 #include <xen/lib.h>
4 #include <asm/uaccess.h>
6 #ifdef PRIVOP_ADDR_COUNT
7 #define PRIVOP_COUNT_NINSTS 2
8 #define PRIVOP_COUNT_NADDRS 30
10 struct privop_addr_count {
11 const char *instname;
12 unsigned long addr[PRIVOP_COUNT_NADDRS];
13 unsigned long count[PRIVOP_COUNT_NADDRS];
14 unsigned long overflow;
15 };
18 static struct privop_addr_count privop_addr_counter[PRIVOP_COUNT_NINSTS] = {
19 [_GET_IFA] = { "=ifa", { 0 }, { 0 }, 0 },
20 [_THASH] = { "thash", { 0 }, { 0 }, 0 }
21 };
23 void privop_count_addr(unsigned long iip, int inst)
24 {
25 struct privop_addr_count *v = &privop_addr_counter[inst];
26 int i;
28 if (inst >= PRIVOP_COUNT_NINSTS)
29 return;
30 for (i = 0; i < PRIVOP_COUNT_NADDRS; i++) {
31 if (!v->addr[i]) {
32 v->addr[i] = iip;
33 v->count[i]++;
34 return;
35 }
36 else if (v->addr[i] == iip) {
37 v->count[i]++;
38 return;
39 }
40 }
41 v->overflow++;;
42 }
44 static int dump_privop_addrs(char *buf)
45 {
46 int i, j;
47 char *s = buf;
48 s += sprintf(s, "Privop addresses:\n");
49 for (i = 0; i < PRIVOP_COUNT_NINSTS; i++) {
50 struct privop_addr_count *v = &privop_addr_counter[i];
51 s += sprintf(s, "%s:\n", v->instname);
52 for (j = 0; j < PRIVOP_COUNT_NADDRS; j++) {
53 if (!v->addr[j])
54 break;
55 s += sprintf(s, " at 0x%lx #%ld\n",
56 v->addr[j], v->count[j]);
57 }
58 if (v->overflow)
59 s += sprintf(s, " other #%ld\n", v->overflow);
60 }
61 return s - buf;
62 }
64 static void zero_privop_addrs(void)
65 {
66 int i,j;
67 for (i = 0; i < PRIVOP_COUNT_NINSTS; i++) {
68 struct privop_addr_count *v = &privop_addr_counter[i];
69 for (j = 0; j < PRIVOP_COUNT_NADDRS; j++)
70 v->addr[j] = v->count[j] = 0;
71 v->overflow = 0;
72 }
73 }
74 #endif
76 /**************************************************************************
77 Privileged operation instrumentation routines
78 **************************************************************************/
80 #if 0
81 static const char * const Mpriv_str[64] = {
82 "mov_to_rr", "mov_to_dbr", "mov_to_ibr", "mov_to_pkr",
83 "mov_to_pmc", "mov_to_pmd", "<0x06>", "<0x07>",
84 "<0x08>", "ptc_l", "ptc_g", "ptc_ga",
85 "ptr_d", "ptr_i", "itr_d", "itr_i",
86 "mov_from_rr", "mov_from_dbr", "mov_from_ibr", "mov_from_pkr",
87 "mov_from_pmc", "<0x15>", "<0x16>", "<0x17>",
88 "<0x18>", "<0x19>", "privified-thash", "privified-ttag",
89 "<0x1c>", "<0x1d>", "tpa", "tak",
90 "<0x20>", "<0x21>", "<0x22>", "<0x23>",
91 "mov_from_cr", "mov_from_psr", "<0x26>", "<0x27>",
92 "<0x28>", "<0x29>", "<0x2a>", "<0x2b>",
93 "mov_to_cr", "mov_to_psr", "itc_d", "itc_i",
94 "<0x30>", "<0x31>", "<0x32>", "<0x33>",
95 "ptc_e", "<0x35>", "<0x36>", "<0x37>",
96 "<0x38>", "<0x39>", "<0x3a>", "<0x3b>",
97 "<0x3c>", "<0x3d>", "<0x3e>", "<0x3f>"
98 };
100 #define RS "Rsvd"
101 static const char * const cr_str[128] = {
102 "dcr","itm","iva",RS,RS,RS,RS,RS,
103 "pta",RS,RS,RS,RS,RS,RS,RS,
104 "ipsr","isr",RS,"iip","ifa","itir","iipa","ifs",
105 "iim","iha",RS,RS,RS,RS,RS,RS,
106 RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
107 RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
108 "lid","ivr","tpr","eoi","irr0","irr1","irr2","irr3",
109 "itv","pmv","cmcv",RS,RS,RS,RS,RS,
110 "lrr0","lrr1",RS,RS,RS,RS,RS,RS,
111 RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
112 RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
113 RS,RS,RS,RS,RS,RS,RS,RS
114 };
116 static const char * const hyperpriv_str[HYPERPRIVOP_MAX+1] = {
117 0, "rfi", "rsm.dt", "ssm.dt", "cover", "itc.d", "itc.i", "ssm.i",
118 "=ivr", "=tpr", "tpr=", "eoi", "itm=", "thash", "ptc.ga", "itr.d",
119 "=rr", "rr=", "kr=", "fc", "=cpuid", "=pmd", "=ar.eflg", "ar.eflg="
120 };
121 #endif
123 #define TMPBUFLEN 8*1024
124 int dump_privop_counts_to_user(char __user *ubuf, int len)
125 {
126 char buf[TMPBUFLEN];
127 int n;
129 if (len < TMPBUFLEN)
130 return -1;
132 n = 0;
133 #ifdef PRIVOP_ADDR_COUNT
134 n += dump_privop_addrs(buf + n);
135 #endif
136 n += dump_vhpt_stats(buf + n);
137 if (__copy_to_user(ubuf,buf,n))
138 return -1;
139 return n;
140 }
142 int zero_privop_counts_to_user(char __user *ubuf, int len)
143 {
144 #ifdef PRIVOP_ADDR_COUNT
145 zero_privop_addrs();
146 #endif
147 return 0;
148 }