ctdb-tools: Produce machine readable output with new function printm()
[Samba.git] / source3 / include / smbprofile.h
blobea241658c03189b25f41f667ee684824a9df7e86
1 #ifndef _PROFILE_H_
2 #define _PROFILE_H_
3 /*
4 Unix SMB/CIFS implementation.
5 store smbd profiling information in shared memory
6 Copyright (C) Andrew Tridgell 1999
7 Copyright (C) James Peach 2006
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #ifdef WITH_PROFILE
26 #define SMBPROFILE_STATS_ALL_SECTIONS \
27 SMBPROFILE_STATS_START \
29 SMBPROFILE_STATS_SECTION_START("SMBD loop") \
30 SMBPROFILE_STATS_COUNT(connect) \
31 SMBPROFILE_STATS_COUNT(disconnect) \
32 SMBPROFILE_STATS_BASIC(idle) \
33 SMBPROFILE_STATS_COUNT(request) \
34 SMBPROFILE_STATS_BASIC(push_sec_ctx) \
35 SMBPROFILE_STATS_BASIC(set_sec_ctx) \
36 SMBPROFILE_STATS_BASIC(set_root_sec_ctx) \
37 SMBPROFILE_STATS_BASIC(pop_sec_ctx) \
38 SMBPROFILE_STATS_SECTION_END \
40 SMBPROFILE_STATS_SECTION_START("System Calls") \
41 SMBPROFILE_STATS_BASIC(syscall_opendir) \
42 SMBPROFILE_STATS_BASIC(syscall_fdopendir) \
43 SMBPROFILE_STATS_BASIC(syscall_readdir) \
44 SMBPROFILE_STATS_BASIC(syscall_seekdir) \
45 SMBPROFILE_STATS_BASIC(syscall_telldir) \
46 SMBPROFILE_STATS_BASIC(syscall_rewinddir) \
47 SMBPROFILE_STATS_BASIC(syscall_mkdir) \
48 SMBPROFILE_STATS_BASIC(syscall_rmdir) \
49 SMBPROFILE_STATS_BASIC(syscall_closedir) \
50 SMBPROFILE_STATS_BASIC(syscall_open) \
51 SMBPROFILE_STATS_BASIC(syscall_createfile) \
52 SMBPROFILE_STATS_BASIC(syscall_close) \
53 SMBPROFILE_STATS_BYTES(syscall_read) \
54 SMBPROFILE_STATS_BYTES(syscall_pread) \
55 SMBPROFILE_STATS_BYTES(syscall_asys_pread) \
56 SMBPROFILE_STATS_BYTES(syscall_write) \
57 SMBPROFILE_STATS_BYTES(syscall_pwrite) \
58 SMBPROFILE_STATS_BYTES(syscall_asys_pwrite) \
59 SMBPROFILE_STATS_BASIC(syscall_lseek) \
60 SMBPROFILE_STATS_BYTES(syscall_sendfile) \
61 SMBPROFILE_STATS_BYTES(syscall_recvfile) \
62 SMBPROFILE_STATS_BASIC(syscall_rename) \
63 SMBPROFILE_STATS_BASIC(syscall_rename_at) \
64 SMBPROFILE_STATS_BASIC(syscall_fsync) \
65 SMBPROFILE_STATS_BASIC(syscall_asys_fsync) \
66 SMBPROFILE_STATS_BASIC(syscall_stat) \
67 SMBPROFILE_STATS_BASIC(syscall_fstat) \
68 SMBPROFILE_STATS_BASIC(syscall_lstat) \
69 SMBPROFILE_STATS_BASIC(syscall_get_alloc_size) \
70 SMBPROFILE_STATS_BASIC(syscall_unlink) \
71 SMBPROFILE_STATS_BASIC(syscall_chmod) \
72 SMBPROFILE_STATS_BASIC(syscall_fchmod) \
73 SMBPROFILE_STATS_BASIC(syscall_chown) \
74 SMBPROFILE_STATS_BASIC(syscall_fchown) \
75 SMBPROFILE_STATS_BASIC(syscall_lchown) \
76 SMBPROFILE_STATS_BASIC(syscall_chdir) \
77 SMBPROFILE_STATS_BASIC(syscall_getwd) \
78 SMBPROFILE_STATS_BASIC(syscall_ntimes) \
79 SMBPROFILE_STATS_BASIC(syscall_ftruncate) \
80 SMBPROFILE_STATS_BASIC(syscall_fallocate) \
81 SMBPROFILE_STATS_BASIC(syscall_fcntl_lock) \
82 SMBPROFILE_STATS_BASIC(syscall_kernel_flock) \
83 SMBPROFILE_STATS_BASIC(syscall_linux_setlease) \
84 SMBPROFILE_STATS_BASIC(syscall_fcntl_getlock) \
85 SMBPROFILE_STATS_BASIC(syscall_readlink) \
86 SMBPROFILE_STATS_BASIC(syscall_symlink) \
87 SMBPROFILE_STATS_BASIC(syscall_link) \
88 SMBPROFILE_STATS_BASIC(syscall_mknod) \
89 SMBPROFILE_STATS_BASIC(syscall_realpath) \
90 SMBPROFILE_STATS_BASIC(syscall_get_quota) \
91 SMBPROFILE_STATS_BASIC(syscall_set_quota) \
92 SMBPROFILE_STATS_BASIC(syscall_get_sd) \
93 SMBPROFILE_STATS_BASIC(syscall_set_sd) \
94 SMBPROFILE_STATS_BASIC(syscall_brl_lock) \
95 SMBPROFILE_STATS_BASIC(syscall_brl_unlock) \
96 SMBPROFILE_STATS_BASIC(syscall_brl_cancel) \
97 SMBPROFILE_STATS_SECTION_END \
99 SMBPROFILE_STATS_SECTION_START("ACL Calls") \
100 SMBPROFILE_STATS_BASIC(get_nt_acl) \
101 SMBPROFILE_STATS_BASIC(fget_nt_acl) \
102 SMBPROFILE_STATS_BASIC(fset_nt_acl) \
103 SMBPROFILE_STATS_BASIC(chmod_acl) \
104 SMBPROFILE_STATS_BASIC(fchmod_acl) \
105 SMBPROFILE_STATS_SECTION_END \
107 SMBPROFILE_STATS_SECTION_START("Stat Cache") \
108 SMBPROFILE_STATS_COUNT(statcache_lookups) \
109 SMBPROFILE_STATS_COUNT(statcache_misses) \
110 SMBPROFILE_STATS_COUNT(statcache_hits) \
111 SMBPROFILE_STATS_SECTION_END \
113 SMBPROFILE_STATS_SECTION_START("Write Cache") \
114 SMBPROFILE_STATS_COUNT(writecache_allocations) \
115 SMBPROFILE_STATS_COUNT(writecache_deallocations) \
116 SMBPROFILE_STATS_COUNT(writecache_cached_reads) \
117 SMBPROFILE_STATS_COUNT(writecache_total_writes) \
118 SMBPROFILE_STATS_COUNT(writecache_init_writes) \
119 SMBPROFILE_STATS_COUNT(writecache_abutted_writes) \
120 SMBPROFILE_STATS_COUNT(writecache_non_oplock_writes) \
121 SMBPROFILE_STATS_COUNT(writecache_direct_writes) \
122 SMBPROFILE_STATS_COUNT(writecache_cached_writes) \
123 SMBPROFILE_STATS_COUNT(writecache_perfect_writes) \
124 SMBPROFILE_STATS_COUNT(writecache_flush_reason_seek) \
125 SMBPROFILE_STATS_COUNT(writecache_flush_reason_read) \
126 SMBPROFILE_STATS_COUNT(writecache_flush_reason_readraw) \
127 SMBPROFILE_STATS_COUNT(writecache_flush_reason_write) \
128 SMBPROFILE_STATS_COUNT(writecache_flush_reason_oplock) \
129 SMBPROFILE_STATS_COUNT(writecache_flush_reason_close) \
130 SMBPROFILE_STATS_COUNT(writecache_flush_reason_sync) \
131 SMBPROFILE_STATS_COUNT(writecache_flush_reason_sizechange) \
132 SMBPROFILE_STATS_SECTION_END \
134 SMBPROFILE_STATS_SECTION_START("SMB Calls") \
135 SMBPROFILE_STATS_BASIC(SMBmkdir) \
136 SMBPROFILE_STATS_BASIC(SMBrmdir) \
137 SMBPROFILE_STATS_BASIC(SMBopen) \
138 SMBPROFILE_STATS_BASIC(SMBcreate) \
139 SMBPROFILE_STATS_BASIC(SMBclose) \
140 SMBPROFILE_STATS_BASIC(SMBflush) \
141 SMBPROFILE_STATS_BASIC(SMBunlink) \
142 SMBPROFILE_STATS_BASIC(SMBmv) \
143 SMBPROFILE_STATS_BASIC(SMBgetatr) \
144 SMBPROFILE_STATS_BASIC(SMBsetatr) \
145 SMBPROFILE_STATS_BASIC(SMBread) \
146 SMBPROFILE_STATS_BASIC(SMBwrite) \
147 SMBPROFILE_STATS_BASIC(SMBlock) \
148 SMBPROFILE_STATS_BASIC(SMBunlock) \
149 SMBPROFILE_STATS_BASIC(SMBctemp) \
150 SMBPROFILE_STATS_BASIC(SMBmknew) \
151 SMBPROFILE_STATS_BASIC(SMBcheckpath) \
152 SMBPROFILE_STATS_BASIC(SMBexit) \
153 SMBPROFILE_STATS_BASIC(SMBlseek) \
154 SMBPROFILE_STATS_BASIC(SMBlockread) \
155 SMBPROFILE_STATS_BASIC(SMBwriteunlock) \
156 SMBPROFILE_STATS_BASIC(SMBreadbraw) \
157 SMBPROFILE_STATS_BASIC(SMBreadBmpx) \
158 SMBPROFILE_STATS_BASIC(SMBreadBs) \
159 SMBPROFILE_STATS_BASIC(SMBwritebraw) \
160 SMBPROFILE_STATS_BASIC(SMBwriteBmpx) \
161 SMBPROFILE_STATS_BASIC(SMBwriteBs) \
162 SMBPROFILE_STATS_BASIC(SMBwritec) \
163 SMBPROFILE_STATS_BASIC(SMBsetattrE) \
164 SMBPROFILE_STATS_BASIC(SMBgetattrE) \
165 SMBPROFILE_STATS_BASIC(SMBlockingX) \
166 SMBPROFILE_STATS_BASIC(SMBtrans) \
167 SMBPROFILE_STATS_BASIC(SMBtranss) \
168 SMBPROFILE_STATS_BASIC(SMBioctl) \
169 SMBPROFILE_STATS_BASIC(SMBioctls) \
170 SMBPROFILE_STATS_BASIC(SMBcopy) \
171 SMBPROFILE_STATS_BASIC(SMBmove) \
172 SMBPROFILE_STATS_BASIC(SMBecho) \
173 SMBPROFILE_STATS_BASIC(SMBwriteclose) \
174 SMBPROFILE_STATS_BASIC(SMBopenX) \
175 SMBPROFILE_STATS_BASIC(SMBreadX) \
176 SMBPROFILE_STATS_BASIC(SMBwriteX) \
177 SMBPROFILE_STATS_BASIC(SMBtrans2) \
178 SMBPROFILE_STATS_BASIC(SMBtranss2) \
179 SMBPROFILE_STATS_BASIC(SMBfindclose) \
180 SMBPROFILE_STATS_BASIC(SMBfindnclose) \
181 SMBPROFILE_STATS_BASIC(SMBtcon) \
182 SMBPROFILE_STATS_BASIC(SMBtdis) \
183 SMBPROFILE_STATS_BASIC(SMBnegprot) \
184 SMBPROFILE_STATS_BASIC(SMBsesssetupX) \
185 SMBPROFILE_STATS_BASIC(SMBulogoffX) \
186 SMBPROFILE_STATS_BASIC(SMBtconX) \
187 SMBPROFILE_STATS_BASIC(SMBdskattr) \
188 SMBPROFILE_STATS_BASIC(SMBsearch) \
189 SMBPROFILE_STATS_BASIC(SMBffirst) \
190 SMBPROFILE_STATS_BASIC(SMBfunique) \
191 SMBPROFILE_STATS_BASIC(SMBfclose) \
192 SMBPROFILE_STATS_BASIC(SMBnttrans) \
193 SMBPROFILE_STATS_BASIC(SMBnttranss) \
194 SMBPROFILE_STATS_BASIC(SMBntcreateX) \
195 SMBPROFILE_STATS_BASIC(SMBntcancel) \
196 SMBPROFILE_STATS_BASIC(SMBntrename) \
197 SMBPROFILE_STATS_BASIC(SMBsplopen) \
198 SMBPROFILE_STATS_BASIC(SMBsplwr) \
199 SMBPROFILE_STATS_BASIC(SMBsplclose) \
200 SMBPROFILE_STATS_BASIC(SMBsplretq) \
201 SMBPROFILE_STATS_BASIC(SMBsends) \
202 SMBPROFILE_STATS_BASIC(SMBsendb) \
203 SMBPROFILE_STATS_BASIC(SMBfwdname) \
204 SMBPROFILE_STATS_BASIC(SMBcancelf) \
205 SMBPROFILE_STATS_BASIC(SMBgetmac) \
206 SMBPROFILE_STATS_BASIC(SMBsendstrt) \
207 SMBPROFILE_STATS_BASIC(SMBsendend) \
208 SMBPROFILE_STATS_BASIC(SMBsendtxt) \
209 SMBPROFILE_STATS_BASIC(SMBinvalid) \
210 SMBPROFILE_STATS_SECTION_END \
212 SMBPROFILE_STATS_SECTION_START("Trans2 Calls") \
213 SMBPROFILE_STATS_BASIC(Trans2_open) \
214 SMBPROFILE_STATS_BASIC(Trans2_findfirst) \
215 SMBPROFILE_STATS_BASIC(Trans2_findnext) \
216 SMBPROFILE_STATS_BASIC(Trans2_qfsinfo) \
217 SMBPROFILE_STATS_BASIC(Trans2_setfsinfo) \
218 SMBPROFILE_STATS_BASIC(Trans2_qpathinfo) \
219 SMBPROFILE_STATS_BASIC(Trans2_setpathinfo) \
220 SMBPROFILE_STATS_BASIC(Trans2_qfileinfo) \
221 SMBPROFILE_STATS_BASIC(Trans2_setfileinfo) \
222 SMBPROFILE_STATS_BASIC(Trans2_fsctl) \
223 SMBPROFILE_STATS_BASIC(Trans2_ioctl) \
224 SMBPROFILE_STATS_BASIC(Trans2_findnotifyfirst) \
225 SMBPROFILE_STATS_BASIC(Trans2_findnotifynext) \
226 SMBPROFILE_STATS_BASIC(Trans2_mkdir) \
227 SMBPROFILE_STATS_BASIC(Trans2_session_setup) \
228 SMBPROFILE_STATS_BASIC(Trans2_get_dfs_referral) \
229 SMBPROFILE_STATS_BASIC(Trans2_report_dfs_inconsistancy) \
230 SMBPROFILE_STATS_SECTION_END \
232 SMBPROFILE_STATS_SECTION_START("NT Transact Calls") \
233 SMBPROFILE_STATS_BASIC(NT_transact_create) \
234 SMBPROFILE_STATS_BASIC(NT_transact_ioctl) \
235 SMBPROFILE_STATS_BASIC(NT_transact_set_security_desc) \
236 SMBPROFILE_STATS_BASIC(NT_transact_notify_change) \
237 SMBPROFILE_STATS_BASIC(NT_transact_rename) \
238 SMBPROFILE_STATS_BASIC(NT_transact_query_security_desc) \
239 SMBPROFILE_STATS_BASIC(NT_transact_get_user_quota) \
240 SMBPROFILE_STATS_BASIC(NT_transact_set_user_quota) \
241 SMBPROFILE_STATS_SECTION_END \
243 SMBPROFILE_STATS_SECTION_START("SMB2 Calls") \
244 SMBPROFILE_STATS_IOBYTES(smb2_negprot) \
245 SMBPROFILE_STATS_IOBYTES(smb2_sesssetup) \
246 SMBPROFILE_STATS_IOBYTES(smb2_logoff) \
247 SMBPROFILE_STATS_IOBYTES(smb2_tcon) \
248 SMBPROFILE_STATS_IOBYTES(smb2_tdis) \
249 SMBPROFILE_STATS_IOBYTES(smb2_create) \
250 SMBPROFILE_STATS_IOBYTES(smb2_close) \
251 SMBPROFILE_STATS_IOBYTES(smb2_flush) \
252 SMBPROFILE_STATS_IOBYTES(smb2_read) \
253 SMBPROFILE_STATS_IOBYTES(smb2_write) \
254 SMBPROFILE_STATS_IOBYTES(smb2_lock) \
255 SMBPROFILE_STATS_IOBYTES(smb2_ioctl) \
256 SMBPROFILE_STATS_IOBYTES(smb2_cancel) \
257 SMBPROFILE_STATS_IOBYTES(smb2_keepalive) \
258 SMBPROFILE_STATS_IOBYTES(smb2_find) \
259 SMBPROFILE_STATS_IOBYTES(smb2_notify) \
260 SMBPROFILE_STATS_IOBYTES(smb2_getinfo) \
261 SMBPROFILE_STATS_IOBYTES(smb2_setinfo) \
262 SMBPROFILE_STATS_IOBYTES(smb2_break) \
263 SMBPROFILE_STATS_SECTION_END \
265 SMBPROFILE_STATS_END
267 /* this file defines the profile structure in the profile shared
268 memory area */
270 /* time values in the following structure are in microseconds */
272 struct smbprofile_stats_count {
273 uint64_t count; /* number of events */
276 struct smbprofile_stats_time {
277 uint64_t time; /* microseconds */
280 struct smbprofile_stats_time_async {
281 uint64_t start;
282 struct smbprofile_stats_time *stats;
285 struct smbprofile_stats_basic {
286 uint64_t count; /* number of events */
287 uint64_t time; /* microseconds */
290 struct smbprofile_stats_basic_async {
291 uint64_t start;
292 struct smbprofile_stats_basic *stats;
295 struct smbprofile_stats_bytes {
296 uint64_t count; /* number of events */
297 uint64_t time; /* microseconds */
298 uint64_t idle; /* idle time compared to 'time' microseconds */
299 uint64_t bytes; /* bytes */
302 struct smbprofile_stats_bytes_async {
303 uint64_t start;
304 uint64_t idle_start;
305 uint64_t idle_time;
306 struct smbprofile_stats_bytes *stats;
309 struct smbprofile_stats_iobytes {
310 uint64_t count; /* number of events */
311 uint64_t time; /* microseconds */
312 uint64_t idle; /* idle time compared to 'time' microseconds */
313 uint64_t inbytes; /* bytes read */
314 uint64_t outbytes; /* bytes written */
317 struct smbprofile_stats_iobytes_async {
318 uint64_t start;
319 uint64_t idle_start;
320 uint64_t idle_time;
321 struct smbprofile_stats_iobytes *stats;
324 struct profile_stats {
325 #define SMBPROFILE_STATS_START
326 #define SMBPROFILE_STATS_SECTION_START(name)
327 #define SMBPROFILE_STATS_COUNT(name) \
328 struct smbprofile_stats_count name##_stats;
329 #define SMBPROFILE_STATS_TIME(name) \
330 struct smbprofile_stats_time name##_stats;
331 #define SMBPROFILE_STATS_BASIC(name) \
332 struct smbprofile_stats_basic name##_stats;
333 #define SMBPROFILE_STATS_BYTES(name) \
334 struct smbprofile_stats_bytes name##_stats;
335 #define SMBPROFILE_STATS_IOBYTES(name) \
336 struct smbprofile_stats_iobytes name##_stats;
337 #define SMBPROFILE_STATS_SECTION_END
338 #define SMBPROFILE_STATS_END
339 SMBPROFILE_STATS_ALL_SECTIONS
340 #undef SMBPROFILE_STATS_START
341 #undef SMBPROFILE_STATS_SECTION_START
342 #undef SMBPROFILE_STATS_COUNT
343 #undef SMBPROFILE_STATS_TIME
344 #undef SMBPROFILE_STATS_BASIC
345 #undef SMBPROFILE_STATS_BYTES
346 #undef SMBPROFILE_STATS_IOBYTES
347 #undef SMBPROFILE_STATS_SECTION_END
348 #undef SMBPROFILE_STATS_END
351 #define _SMBPROFILE_COUNT_INCREMENT(_stats, _area, _v) do { \
352 if (do_profile_flag) { \
353 (_area)->_stats.count += (_v); \
355 } while(0)
356 #define SMBPROFILE_COUNT_INCREMENT(_name, _area, _v) \
357 _SMBPROFILE_COUNT_INCREMENT(_name##_stats, _area, _v)
359 #define SMBPROFILE_TIME_ASYNC_STATE(_async_name) \
360 struct smbprofile_stats_time_async _async_name;
361 #define _SMBPROFILE_TIME_ASYNC_START(_stats, _area, _async) do { \
362 (_async) = (struct smbprofile_stats_time_async) {}; \
363 if (smbprofile_state.config.do_times) { \
364 (_async).stats = &((_area)->_stats), \
365 (_async).start = profile_timestamp(); \
367 } while(0)
368 #define SMBPROFILE_TIME_ASYNC_START(_name, _area, _async) \
369 _SMBPROFILE_TIME_ASYNC_START(_name##_stats, _area, _async)
370 #define SMBPROFILE_TIME_ASYNC_END(_async) do { \
371 if ((_async).start != 0) { \
372 (_async).stats->time += profile_timestamp() - (_async).start; \
373 (_async) = (struct smbprofile_stats_basic_async) {}; \
375 } while(0)
377 #define SMBPROFILE_BASIC_ASYNC_STATE(_async_name) \
378 struct smbprofile_stats_basic_async _async_name;
379 #define _SMBPROFILE_BASIC_ASYNC_START(_stats, _area, _async) do { \
380 (_async) = (struct smbprofile_stats_basic_async) {}; \
381 if (do_profile_flag) { \
382 if (do_profile_times) { \
383 (_async).start = profile_timestamp(); \
384 (_async).stats = &((_area)->_stats); \
386 (_area)->_stats.count += 1; \
388 } while(0)
389 #define SMBPROFILE_BASIC_ASYNC_START(_name, _area, _async) \
390 _SMBPROFILE_BASIC_ASYNC_START(_name##_stats, _area, _async)
391 #define SMBPROFILE_BASIC_ASYNC_END(_async) do { \
392 if ((_async).start != 0) { \
393 (_async).stats->time += profile_timestamp() - (_async).start; \
394 (_async) = (struct smbprofile_stats_basic_async) {}; \
396 } while(0)
398 #define _SMBPROFILE_TIMER_ASYNC_START(_stats, _area, _async) do { \
399 (_async).stats = &((_area)->_stats); \
400 if (do_profile_times) { \
401 (_async).start = profile_timestamp(); \
403 } while(0)
404 #define _SMBPROFILE_TIMER_ASYNC_SET_IDLE(_async) do { \
405 if ((_async).start != 0) { \
406 if ((_async).idle_start == 0) { \
407 (_async).idle_start = profile_timestamp(); \
410 } while(0)
411 #define _SMBPROFILE_TIMER_ASYNC_SET_BUSY(_async) do { \
412 if ((_async).idle_start != 0) { \
413 (_async).idle_time += \
414 profile_timestamp() - (_async).idle_start; \
415 (_async).idle_start = 0; \
417 } while(0)
418 #define _SMBPROFILE_TIMER_ASYNC_END(_async) do { \
419 if ((_async).start != 0) { \
420 _SMBPROFILE_TIMER_ASYNC_SET_BUSY(_async); \
421 (_async).stats->time += profile_timestamp() - (_async).start; \
422 (_async).stats->idle += (_async).idle_time; \
424 } while(0)
426 #define SMBPROFILE_BYTES_ASYNC_STATE(_async_name) \
427 struct smbprofile_stats_bytes_async _async_name;
428 #define _SMBPROFILE_BYTES_ASYNC_START(_stats, _area, _async, _bytes) do { \
429 (_async) = (struct smbprofile_stats_bytes_async) {}; \
430 if (do_profile_flag) { \
431 _SMBPROFILE_TIMER_ASYNC_START(_stats, _area, _async); \
432 (_area)->_stats.count += 1; \
433 (_area)->_stats.bytes += (_bytes); \
435 } while(0)
436 #define SMBPROFILE_BYTES_ASYNC_START(_name, _area, _async, _bytes) \
437 _SMBPROFILE_BYTES_ASYNC_START(_name##_stats, _area, _async, _bytes)
438 #define SMBPROFILE_BYTES_ASYNC_SET_IDLE(_async) \
439 _SMBPROFILE_TIMER_ASYNC_SET_IDLE(_async)
440 #define SMBPROFILE_BYTES_ASYNC_SET_BUSY(_async) \
441 _SMBPROFILE_TIMER_ASYNC_SET_BUSY(_async)
442 #define SMBPROFILE_BYTES_ASYNC_END(_async) do { \
443 if ((_async).stats != NULL) { \
444 _SMBPROFILE_TIMER_ASYNC_END(_async); \
445 (_async) = (struct smbprofile_stats_bytes_async) {}; \
447 } while(0)
449 #define SMBPROFILE_IOBYTES_ASYNC_STATE(_async_name) \
450 struct smbprofile_stats_iobytes_async _async_name;
451 #define _SMBPROFILE_IOBYTES_ASYNC_START(_stats, _area, _async, _inbytes) do { \
452 (_async) = (struct smbprofile_stats_iobytes_async) {}; \
453 if (do_profile_flag) { \
454 _SMBPROFILE_TIMER_ASYNC_START(_stats, _area, _async); \
455 (_area)->_stats.count += 1; \
456 (_area)->_stats.inbytes += (_inbytes); \
458 } while(0)
459 #define SMBPROFILE_IOBYTES_ASYNC_START(_name, _area, _async, _inbytes) \
460 _SMBPROFILE_IOBYTES_ASYNC_START(_name##_stats, _area, _async, _inbytes)
461 #define SMBPROFILE_IOBYTES_ASYNC_SET_IDLE(_async) \
462 _SMBPROFILE_TIMER_ASYNC_SET_IDLE(_async)
463 #define SMBPROFILE_IOBYTES_ASYNC_SET_BUSY(_async) \
464 _SMBPROFILE_TIMER_ASYNC_SET_BUSY(_async)
465 #define SMBPROFILE_IOBYTES_ASYNC_END(_async, _outbytes) do { \
466 if ((_async).stats != NULL) { \
467 (_async).stats->outbytes += (_outbytes); \
468 _SMBPROFILE_TIMER_ASYNC_END(_async); \
469 (_async) = (struct smbprofile_stats_iobytes_async) {}; \
471 } while(0)
473 extern struct profile_stats *profile_p;
474 extern bool do_profile_flag;
475 extern bool do_profile_times;
477 static inline uint64_t profile_timestamp(void)
479 struct timespec ts;
481 /* we might prefer to use the _COARSE clock variant of CLOCK_MONOTONIC
482 that one is faster but cached and "just" tick-wise precise */
483 clock_gettime_mono(&ts);
484 return (ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); /* usec */
487 #define DO_PROFILE_INC(x) \
488 _SMBPROFILE_COUNT_INCREMENT(x##_stats, profile_p, 1); \
490 #define START_PROFILE(x) \
491 struct smbprofile_stats_basic_async __profasync_##x = {}; \
492 _SMBPROFILE_BASIC_ASYNC_START(x##_stats, profile_p, __profasync_##x);
494 #define START_PROFILE_BYTES(x,n) \
495 struct smbprofile_stats_bytes_async __profasync_##x = {}; \
496 _SMBPROFILE_BYTES_ASYNC_START(x##_stats, profile_p, __profasync_##x, n);
498 #define END_PROFILE(x) \
499 SMBPROFILE_BASIC_ASYNC_END(__profasync_##x)
501 #define END_PROFILE_BYTES(x) \
502 SMBPROFILE_BYTES_ASYNC_END(__profasync_##x)
504 #else /* WITH_PROFILE */
506 #define SMBPROFILE_COUNT_INCREMENT(_name, _area, _v)
508 #define SMBPROFILE_TIME_ASYNC_STATE(_async_name)
509 #define SMBPROFILE_TIME_ASYNC_START(_name, _area, _async)
510 #define SMBPROFILE_TIME_ASYNC_END(_async)
512 #define SMBPROFILE_BASIC_ASYNC_STATE(_async_name)
513 #define SMBPROFILE_BASIC_ASYNC_START(_name, _area, _async)
514 #define SMBPROFILE_BASIC_ASYNC_END(_async)
516 #define SMBPROFILE_BYTES_ASYNC_STATE(_async_name)
517 #define SMBPROFILE_BYTES_ASYNC_START(_name, _area, _async, _inbytes)
518 #define SMBPROFILE_BYTES_ASYNC_SET_IDLE(_async)
519 #define SMBPROFILE_BYTES_ASYNC_SET_BUSY(_async)
520 #define SMBPROFILE_BYTES_ASYNC_END(_async)
522 #define SMBPROFILE_IOBYTES_ASYNC_STATE(_async_name)
523 #define SMBPROFILE_IOBYTES_ASYNC_START(_name, _area, _async, _inbytes)
524 #define SMBPROFILE_IOBYTES_ASYNC_SET_IDLE(_async)
525 #define SMBPROFILE_IOBYTES_ASYNC_SET_BUSY(_async)
526 #define SMBPROFILE_IOBYTES_ASYNC_END(_async, _outbytes)
528 #define DO_PROFILE_INC(x)
529 #define START_PROFILE(x)
530 #define START_PROFILE_BYTES(x,n)
531 #define END_PROFILE(x)
532 #define END_PROFILE_BYTES(x)
534 #endif /* WITH_PROFILE */
536 /* The following definitions come from profile/profile.c */
538 void set_profile_level(int level, struct server_id src);
540 struct messaging_context;
541 bool profile_setup(struct messaging_context *msg_ctx, bool rdonly);
543 #endif