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
/* this file defines the profile structure in the profile shared
27
#define PROF_SHMEM_KEY ((key_t)0x07021999)
28
#define PROF_SHM_MAGIC 0x6349985
29
#define PROF_SHM_VERSION 11
31
/* time values in the following structure are in microseconds */
33
#define __profile_stats_value(which, domain) domain[which]
35
enum profile_stats_values
37
PR_VALUE_SMBD_IDLE = 0,
38
#define smbd_idle_count __profile_stats_value(PR_VALUE_SMBD_IDLE, count)
39
#define smbd_idle_time __profile_stats_value(PR_VALUE_SMBD_IDLE, time)
41
/* system call counters */
42
PR_VALUE_SYSCALL_OPENDIR,
43
#define syscall_opendir_count __profile_stats_value(PR_VALUE_SYSCALL_OPENDIR, count)
44
#define syscall_opendir_time __profile_stats_value(PR_VALUE_SYSCALL_OPENDIR, time)
46
PR_VALUE_SYSCALL_READDIR,
47
#define syscall_readdir_count __profile_stats_value(PR_VALUE_SYSCALL_READDIR, count)
48
#define syscall_readdir_time __profile_stats_value(PR_VALUE_SYSCALL_READDIR, time)
50
PR_VALUE_SYSCALL_SEEKDIR,
51
#define syscall_seekdir_count __profile_stats_value(PR_VALUE_SYSCALL_SEEKDIR, count)
52
#define syscall_seekdir_time __profile_stats_value(PR_VALUE_SYSCALL_SEEKDIR, time)
54
PR_VALUE_SYSCALL_TELLDIR,
55
#define syscall_telldir_count __profile_stats_value(PR_VALUE_SYSCALL_TELLDIR, count)
56
#define syscall_telldir_time __profile_stats_value(PR_VALUE_SYSCALL_TELLDIR, time)
58
PR_VALUE_SYSCALL_REWINDDIR,
59
#define syscall_rewinddir_count __profile_stats_value(PR_VALUE_SYSCALL_REWINDDIR, count)
60
#define syscall_rewinddir_time __profile_stats_value(PR_VALUE_SYSCALL_REWINDDIR, time)
62
PR_VALUE_SYSCALL_MKDIR,
63
#define syscall_mkdir_count __profile_stats_value(PR_VALUE_SYSCALL_MKDIR, count)
64
#define syscall_mkdir_time __profile_stats_value(PR_VALUE_SYSCALL_MKDIR, time)
66
PR_VALUE_SYSCALL_RMDIR,
67
#define syscall_rmdir_count __profile_stats_value(PR_VALUE_SYSCALL_RMDIR, count)
68
#define syscall_rmdir_time __profile_stats_value(PR_VALUE_SYSCALL_RMDIR, time)
70
PR_VALUE_SYSCALL_CLOSEDIR,
71
#define syscall_closedir_count __profile_stats_value(PR_VALUE_SYSCALL_CLOSEDIR, count)
72
#define syscall_closedir_time __profile_stats_value(PR_VALUE_SYSCALL_CLOSEDIR, time)
74
PR_VALUE_SYSCALL_OPEN,
75
#define syscall_open_count __profile_stats_value(PR_VALUE_SYSCALL_OPEN, count)
76
#define syscall_open_time __profile_stats_value(PR_VALUE_SYSCALL_OPEN, time)
78
PR_VALUE_SYSCALL_CREATEFILE,
79
#define syscall_createfile_count __profile_stats_value(PR_VALUE_SYSCALL_CREATEFILE, count)
80
#define syscall_createfile_time __profile_stats_value(PR_VALUE_SYSCALL_CREATEFILE, time)
82
PR_VALUE_SYSCALL_CLOSE,
83
#define syscall_close_count __profile_stats_value(PR_VALUE_SYSCALL_CLOSE, count)
84
#define syscall_close_time __profile_stats_value(PR_VALUE_SYSCALL_CLOSE, time)
86
PR_VALUE_SYSCALL_READ,
87
#define syscall_read_count __profile_stats_value(PR_VALUE_SYSCALL_READ, count)
88
#define syscall_read_time __profile_stats_value(PR_VALUE_SYSCALL_READ, time)
90
PR_VALUE_SYSCALL_PREAD,
91
#define syscall_pread_count __profile_stats_value(PR_VALUE_SYSCALL_PREAD, count)
92
#define syscall_pread_time __profile_stats_value(PR_VALUE_SYSCALL_PREAD, time)
94
PR_VALUE_SYSCALL_WRITE,
95
#define syscall_write_count __profile_stats_value(PR_VALUE_SYSCALL_WRITE, count)
96
#define syscall_write_time __profile_stats_value(PR_VALUE_SYSCALL_WRITE, time)
98
PR_VALUE_SYSCALL_PWRITE,
99
#define syscall_pwrite_count __profile_stats_value(PR_VALUE_SYSCALL_PWRITE, count)
100
#define syscall_pwrite_time __profile_stats_value(PR_VALUE_SYSCALL_PWRITE, time)
102
PR_VALUE_SYSCALL_LSEEK,
103
#define syscall_lseek_count __profile_stats_value(PR_VALUE_SYSCALL_LSEEK, count)
104
#define syscall_lseek_time __profile_stats_value(PR_VALUE_SYSCALL_LSEEK, time)
106
PR_VALUE_SYSCALL_SENDFILE,
107
#define syscall_sendfile_count __profile_stats_value(PR_VALUE_SYSCALL_SENDFILE, count)
108
#define syscall_sendfile_time __profile_stats_value(PR_VALUE_SYSCALL_SENDFILE, time)
110
PR_VALUE_SYSCALL_RECVFILE,
111
#define syscall_recvfile_count __profile_stats_value(PR_VALUE_SYSCALL_RECVFILE, count)
112
#define syscall_recvfile_time __profile_stats_value(PR_VALUE_SYSCALL_RECVFILE, time)
114
PR_VALUE_SYSCALL_RENAME,
115
#define syscall_rename_count __profile_stats_value(PR_VALUE_SYSCALL_RENAME, count)
116
#define syscall_rename_time __profile_stats_value(PR_VALUE_SYSCALL_RENAME, time)
118
PR_VALUE_SYSCALL_RENAME_AT,
119
#define syscall_rename_at_count __profile_stats_value(PR_VALUE_SYSCALL_RENAME_AT, count)
120
#define syscall_rename_at_time __profile_stats_value(PR_VALUE_SYSCALL_RENAME_AT, time)
122
PR_VALUE_SYSCALL_FSYNC,
123
#define syscall_fsync_count __profile_stats_value(PR_VALUE_SYSCALL_FSYNC, count)
124
#define syscall_fsync_time __profile_stats_value(PR_VALUE_SYSCALL_FSYNC, time)
126
PR_VALUE_SYSCALL_STAT,
127
#define syscall_stat_count __profile_stats_value(PR_VALUE_SYSCALL_STAT, count)
128
#define syscall_stat_time __profile_stats_value(PR_VALUE_SYSCALL_STAT, time)
130
PR_VALUE_SYSCALL_FSTAT,
131
#define syscall_fstat_count __profile_stats_value(PR_VALUE_SYSCALL_FSTAT, count)
132
#define syscall_fstat_time __profile_stats_value(PR_VALUE_SYSCALL_FSTAT, time)
134
PR_VALUE_SYSCALL_LSTAT,
135
#define syscall_lstat_count __profile_stats_value(PR_VALUE_SYSCALL_LSTAT, count)
136
#define syscall_lstat_time __profile_stats_value(PR_VALUE_SYSCALL_LSTAT, time)
138
PR_VALUE_SYSCALL_GET_ALLOC_SIZE,
139
#define syscall_get_alloc_size_count __profile_stats_value(PR_VALUE_SYSCALL_GET_ALLOC_SIZE, count)
140
#define syscall_get_alloc_size_time __profile_stats_value(PR_VALUE_SYSCALL_GET_ALLOC_SIZE, time)
142
PR_VALUE_SYSCALL_UNLINK,
143
#define syscall_unlink_count __profile_stats_value(PR_VALUE_SYSCALL_UNLINK, count)
144
#define syscall_unlink_time __profile_stats_value(PR_VALUE_SYSCALL_UNLINK, time)
146
PR_VALUE_SYSCALL_CHMOD,
147
#define syscall_chmod_count __profile_stats_value(PR_VALUE_SYSCALL_CHMOD, count)
148
#define syscall_chmod_time __profile_stats_value(PR_VALUE_SYSCALL_CHMOD, time)
150
PR_VALUE_SYSCALL_FCHMOD,
151
#define syscall_fchmod_count __profile_stats_value(PR_VALUE_SYSCALL_FCHMOD, count)
152
#define syscall_fchmod_time __profile_stats_value(PR_VALUE_SYSCALL_FCHMOD, time)
154
PR_VALUE_SYSCALL_CHOWN,
155
#define syscall_chown_count __profile_stats_value(PR_VALUE_SYSCALL_CHOWN, count)
156
#define syscall_chown_time __profile_stats_value(PR_VALUE_SYSCALL_CHOWN, time)
158
PR_VALUE_SYSCALL_FCHOWN,
159
#define syscall_fchown_count __profile_stats_value(PR_VALUE_SYSCALL_FCHOWN, count)
160
#define syscall_fchown_time __profile_stats_value(PR_VALUE_SYSCALL_FCHOWN, time)
162
PR_VALUE_SYSCALL_LCHOWN,
163
#define syscall_lchown_count __profile_stats_value(PR_VALUE_SYSCALL_LCHOWN, count)
164
#define syscall_lchown_time __profile_stats_value(PR_VALUE_SYSCALL_LCHOWN, time)
166
PR_VALUE_SYSCALL_CHDIR,
167
#define syscall_chdir_count __profile_stats_value(PR_VALUE_SYSCALL_CHDIR, count)
168
#define syscall_chdir_time __profile_stats_value(PR_VALUE_SYSCALL_CHDIR, time)
170
PR_VALUE_SYSCALL_GETWD,
171
#define syscall_getwd_count __profile_stats_value(PR_VALUE_SYSCALL_GETWD, count)
172
#define syscall_getwd_time __profile_stats_value(PR_VALUE_SYSCALL_GETWD, time)
174
PR_VALUE_SYSCALL_NTIMES,
175
#define syscall_ntimes_count __profile_stats_value(PR_VALUE_SYSCALL_NTIMES, count)
176
#define syscall_ntimes_time __profile_stats_value(PR_VALUE_SYSCALL_NTIMES, time)
178
PR_VALUE_SYSCALL_FTRUNCATE,
179
#define syscall_ftruncate_count __profile_stats_value(PR_VALUE_SYSCALL_FTRUNCATE, count)
180
#define syscall_ftruncate_time __profile_stats_value(PR_VALUE_SYSCALL_FTRUNCATE, time)
182
PR_VALUE_SYSCALL_FCNTL_LOCK,
183
#define syscall_fcntl_lock_count __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_LOCK, count)
184
#define syscall_fcntl_lock_time __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_LOCK, time)
186
PR_VALUE_SYSCALL_KERNEL_FLOCK,
187
#define syscall_kernel_flock_count __profile_stats_value(PR_VALUE_SYSCALL_KERNEL_FLOCK, count)
188
#define syscall_kernel_flock_time __profile_stats_value(PR_VALUE_SYSCALL_KERNEL_FLOCK, time)
190
PR_VALUE_SYSCALL_LINUX_SETLEASE,
191
#define syscall_linux_setlease_count __profile_stats_value(PR_VALUE_SYSCALL_LINUX_SETLEASE, count)
192
#define syscall_linux_setlease_time __profile_stats_value(PR_VALUE_SYSCALL_LINUX_SETLEASE, time)
194
PR_VALUE_SYSCALL_FCNTL_GETLOCK,
195
#define syscall_fcntl_getlock_count __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_GETLOCK, count)
196
#define syscall_fcntl_getlock_time __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_GETLOCK, time)
198
PR_VALUE_SYSCALL_READLINK,
199
#define syscall_readlink_count __profile_stats_value(PR_VALUE_SYSCALL_READLINK, count)
200
#define syscall_readlink_time __profile_stats_value(PR_VALUE_SYSCALL_READLINK, time)
202
PR_VALUE_SYSCALL_SYMLINK,
203
#define syscall_symlink_count __profile_stats_value(PR_VALUE_SYSCALL_SYMLINK, count)
204
#define syscall_symlink_time __profile_stats_value(PR_VALUE_SYSCALL_SYMLINK, time)
206
PR_VALUE_SYSCALL_LINK,
207
#define syscall_link_count __profile_stats_value(PR_VALUE_SYSCALL_LINK, count)
208
#define syscall_link_time __profile_stats_value(PR_VALUE_SYSCALL_LINK, time)
210
PR_VALUE_SYSCALL_MKNOD,
211
#define syscall_mknod_count __profile_stats_value(PR_VALUE_SYSCALL_MKNOD, count)
212
#define syscall_mknod_time __profile_stats_value(PR_VALUE_SYSCALL_MKNOD, time)
214
PR_VALUE_SYSCALL_REALPATH,
215
#define syscall_realpath_count __profile_stats_value(PR_VALUE_SYSCALL_REALPATH, count)
216
#define syscall_realpath_time __profile_stats_value(PR_VALUE_SYSCALL_REALPATH, time)
218
PR_VALUE_SYSCALL_GET_QUOTA,
219
#define syscall_get_quota_count __profile_stats_value(PR_VALUE_SYSCALL_GET_QUOTA, count)
220
#define syscall_get_quota_time __profile_stats_value(PR_VALUE_SYSCALL_GET_QUOTA, time)
222
PR_VALUE_SYSCALL_SET_QUOTA,
223
#define syscall_set_quota_count __profile_stats_value(PR_VALUE_SYSCALL_SET_QUOTA, count)
224
#define syscall_set_quota_time __profile_stats_value(PR_VALUE_SYSCALL_SET_QUOTA, time)
226
PR_VALUE_SYSCALL_GET_SD,
227
#define syscall_get_sd_count __profile_stats_value(PR_VALUE_SYSCALL_GET_SD, count)
228
#define syscall_get_sd_time __profile_stats_value(PR_VALUE_SYSCALL_GET_SD, time)
230
PR_VALUE_SYSCALL_SET_SD,
231
#define syscall_set_sd_count __profile_stats_value(PR_VALUE_SYSCALL_SET_SD, count)
232
#define syscall_set_sd_time __profile_stats_value(PR_VALUE_SYSCALL_SET_SD, time)
234
PR_VALUE_SYSCALL_BRL_LOCK,
235
#define syscall_brl_lock_count __profile_stats_value(PR_VALUE_SYSCALL_BRL_LOCK, count)
236
#define syscall_brl_lock_time __profile_stats_value(PR_VALUE_SYSCALL_BRL_LOCK, time)
238
PR_VALUE_SYSCALL_BRL_UNLOCK,
239
#define syscall_brl_unlock_count __profile_stats_value(PR_VALUE_SYSCALL_BRL_UNLOCK, count)
240
#define syscall_brl_unlock_time __profile_stats_value(PR_VALUE_SYSCALL_BRL_UNLOCK, time)
242
PR_VALUE_SYSCALL_BRL_CANCEL,
243
#define syscall_brl_cancel_count __profile_stats_value(PR_VALUE_SYSCALL_BRL_CANCEL, count)
244
#define syscall_brl_cancel_time __profile_stats_value(PR_VALUE_SYSCALL_BRL_CANCEL, time)
246
PR_VALUE_SYSCALL_STRICT_LOCK,
247
#define syscall_strict_lock_count __profile_stats_value(PR_VALUE_SYSCALL_STRICT_LOCK, count)
248
#define syscall_strict_lock_time __profile_stats_value(PR_VALUE_SYSCALL_STRICT_LOCK, time)
250
PR_VALUE_SYSCALL_STRICT_UNLOCK,
251
#define syscall_strict_unlock_count __profile_stats_value(PR_VALUE_SYSCALL_STRICT_UNLOCK, count)
252
#define syscall_strict_unlock_time __profile_stats_value(PR_VALUE_SYSCALL_STRICT_UNLOCK, time)
254
/* counters for individual SMB types */
256
#define SMBmkdir_count __profile_stats_value(PR_VALUE_SMBMKDIR, count)
257
#define SMBmkdir_time __profile_stats_value(PR_VALUE_SMBMKDIR, time)
260
#define SMBrmdir_count __profile_stats_value(PR_VALUE_SMBRMDIR, count)
261
#define SMBrmdir_time __profile_stats_value(PR_VALUE_SMBRMDIR, time)
264
#define SMBopen_count __profile_stats_value(PR_VALUE_SMBOPEN, count)
265
#define SMBopen_time __profile_stats_value(PR_VALUE_SMBOPEN, time)
268
#define SMBcreate_count __profile_stats_value(PR_VALUE_SMBCREATE, count)
269
#define SMBcreate_time __profile_stats_value(PR_VALUE_SMBCREATE, time)
272
#define SMBclose_count __profile_stats_value(PR_VALUE_SMBCLOSE, count)
273
#define SMBclose_time __profile_stats_value(PR_VALUE_SMBCLOSE, time)
276
#define SMBflush_count __profile_stats_value(PR_VALUE_SMBFLUSH, count)
277
#define SMBflush_time __profile_stats_value(PR_VALUE_SMBFLUSH, time)
280
#define SMBunlink_count __profile_stats_value(PR_VALUE_SMBUNLINK, count)
281
#define SMBunlink_time __profile_stats_value(PR_VALUE_SMBUNLINK, time)
284
#define SMBmv_count __profile_stats_value(PR_VALUE_SMBMV, count)
285
#define SMBmv_time __profile_stats_value(PR_VALUE_SMBMV, time)
288
#define SMBgetatr_count __profile_stats_value(PR_VALUE_SMBGETATR, count)
289
#define SMBgetatr_time __profile_stats_value(PR_VALUE_SMBGETATR, time)
292
#define SMBsetatr_count __profile_stats_value(PR_VALUE_SMBSETATR, count)
293
#define SMBsetatr_time __profile_stats_value(PR_VALUE_SMBSETATR, time)
296
#define SMBread_count __profile_stats_value(PR_VALUE_SMBREAD, count)
297
#define SMBread_time __profile_stats_value(PR_VALUE_SMBREAD, time)
300
#define SMBwrite_count __profile_stats_value(PR_VALUE_SMBWRITE, count)
301
#define SMBwrite_time __profile_stats_value(PR_VALUE_SMBWRITE, time)
304
#define SMBlock_count __profile_stats_value(PR_VALUE_SMBLOCK, count)
305
#define SMBlock_time __profile_stats_value(PR_VALUE_SMBLOCK, time)
308
#define SMBunlock_count __profile_stats_value(PR_VALUE_SMBUNLOCK, count)
309
#define SMBunlock_time __profile_stats_value(PR_VALUE_SMBUNLOCK, time)
312
#define SMBctemp_count __profile_stats_value(PR_VALUE_SMBCTEMP, count)
313
#define SMBctemp_time __profile_stats_value(PR_VALUE_SMBCTEMP, time)
315
/* SMBmknew stats are currently combined with SMBcreate */
317
#define SMBmknew_count __profile_stats_value(PR_VALUE_SMBMKNEW, count)
318
#define SMBmknew_time __profile_stats_value(PR_VALUE_SMBMKNEW, time)
320
PR_VALUE_SMBCHECKPATH,
321
#define SMBcheckpath_count __profile_stats_value(PR_VALUE_SMBCHECKPATH, count)
322
#define SMBcheckpath_time __profile_stats_value(PR_VALUE_SMBCHECKPATH, time)
325
#define SMBexit_count __profile_stats_value(PR_VALUE_SMBEXIT, count)
326
#define SMBexit_time __profile_stats_value(PR_VALUE_SMBEXIT, time)
329
#define SMBlseek_count __profile_stats_value(PR_VALUE_SMBLSEEK, count)
330
#define SMBlseek_time __profile_stats_value(PR_VALUE_SMBLSEEK, time)
332
PR_VALUE_SMBLOCKREAD,
333
#define SMBlockread_count __profile_stats_value(PR_VALUE_SMBLOCKREAD, count)
334
#define SMBlockread_time __profile_stats_value(PR_VALUE_SMBLOCKREAD, time)
336
PR_VALUE_SMBWRITEUNLOCK,
337
#define SMBwriteunlock_count __profile_stats_value(PR_VALUE_SMBWRITEUNLOCK, count)
338
#define SMBwriteunlock_time __profile_stats_value(PR_VALUE_SMBWRITEUNLOCK, time)
340
PR_VALUE_SMBREADBRAW,
341
#define SMBreadbraw_count __profile_stats_value(PR_VALUE_SMBREADBRAW, count)
342
#define SMBreadbraw_time __profile_stats_value(PR_VALUE_SMBREADBRAW, time)
344
PR_VALUE_SMBREADBMPX,
345
#define SMBreadBmpx_count __profile_stats_value(PR_VALUE_SMBREADBMPX, count)
346
#define SMBreadBmpx_time __profile_stats_value(PR_VALUE_SMBREADBMPX, time)
349
#define SMBreadBs_count __profile_stats_value(PR_VALUE_SMBREADBS, count)
350
#define SMBreadBs_time __profile_stats_value(PR_VALUE_SMBREADBS, time)
352
PR_VALUE_SMBWRITEBRAW,
353
#define SMBwritebraw_count __profile_stats_value(PR_VALUE_SMBWRITEBRAW, count)
354
#define SMBwritebraw_time __profile_stats_value(PR_VALUE_SMBWRITEBRAW, time)
356
PR_VALUE_SMBWRITEBMPX,
357
#define SMBwriteBmpx_count __profile_stats_value(PR_VALUE_SMBWRITEBMPX, count)
358
#define SMBwriteBmpx_time __profile_stats_value(PR_VALUE_SMBWRITEBMPX, time)
361
#define SMBwriteBs_count __profile_stats_value(PR_VALUE_SMBWRITEBS, count)
362
#define SMBwriteBs_time __profile_stats_value(PR_VALUE_SMBWRITEBS, time)
365
#define SMBwritec_count __profile_stats_value(PR_VALUE_SMBWRITEC, count)
366
#define SMBwritec_time __profile_stats_value(PR_VALUE_SMBWRITEC, time)
368
PR_VALUE_SMBSETATTRE,
369
#define SMBsetattrE_count __profile_stats_value(PR_VALUE_SMBSETATTRE, count)
370
#define SMBsetattrE_time __profile_stats_value(PR_VALUE_SMBSETATTRE, time)
372
PR_VALUE_SMBGETATTRE,
373
#define SMBgetattrE_count __profile_stats_value(PR_VALUE_SMBGETATTRE, count)
374
#define SMBgetattrE_time __profile_stats_value(PR_VALUE_SMBGETATTRE, time)
376
PR_VALUE_SMBLOCKINGX,
377
#define SMBlockingX_count __profile_stats_value(PR_VALUE_SMBLOCKINGX, count)
378
#define SMBlockingX_time __profile_stats_value(PR_VALUE_SMBLOCKINGX, time)
381
#define SMBtrans_count __profile_stats_value(PR_VALUE_SMBTRANS, count)
382
#define SMBtrans_time __profile_stats_value(PR_VALUE_SMBTRANS, time)
385
#define SMBtranss_count __profile_stats_value(PR_VALUE_SMBTRANSS, count)
386
#define SMBtranss_time __profile_stats_value(PR_VALUE_SMBTRANSS, time)
389
#define SMBioctl_count __profile_stats_value(PR_VALUE_SMBIOCTL, count)
390
#define SMBioctl_time __profile_stats_value(PR_VALUE_SMBIOCTL, time)
393
#define SMBioctls_count __profile_stats_value(PR_VALUE_SMBIOCTLS, count)
394
#define SMBioctls_time __profile_stats_value(PR_VALUE_SMBIOCTLS, time)
397
#define SMBcopy_count __profile_stats_value(PR_VALUE_SMBCOPY, count)
398
#define SMBcopy_time __profile_stats_value(PR_VALUE_SMBCOPY, time)
401
#define SMBmove_count __profile_stats_value(PR_VALUE_SMBMOVE, count)
402
#define SMBmove_time __profile_stats_value(PR_VALUE_SMBMOVE, time)
405
#define SMBecho_count __profile_stats_value(PR_VALUE_SMBECHO, count)
406
#define SMBecho_time __profile_stats_value(PR_VALUE_SMBECHO, time)
408
PR_VALUE_SMBWRITECLOSE,
409
#define SMBwriteclose_count __profile_stats_value(PR_VALUE_SMBWRITECLOSE, count)
410
#define SMBwriteclose_time __profile_stats_value(PR_VALUE_SMBWRITECLOSE, time)
413
#define SMBopenX_count __profile_stats_value(PR_VALUE_SMBOPENX, count)
414
#define SMBopenX_time __profile_stats_value(PR_VALUE_SMBOPENX, time)
417
#define SMBreadX_count __profile_stats_value(PR_VALUE_SMBREADX, count)
418
#define SMBreadX_time __profile_stats_value(PR_VALUE_SMBREADX, time)
421
#define SMBwriteX_count __profile_stats_value(PR_VALUE_SMBWRITEX, count)
422
#define SMBwriteX_time __profile_stats_value(PR_VALUE_SMBWRITEX, time)
425
#define SMBtrans2_count __profile_stats_value(PR_VALUE_SMBTRANS2, count)
426
#define SMBtrans2_time __profile_stats_value(PR_VALUE_SMBTRANS2, time)
429
#define SMBtranss2_count __profile_stats_value(PR_VALUE_SMBTRANSS2, count)
430
#define SMBtranss2_time __profile_stats_value(PR_VALUE_SMBTRANSS2, time)
432
PR_VALUE_SMBFINDCLOSE,
433
#define SMBfindclose_count __profile_stats_value(PR_VALUE_SMBFINDCLOSE, count)
434
#define SMBfindclose_time __profile_stats_value(PR_VALUE_SMBFINDCLOSE, time)
436
PR_VALUE_SMBFINDNCLOSE,
437
#define SMBfindnclose_count __profile_stats_value(PR_VALUE_SMBFINDNCLOSE, count)
438
#define SMBfindnclose_time __profile_stats_value(PR_VALUE_SMBFINDNCLOSE, time)
441
#define SMBtcon_count __profile_stats_value(PR_VALUE_SMBTCON, count)
442
#define SMBtcon_time __profile_stats_value(PR_VALUE_SMBTCON, time)
445
#define SMBtdis_count __profile_stats_value(PR_VALUE_SMBTDIS, count)
446
#define SMBtdis_time __profile_stats_value(PR_VALUE_SMBTDIS, time)
449
#define SMBnegprot_count __profile_stats_value(PR_VALUE_SMBNEGPROT, count)
450
#define SMBnegprot_time __profile_stats_value(PR_VALUE_SMBNEGPROT, time)
452
PR_VALUE_SMBSESSSETUPX,
453
#define SMBsesssetupX_count __profile_stats_value(PR_VALUE_SMBSESSSETUPX, count)
454
#define SMBsesssetupX_time __profile_stats_value(PR_VALUE_SMBSESSSETUPX, time)
456
PR_VALUE_SMBULOGOFFX,
457
#define SMBulogoffX_count __profile_stats_value(PR_VALUE_SMBULOGOFFX, count)
458
#define SMBulogoffX_time __profile_stats_value(PR_VALUE_SMBULOGOFFX, time)
461
#define SMBtconX_count __profile_stats_value(PR_VALUE_SMBTCONX, count)
462
#define SMBtconX_time __profile_stats_value(PR_VALUE_SMBTCONX, time)
465
#define SMBdskattr_count __profile_stats_value(PR_VALUE_SMBDSKATTR, count)
466
#define SMBdskattr_time __profile_stats_value(PR_VALUE_SMBDSKATTR, time)
469
#define SMBsearch_count __profile_stats_value(PR_VALUE_SMBSEARCH, count)
470
#define SMBsearch_time __profile_stats_value(PR_VALUE_SMBSEARCH, time)
472
/* SBMffirst stats combined with SMBsearch */
474
#define SMBffirst_count __profile_stats_value(PR_VALUE_SMBFFIRST, count)
475
#define SMBffirst_time __profile_stats_value(PR_VALUE_SMBFFIRST, time)
477
/* SBMfunique stats combined with SMBsearch */
479
#define SMBfunique_count __profile_stats_value(PR_VALUE_SMBFUNIQUE, count)
480
#define SMBfunique_time __profile_stats_value(PR_VALUE_SMBFUNIQUE, time)
483
#define SMBfclose_count __profile_stats_value(PR_VALUE_SMBFCLOSE, count)
484
#define SMBfclose_time __profile_stats_value(PR_VALUE_SMBFCLOSE, time)
487
#define SMBnttrans_count __profile_stats_value(PR_VALUE_SMBNTTRANS, count)
488
#define SMBnttrans_time __profile_stats_value(PR_VALUE_SMBNTTRANS, time)
490
PR_VALUE_SMBNTTRANSS,
491
#define SMBnttranss_count __profile_stats_value(PR_VALUE_SMBNTTRANSS, count)
492
#define SMBnttranss_time __profile_stats_value(PR_VALUE_SMBNTTRANSS, time)
494
PR_VALUE_SMBNTCREATEX,
495
#define SMBntcreateX_count __profile_stats_value(PR_VALUE_SMBNTCREATEX, count)
496
#define SMBntcreateX_time __profile_stats_value(PR_VALUE_SMBNTCREATEX, time)
498
PR_VALUE_SMBNTCANCEL,
499
#define SMBntcancel_count __profile_stats_value(PR_VALUE_SMBNTCANCEL, count)
500
#define SMBntcancel_time __profile_stats_value(PR_VALUE_SMBNTCANCEL, time)
502
PR_VALUE_SMBNTRENAME,
503
#define SMBntrename_count __profile_stats_value(PR_VALUE_SMBNTRENAME, count)
504
#define SMBntrename_time __profile_stats_value(PR_VALUE_SMBNTRENAME, time)
507
#define SMBsplopen_count __profile_stats_value(PR_VALUE_SMBSPLOPEN, count)
508
#define SMBsplopen_time __profile_stats_value(PR_VALUE_SMBSPLOPEN, time)
511
#define SMBsplwr_count __profile_stats_value(PR_VALUE_SMBSPLWR, count)
512
#define SMBsplwr_time __profile_stats_value(PR_VALUE_SMBSPLWR, time)
514
PR_VALUE_SMBSPLCLOSE,
515
#define SMBsplclose_count __profile_stats_value(PR_VALUE_SMBSPLCLOSE, count)
516
#define SMBsplclose_time __profile_stats_value(PR_VALUE_SMBSPLCLOSE, time)
519
#define SMBsplretq_count __profile_stats_value(PR_VALUE_SMBSPLRETQ, count)
520
#define SMBsplretq_time __profile_stats_value(PR_VALUE_SMBSPLRETQ, time)
523
#define SMBsends_count __profile_stats_value(PR_VALUE_SMBSENDS, count)
524
#define SMBsends_time __profile_stats_value(PR_VALUE_SMBSENDS, time)
527
#define SMBsendb_count __profile_stats_value(PR_VALUE_SMBSENDB, count)
528
#define SMBsendb_time __profile_stats_value(PR_VALUE_SMBSENDB, time)
531
#define SMBfwdname_count __profile_stats_value(PR_VALUE_SMBFWDNAME, count)
532
#define SMBfwdname_time __profile_stats_value(PR_VALUE_SMBFWDNAME, time)
535
#define SMBcancelf_count __profile_stats_value(PR_VALUE_SMBCANCELF, count)
536
#define SMBcancelf_time __profile_stats_value(PR_VALUE_SMBCANCELF, time)
539
#define SMBgetmac_count __profile_stats_value(PR_VALUE_SMBGETMAC, count)
540
#define SMBgetmac_time __profile_stats_value(PR_VALUE_SMBGETMAC, time)
542
PR_VALUE_SMBSENDSTRT,
543
#define SMBsendstrt_count __profile_stats_value(PR_VALUE_SMBSENDSTRT, count)
544
#define SMBsendstrt_time __profile_stats_value(PR_VALUE_SMBSENDSTRT, time)
547
#define SMBsendend_count __profile_stats_value(PR_VALUE_SMBSENDEND, count)
548
#define SMBsendend_time __profile_stats_value(PR_VALUE_SMBSENDEND, time)
551
#define SMBsendtxt_count __profile_stats_value(PR_VALUE_SMBSENDTXT, count)
552
#define SMBsendtxt_time __profile_stats_value(PR_VALUE_SMBSENDTXT, time)
555
#define SMBinvalid_count __profile_stats_value(PR_VALUE_SMBINVALID, count)
556
#define SMBinvalid_time __profile_stats_value(PR_VALUE_SMBINVALID, time)
558
/* Pathworks setdir command */
559
PR_VALUE_PATHWORKS_SETDIR,
560
#define pathworks_setdir_count __profile_stats_value(PR_VALUE_PATHWORKS_SETDIR, count)
561
#define pathworks_setdir_time __profile_stats_value(PR_VALUE_PATHWORKS_SETDIR, time)
563
/* These are the TRANS2 sub commands */
564
PR_VALUE_TRANS2_OPEN,
565
#define Trans2_open_count __profile_stats_value(PR_VALUE_TRANS2_OPEN, count)
566
#define Trans2_open_time __profile_stats_value(PR_VALUE_TRANS2_OPEN, time)
568
PR_VALUE_TRANS2_FINDFIRST,
569
#define Trans2_findfirst_count __profile_stats_value(PR_VALUE_TRANS2_FINDFIRST, count)
570
#define Trans2_findfirst_time __profile_stats_value(PR_VALUE_TRANS2_FINDFIRST, time)
572
PR_VALUE_TRANS2_FINDNEXT,
573
#define Trans2_findnext_count __profile_stats_value(PR_VALUE_TRANS2_FINDNEXT, count)
574
#define Trans2_findnext_time __profile_stats_value(PR_VALUE_TRANS2_FINDNEXT, time)
576
PR_VALUE_TRANS2_QFSINFO,
577
#define Trans2_qfsinfo_count __profile_stats_value(PR_VALUE_TRANS2_QFSINFO, count)
578
#define Trans2_qfsinfo_time __profile_stats_value(PR_VALUE_TRANS2_QFSINFO, time)
580
PR_VALUE_TRANS2_SETFSINFO,
581
#define Trans2_setfsinfo_count __profile_stats_value(PR_VALUE_TRANS2_SETFSINFO, count)
582
#define Trans2_setfsinfo_time __profile_stats_value(PR_VALUE_TRANS2_SETFSINFO, time)
584
PR_VALUE_TRANS2_QPATHINFO,
585
#define Trans2_qpathinfo_count __profile_stats_value(PR_VALUE_TRANS2_QPATHINFO, count)
586
#define Trans2_qpathinfo_time __profile_stats_value(PR_VALUE_TRANS2_QPATHINFO, time)
588
PR_VALUE_TRANS2_SETPATHINFO,
589
#define Trans2_setpathinfo_count __profile_stats_value(PR_VALUE_TRANS2_SETPATHINFO, count)
590
#define Trans2_setpathinfo_time __profile_stats_value(PR_VALUE_TRANS2_SETPATHINFO, time)
592
PR_VALUE_TRANS2_QFILEINFO,
593
#define Trans2_qfileinfo_count __profile_stats_value(PR_VALUE_TRANS2_QFILEINFO, count)
594
#define Trans2_qfileinfo_time __profile_stats_value(PR_VALUE_TRANS2_QFILEINFO, time)
596
PR_VALUE_TRANS2_SETFILEINFO,
597
#define Trans2_setfileinfo_count __profile_stats_value(PR_VALUE_TRANS2_SETFILEINFO, count)
598
#define Trans2_setfileinfo_time __profile_stats_value(PR_VALUE_TRANS2_SETFILEINFO, time)
600
PR_VALUE_TRANS2_FSCTL,
601
#define Trans2_fsctl_count __profile_stats_value(PR_VALUE_TRANS2_FSCTL, count)
602
#define Trans2_fsctl_time __profile_stats_value(PR_VALUE_TRANS2_FSCTL, time)
604
PR_VALUE_TRANS2_IOCTL,
605
#define Trans2_ioctl_count __profile_stats_value(PR_VALUE_TRANS2_IOCTL, count)
606
#define Trans2_ioctl_time __profile_stats_value(PR_VALUE_TRANS2_IOCTL, time)
608
PR_VALUE_TRANS2_FINDNOTIFYFIRST,
609
#define Trans2_findnotifyfirst_count __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYFIRST, count)
610
#define Trans2_findnotifyfirst_time __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYFIRST, time)
612
PR_VALUE_TRANS2_FINDNOTIFYNEXT,
613
#define Trans2_findnotifynext_count __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYNEXT, count)
614
#define Trans2_findnotifynext_time __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYNEXT, time)
616
PR_VALUE_TRANS2_MKDIR,
617
#define Trans2_mkdir_count __profile_stats_value(PR_VALUE_TRANS2_MKDIR, count)
618
#define Trans2_mkdir_time __profile_stats_value(PR_VALUE_TRANS2_MKDIR, time)
620
PR_VALUE_TRANS2_SESSION_SETUP,
621
#define Trans2_session_setup_count __profile_stats_value(PR_VALUE_TRANS2_SESSION_SETUP, count)
622
#define Trans2_session_setup_time __profile_stats_value(PR_VALUE_TRANS2_SESSION_SETUP, time)
624
PR_VALUE_TRANS2_GET_DFS_REFERRAL,
625
#define Trans2_get_dfs_referral_count __profile_stats_value(PR_VALUE_TRANS2_GET_DFS_REFERRAL, count)
626
#define Trans2_get_dfs_referral_time __profile_stats_value(PR_VALUE_TRANS2_GET_DFS_REFERRAL, time)
628
PR_VALUE_TRANS2_REPORT_DFS_INCONSISTANCY,
629
#define Trans2_report_dfs_inconsistancy_count __profile_stats_value(PR_VALUE_TRANS2_REPORT_DFS_INCONSISTANCY, count)
630
#define Trans2_report_dfs_inconsistancy_time __profile_stats_value(PR_VALUE_TRANS2_REPORT_DFS_INCONSISTANCY, time)
632
/* These are the NT transact sub commands. */
633
PR_VALUE_NT_TRANSACT_CREATE,
634
#define NT_transact_create_count __profile_stats_value(PR_VALUE_NT_TRANSACT_CREATE, count)
635
#define NT_transact_create_time __profile_stats_value(PR_VALUE_NT_TRANSACT_CREATE, time)
637
PR_VALUE_NT_TRANSACT_IOCTL,
638
#define NT_transact_ioctl_count __profile_stats_value(PR_VALUE_NT_TRANSACT_IOCTL, count)
639
#define NT_transact_ioctl_time __profile_stats_value(PR_VALUE_NT_TRANSACT_IOCTL, time)
641
PR_VALUE_NT_TRANSACT_SET_SECURITY_DESC,
642
#define NT_transact_set_security_desc_count __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_SECURITY_DESC, count)
643
#define NT_transact_set_security_desc_time __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_SECURITY_DESC, time)
645
PR_VALUE_NT_TRANSACT_NOTIFY_CHANGE,
646
#define NT_transact_notify_change_count __profile_stats_value(PR_VALUE_NT_TRANSACT_NOTIFY_CHANGE, count)
647
#define NT_transact_notify_change_time __profile_stats_value(PR_VALUE_NT_TRANSACT_NOTIFY_CHANGE, time)
649
PR_VALUE_NT_TRANSACT_RENAME,
650
#define NT_transact_rename_count __profile_stats_value(PR_VALUE_NT_TRANSACT_RENAME, count)
651
#define NT_transact_rename_time __profile_stats_value(PR_VALUE_NT_TRANSACT_RENAME, time)
653
PR_VALUE_NT_TRANSACT_QUERY_SECURITY_DESC,
654
#define NT_transact_query_security_desc_count __profile_stats_value(PR_VALUE_NT_TRANSACT_QUERY_SECURITY_DESC, count)
655
#define NT_transact_query_security_desc_time __profile_stats_value(PR_VALUE_NT_TRANSACT_QUERY_SECURITY_DESC, time)
657
PR_VALUE_NT_TRANSACT_GET_USER_QUOTA,
658
#define NT_transact_get_user_quota_count __profile_stats_value(PR_VALUE_NT_TRANSACT_GET_USER_QUOTA, count)
659
#define NT_transact_get_user_quota_time __profile_stats_value(PR_VALUE_NT_TRANSACT_GET_USER_QUOTA, time)
661
PR_VALUE_NT_TRANSACT_SET_USER_QUOTA,
662
#define NT_transact_set_user_quota_count __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_USER_QUOTA, count)
663
#define NT_transact_set_user_quota_time __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_USER_QUOTA, time)
665
/* These are ACL manipulation calls */
667
#define get_nt_acl_count __profile_stats_value(PR_VALUE_GET_NT_ACL, count)
668
#define get_nt_acl_time __profile_stats_value(PR_VALUE_GET_NT_ACL, time)
670
PR_VALUE_FGET_NT_ACL,
671
#define fget_nt_acl_count __profile_stats_value(PR_VALUE_FGET_NT_ACL, count)
672
#define fget_nt_acl_time __profile_stats_value(PR_VALUE_FGET_NT_ACL, time)
674
PR_VALUE_FSET_NT_ACL,
675
#define fset_nt_acl_count __profile_stats_value(PR_VALUE_FSET_NT_ACL, count)
676
#define fset_nt_acl_time __profile_stats_value(PR_VALUE_FSET_NT_ACL, time)
679
#define chmod_acl_count __profile_stats_value(PR_VALUE_CHMOD_ACL, count)
680
#define chmod_acl_time __profile_stats_value(PR_VALUE_CHMOD_ACL, time)
683
#define fchmod_acl_count __profile_stats_value(PR_VALUE_FCHMOD_ACL, count)
684
#define fchmod_acl_time __profile_stats_value(PR_VALUE_FCHMOD_ACL, time)
686
/* These are nmbd stats */
687
PR_VALUE_NAME_RELEASE,
688
#define name_release_count __profile_stats_value(PR_VALUE_NAME_RELEASE, count)
689
#define name_release_time __profile_stats_value(PR_VALUE_NAME_RELEASE, time)
691
PR_VALUE_NAME_REFRESH,
692
#define name_refresh_count __profile_stats_value(PR_VALUE_NAME_REFRESH, count)
693
#define name_refresh_time __profile_stats_value(PR_VALUE_NAME_REFRESH, time)
695
PR_VALUE_NAME_REGISTRATION,
696
#define name_registration_count __profile_stats_value(PR_VALUE_NAME_REGISTRATION, count)
697
#define name_registration_time __profile_stats_value(PR_VALUE_NAME_REGISTRATION, time)
699
PR_VALUE_NODE_STATUS,
700
#define node_status_count __profile_stats_value(PR_VALUE_NODE_STATUS, count)
701
#define node_status_time __profile_stats_value(PR_VALUE_NODE_STATUS, time)
704
#define name_query_count __profile_stats_value(PR_VALUE_NAME_QUERY, count)
705
#define name_query_time __profile_stats_value(PR_VALUE_NAME_QUERY, time)
707
PR_VALUE_HOST_ANNOUNCE,
708
#define host_announce_count __profile_stats_value(PR_VALUE_HOST_ANNOUNCE, count)
709
#define host_announce_time __profile_stats_value(PR_VALUE_HOST_ANNOUNCE, time)
711
PR_VALUE_WORKGROUP_ANNOUNCE,
712
#define workgroup_announce_count __profile_stats_value(PR_VALUE_WORKGROUP_ANNOUNCE, count)
713
#define workgroup_announce_time __profile_stats_value(PR_VALUE_WORKGROUP_ANNOUNCE, time)
715
PR_VALUE_LOCAL_MASTER_ANNOUNCE,
716
#define local_master_announce_count __profile_stats_value(PR_VALUE_LOCAL_MASTER_ANNOUNCE, count)
717
#define local_master_announce_time __profile_stats_value(PR_VALUE_LOCAL_MASTER_ANNOUNCE, time)
719
PR_VALUE_MASTER_BROWSER_ANNOUNCE,
720
#define master_browser_announce_count __profile_stats_value(PR_VALUE_MASTER_BROWSER_ANNOUNCE, count)
721
#define master_browser_announce_time __profile_stats_value(PR_VALUE_MASTER_BROWSER_ANNOUNCE, time)
723
PR_VALUE_LM_HOST_ANNOUNCE,
724
#define lm_host_announce_count __profile_stats_value(PR_VALUE_LM_HOST_ANNOUNCE, count)
725
#define lm_host_announce_time __profile_stats_value(PR_VALUE_LM_HOST_ANNOUNCE, time)
727
PR_VALUE_GET_BACKUP_LIST,
728
#define get_backup_list_count __profile_stats_value(PR_VALUE_GET_BACKUP_LIST, count)
729
#define get_backup_list_time __profile_stats_value(PR_VALUE_GET_BACKUP_LIST, time)
731
PR_VALUE_RESET_BROWSER,
732
#define reset_browser_count __profile_stats_value(PR_VALUE_RESET_BROWSER, count)
733
#define reset_browser_time __profile_stats_value(PR_VALUE_RESET_BROWSER, time)
735
PR_VALUE_ANNOUNCE_REQUEST,
736
#define announce_request_count __profile_stats_value(PR_VALUE_ANNOUNCE_REQUEST, count)
737
#define announce_request_time __profile_stats_value(PR_VALUE_ANNOUNCE_REQUEST, time)
739
PR_VALUE_LM_ANNOUNCE_REQUEST,
740
#define lm_announce_request_count __profile_stats_value(PR_VALUE_LM_ANNOUNCE_REQUEST, count)
741
#define lm_announce_request_time __profile_stats_value(PR_VALUE_LM_ANNOUNCE_REQUEST, time)
743
PR_VALUE_DOMAIN_LOGON,
744
#define domain_logon_count __profile_stats_value(PR_VALUE_DOMAIN_LOGON, count)
745
#define domain_logon_time __profile_stats_value(PR_VALUE_DOMAIN_LOGON, time)
747
PR_VALUE_SYNC_BROWSE_LISTS,
748
#define sync_browse_lists_count __profile_stats_value(PR_VALUE_SYNC_BROWSE_LISTS, count)
749
#define sync_browse_lists_time __profile_stats_value(PR_VALUE_SYNC_BROWSE_LISTS, time)
751
PR_VALUE_RUN_ELECTIONS,
752
#define run_elections_count __profile_stats_value(PR_VALUE_RUN_ELECTIONS, count)
753
#define run_elections_time __profile_stats_value(PR_VALUE_RUN_ELECTIONS, time)
756
#define election_count __profile_stats_value(PR_VALUE_ELECTION, count)
757
#define election_time __profile_stats_value(PR_VALUE_ELECTION, time)
759
/* This mist remain the last value. */
761
}; /* enum profile_stats_values */
763
const char * profile_value_name(enum profile_stats_values val);
765
struct profile_stats {
766
/* general counters */
767
unsigned smb_count; /* how many SMB packets we have processed */
768
unsigned uid_changes; /* how many times we change our effective uid */
770
/* system call and protocol operation counters and cumulative times */
771
unsigned count[PR_VALUE_MAX];
772
unsigned time[PR_VALUE_MAX];
774
/* cumulative byte counts */
775
unsigned syscall_pread_bytes;
776
unsigned syscall_pwrite_bytes;
777
unsigned syscall_read_bytes;
778
unsigned syscall_write_bytes;
779
unsigned syscall_sendfile_bytes;
780
unsigned syscall_recvfile_bytes;
782
/* stat cache counters */
783
unsigned statcache_lookups;
784
unsigned statcache_misses;
785
unsigned statcache_hits;
787
/* write cache counters */
788
unsigned writecache_read_hits;
789
unsigned writecache_abutted_writes;
790
unsigned writecache_total_writes;
791
unsigned writecache_non_oplock_writes;
792
unsigned writecache_direct_writes;
793
unsigned writecache_init_writes;
794
unsigned writecache_flushed_writes[NUM_FLUSH_REASONS];
795
unsigned writecache_num_perfect_writes;
796
unsigned writecache_num_write_caches;
797
unsigned writecache_allocated_write_caches;
800
struct profile_header {
802
int prof_shm_version;
803
struct profile_stats stats;
806
extern struct profile_header *profile_h;
807
extern struct profile_stats *profile_p;
808
extern bool do_profile_flag;
809
extern bool do_profile_times;
813
/* these are helper macros - do not call them directly in the code
814
* use the DO_PROFILE_* START_PROFILE and END_PROFILE ones
815
* below which test for the profile flage first
817
#define INC_PROFILE_COUNT(x) profile_p->x++
818
#define DEC_PROFILE_COUNT(x) profile_p->x--
819
#define ADD_PROFILE_COUNT(x,y) profile_p->x += (y)
821
#if defined(HAVE_CLOCK_GETTIME)
823
extern clockid_t __profile_clock;
825
static inline uint64_t profile_timestamp(void)
829
/* FIXME: On a single-CPU system, or a system where we have bound
830
* daemon threads to single CPUs (eg. using cpusets or processor
831
* affinity), it might be preferable to use CLOCK_PROCESS_CPUTIME_ID.
834
clock_gettime(__profile_clock, &ts);
835
return (ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); /* usec */
840
static inline uint64_t profile_timestamp(void)
844
return (tv.tv_sec * 1000000) + tv.tv_usec;
849
/* end of helper macros */
851
#define DO_PROFILE_INC(x) \
852
if (do_profile_flag) { \
853
INC_PROFILE_COUNT(x); \
856
#define DO_PROFILE_DEC(x) \
857
if (do_profile_flag) { \
858
DEC_PROFILE_COUNT(x); \
861
#define DO_PROFILE_DEC_INC(x,y) \
862
if (do_profile_flag) { \
863
DEC_PROFILE_COUNT(x); \
864
INC_PROFILE_COUNT(y); \
867
#define DO_PROFILE_ADD(x,n) \
868
if (do_profile_flag) { \
869
ADD_PROFILE_COUNT(x,n); \
872
#define START_PROFILE(x) \
873
uint64_t __profstamp_##x = 0; \
874
if (do_profile_flag) { \
875
__profstamp_##x = do_profile_times ? profile_timestamp() : 0;\
876
INC_PROFILE_COUNT(x##_count); \
879
#define START_PROFILE_BYTES(x,n) \
880
uint64_t __profstamp_##x = 0; \
881
if (do_profile_flag) { \
882
__profstamp_##x = do_profile_times ? profile_timestamp() : 0;\
883
INC_PROFILE_COUNT(x##_count); \
884
ADD_PROFILE_COUNT(x##_bytes, n); \
887
#define END_PROFILE(x) \
888
if (do_profile_times) { \
889
ADD_PROFILE_COUNT(x##_time, \
890
profile_timestamp() - __profstamp_##x); \
894
#else /* WITH_PROFILE */
896
#define DO_PROFILE_INC(x)
897
#define DO_PROFILE_DEC(x)
898
#define DO_PROFILE_DEC_INC(x,y)
899
#define DO_PROFILE_ADD(x,n)
900
#define START_PROFILE(x)
901
#define START_PROFILE_BYTES(x,n)
902
#define END_PROFILE(x)
904
#endif /* WITH_PROFILE */