This source file includes following definitions.
- uvmhist_print
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 #ifndef _UVM_UVM_STAT_H_
39 #define _UVM_UVM_STAT_H_
40
41 #include <sys/queue.h>
42
43
44
45
46
47
48
49
50
51 #define UVMCNT_MASK 0xf
52 #define UVMCNT_CNT 0
53 #define UVMCNT_DEV 1
54
55 struct uvm_cnt {
56 int c;
57 int t;
58 struct uvm_cnt *next;
59 char *name;
60 void *p;
61 };
62
63 #ifdef _KERNEL
64
65 extern struct uvm_cnt *uvm_cnt_head;
66
67
68
69
70
71 #define UVMCNT_INIT(CNT,TYP,VAL,NAM,PRIV) \
72 do { \
73 CNT.c = VAL; \
74 CNT.t = TYP; \
75 CNT.next = uvm_cnt_head; \
76 uvm_cnt_head = &CNT; \
77 CNT.name = NAM; \
78 CNT.p = PRIV; \
79 } while (0)
80
81 #define UVMCNT_SET(C,V) \
82 do { \
83 (C).c = (V); \
84 } while (0)
85
86 #define UVMCNT_ADD(C,V) \
87 do { \
88 (C).c += (V); \
89 } while (0)
90
91 #define UVMCNT_INCR(C) UVMCNT_ADD(C,1)
92 #define UVMCNT_DECR(C) UVMCNT_ADD(C,-1)
93
94 #endif
95
96
97
98
99
100 struct uvm_history_ent {
101 struct timeval tv;
102 char *fmt;
103 size_t fmtlen;
104 char *fn;
105 size_t fnlen;
106 u_long call;
107 u_long v[4];
108 };
109
110 struct uvm_history {
111 const char *name;
112 size_t namelen;
113 LIST_ENTRY(uvm_history) list;
114 int n;
115 int f;
116 simple_lock_data_t l;
117 struct uvm_history_ent *e;
118 };
119
120 LIST_HEAD(uvm_history_head, uvm_history);
121
122
123
124
125
126
127
128
129 #define MAXHISTS 32
130
131
132 #define UVMHIST_MAPHIST 0x00000001
133 #define UVMHIST_PDHIST 0x00000002
134 #define UVMHIST_UBCHIST 0x00000004
135 #define UVMHIST_PGHIST 0x00000008
136
137 #ifdef _KERNEL
138
139
140
141
142
143 #ifndef UVMHIST
144 #define UVMHIST_DECL(NAME)
145 #define UVMHIST_INIT(NAME,N)
146 #define UVMHIST_INIT_STATIC(NAME,BUF)
147 #define UVMHIST_LOG(NAME,FMT,A,B,C,D)
148 #define UVMHIST_CALLED(NAME)
149 #define UVMHIST_FUNC(FNAME)
150 #define uvmhist_dump(NAME)
151 #else
152 extern struct uvm_history_head uvm_histories;
153
154 #define UVMHIST_DECL(NAME) struct uvm_history NAME
155
156 #define UVMHIST_INIT(NAME,N) \
157 do { \
158 (NAME).name = __STRING(NAME); \
159 (NAME).namelen = strlen((NAME).name); \
160 (NAME).n = (N); \
161 (NAME).f = 0; \
162 simple_lock_init(&(NAME).l); \
163 (NAME).e = (struct uvm_history_ent *) \
164 malloc(sizeof(struct uvm_history_ent) * (N), M_TEMP, \
165 M_WAITOK); \
166 memset((NAME).e, 0, sizeof(struct uvm_history_ent) * (N)); \
167 LIST_INSERT_HEAD(&uvm_histories, &(NAME), list); \
168 } while (0)
169
170 #define UVMHIST_INIT_STATIC(NAME,BUF) \
171 do { \
172 (NAME).name = __STRING(NAME); \
173 (NAME).namelen = strlen((NAME).name); \
174 (NAME).n = sizeof(BUF) / sizeof(struct uvm_history_ent); \
175 (NAME).f = 0; \
176 simple_lock_init(&(NAME).l); \
177 (NAME).e = (struct uvm_history_ent *) (BUF); \
178 memset((NAME).e, 0, sizeof(struct uvm_history_ent) * (NAME).n); \
179 LIST_INSERT_HEAD(&uvm_histories, &(NAME), list); \
180 } while (0)
181
182 #if defined(UVMHIST_PRINT)
183 extern int uvmhist_print_enabled;
184 #define UVMHIST_PRINTNOW(E) \
185 do { \
186 if (uvmhist_print_enabled) { \
187 uvmhist_print(E); \
188 DELAY(100000); \
189 } \
190 } while (0)
191 #else
192 #define UVMHIST_PRINTNOW(E)
193 #endif
194
195 #define UVMHIST_LOG(NAME,FMT,A,B,C,D) \
196 do { \
197 int _i_, _s_ = splhigh(); \
198 simple_lock(&(NAME).l); \
199 _i_ = (NAME).f; \
200 (NAME).f = (_i_ + 1) % (NAME).n; \
201 simple_unlock(&(NAME).l); \
202 splx(_s_); \
203 if (!cold) \
204 microtime(&(NAME).e[_i_].tv); \
205 (NAME).e[_i_].fmt = (FMT); \
206 (NAME).e[_i_].fmtlen = strlen((NAME).e[_i_].fmt); \
207 (NAME).e[_i_].fn = _uvmhist_name; \
208 (NAME).e[_i_].fnlen = strlen((NAME).e[_i_].fn); \
209 (NAME).e[_i_].call = _uvmhist_call; \
210 (NAME).e[_i_].v[0] = (u_long)(A); \
211 (NAME).e[_i_].v[1] = (u_long)(B); \
212 (NAME).e[_i_].v[2] = (u_long)(C); \
213 (NAME).e[_i_].v[3] = (u_long)(D); \
214 UVMHIST_PRINTNOW(&((NAME).e[_i_])); \
215 } while (0)
216
217 #define UVMHIST_CALLED(NAME) \
218 do { \
219 { \
220 int s = splhigh(); \
221 simple_lock(&(NAME).l); \
222 _uvmhist_call = _uvmhist_cnt++; \
223 simple_unlock(&(NAME).l); \
224 splx(s); \
225 } \
226 UVMHIST_LOG(NAME,"called!", 0, 0, 0, 0); \
227 } while (0)
228
229 #define UVMHIST_FUNC(FNAME) \
230 static int _uvmhist_cnt = 0; \
231 static char *_uvmhist_name = FNAME; \
232 int _uvmhist_call;
233
234 static __inline void uvmhist_print(struct uvm_history_ent *);
235
236 static __inline void
237 uvmhist_print(e)
238 struct uvm_history_ent *e;
239 {
240 printf("%06ld.%06ld ", e->tv.tv_sec, e->tv.tv_usec);
241 printf("%s#%ld: ", e->fn, e->call);
242 printf(e->fmt, e->v[0], e->v[1], e->v[2], e->v[3]);
243 printf("\n");
244 }
245 #endif
246
247 #endif
248
249 #endif