関数 | |
void | set_profile_level (int level, struct process_id src) |
void | profile_message (int msg_type, struct process_id src, void *buf, size_t len, void *private_data) |
void | reqprofile_message (int msg_type, struct process_id src, void *buf, size_t len, void *private_data) |
static void | init_clock_gettime (void) |
BOOL | profile_setup (BOOL rdonly) |
const char * | profile_value_name (enum profile_stats_values val) |
変数 | |
static int | shm_id |
static BOOL | read_only |
clockid_t | __profile_clock |
BOOL | have_profiling_clock = False |
profile_header * | profile_h |
profile_stats * | profile_p |
BOOL | do_profile_flag = False |
BOOL | do_profile_times = False |
void set_profile_level | ( | int | level, | |
struct process_id | src | |||
) |
参照先 do_profile_flag・do_profile_times・have_profiling_clock・procid_to_pid()・profile_p.
参照元 main()・profile_message().
00048 { 00049 #ifdef WITH_PROFILE 00050 switch (level) { 00051 case 0: /* turn off profiling */ 00052 do_profile_flag = False; 00053 do_profile_times = False; 00054 DEBUG(1,("INFO: Profiling turned OFF from pid %d\n", 00055 (int)procid_to_pid(&src))); 00056 break; 00057 case 1: /* turn on counter profiling only */ 00058 do_profile_flag = True; 00059 do_profile_times = False; 00060 DEBUG(1,("INFO: Profiling counts turned ON from pid %d\n", 00061 (int)procid_to_pid(&src))); 00062 break; 00063 case 2: /* turn on complete profiling */ 00064 00065 #if defined(HAVE_CLOCK_GETTIME) 00066 if (!have_profiling_clock) { 00067 do_profile_flag = True; 00068 do_profile_times = False; 00069 DEBUG(1,("INFO: Profiling counts turned ON from " 00070 "pid %d\n", (int)procid_to_pid(&src))); 00071 DEBUGADD(1,("INFO: Profiling times disabled " 00072 "due to lack of a suitable clock\n")); 00073 break; 00074 } 00075 #endif 00076 00077 do_profile_flag = True; 00078 do_profile_times = True; 00079 DEBUG(1,("INFO: Full profiling turned ON from pid %d\n", 00080 (int)procid_to_pid(&src))); 00081 break; 00082 case 3: /* reset profile values */ 00083 memset((char *)profile_p, 0, sizeof(*profile_p)); 00084 DEBUG(1,("INFO: Profiling values cleared from pid %d\n", 00085 (int)procid_to_pid(&src))); 00086 break; 00087 } 00088 #else /* WITH_PROFILE */ 00089 DEBUG(1,("INFO: Profiling support unavailable in this build.\n")); 00090 #endif /* WITH_PROFILE */ 00091 }
void profile_message | ( | int | msg_type, | |
struct process_id | src, | |||
void * | buf, | |||
size_t | len, | |||
void * | private_data | |||
) |
参照先 level・set_profile_level().
参照元 profile_setup().
00097 { 00098 int level; 00099 00100 memcpy(&level, buf, sizeof(int)); 00101 set_profile_level(level, src); 00102 }
void reqprofile_message | ( | int | msg_type, | |
struct process_id | src, | |||
void * | buf, | |||
size_t | len, | |||
void * | private_data | |||
) |
参照先 do_profile_flag・do_profile_times・level・message_send_pid()・procid_to_pid().
参照元 profile_setup().
00109 { 00110 int level; 00111 00112 #ifdef WITH_PROFILE 00113 level = 1 + (do_profile_flag?2:0) + (do_profile_times?4:0); 00114 #else 00115 level = 0; 00116 #endif 00117 DEBUG(1,("INFO: Received REQ_PROFILELEVEL message from PID %u\n", 00118 (unsigned int)procid_to_pid(&src))); 00119 message_send_pid(src, MSG_PROFILELEVEL, &level, sizeof(int), True); 00120 }
static void init_clock_gettime | ( | void | ) | [static] |
参照先 __profile_clock・have_profiling_clock・this_is_smp().
参照元 profile_setup().
00133 { 00134 struct timespec ts; 00135 00136 have_profiling_clock = False; 00137 00138 #ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID 00139 /* CLOCK_PROCESS_CPUTIME_ID is sufficiently fast that the 00140 * always profiling times is plausible. Unfortunately on Linux 00141 * it is only accurate if we can guarantee we will not be scheduled 00142 * scheduled onto a different CPU between samples. Until there is 00143 * some way to set processor affinity, we can only use this on 00144 * uniprocessors. 00145 */ 00146 if (!this_is_smp()) { 00147 if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == 0) { 00148 DEBUG(10, ("Using CLOCK_PROCESS_CPUTIME_ID " 00149 "for profile_clock\n")); 00150 __profile_clock = CLOCK_PROCESS_CPUTIME_ID; 00151 have_profiling_clock = True; 00152 } 00153 } 00154 #endif 00155 00156 #ifdef HAVE_CLOCK_MONOTONIC 00157 if (!have_profiling_clock && 00158 clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { 00159 DEBUG(10, ("Using CLOCK_MONOTONIC for profile_clock\n")); 00160 __profile_clock = CLOCK_MONOTONIC; 00161 have_profiling_clock = True; 00162 } 00163 #endif 00164 00165 #ifdef HAVE_CLOCK_REALTIME 00166 /* POSIX says that CLOCK_REALTIME should be defined everywhere 00167 * where we have clock_gettime... 00168 */ 00169 if (!have_profiling_clock && 00170 clock_gettime(CLOCK_REALTIME, &ts) == 0) { 00171 __profile_clock = CLOCK_REALTIME; 00172 have_profiling_clock = True; 00173 00174 SMB_WARN(__profile_clock != CLOCK_REALTIME, 00175 ("forced to use a slow profiling clock")); 00176 } 00177 00178 #endif 00179 00180 SMB_WARN(have_profiling_clock == True, 00181 ("could not find a working clock for profiling")); 00182 return; 00183 }
参照先 errno・init_clock_gettime()・message_register()・profile_h・profile_message()・profile_p・read_only・reqprofile_message()・sec_initial_gid()・sec_initial_uid()・shm_id・strerror().
参照元 main()・status_profile_dump()・status_profile_rates().
00187 { 00188 struct shmid_ds shm_ds; 00189 00190 read_only = rdonly; 00191 00192 #ifdef HAVE_CLOCK_GETTIME 00193 init_clock_gettime(); 00194 #endif 00195 00196 again: 00197 /* try to use an existing key */ 00198 shm_id = shmget(PROF_SHMEM_KEY, 0, 0); 00199 00200 /* if that failed then create one. There is a race condition here 00201 if we are running from inetd. Bad luck. */ 00202 if (shm_id == -1) { 00203 if (read_only) return False; 00204 shm_id = shmget(PROF_SHMEM_KEY, sizeof(*profile_h), 00205 IPC_CREAT | IPC_EXCL | IPC_PERMS); 00206 } 00207 00208 if (shm_id == -1) { 00209 DEBUG(0,("Can't create or use IPC area. Error was %s\n", 00210 strerror(errno))); 00211 return False; 00212 } 00213 00214 00215 profile_h = (struct profile_header *)shmat(shm_id, 0, 00216 read_only?SHM_RDONLY:0); 00217 if ((long)profile_p == -1) { 00218 DEBUG(0,("Can't attach to IPC area. Error was %s\n", 00219 strerror(errno))); 00220 return False; 00221 } 00222 00223 /* find out who created this memory area */ 00224 if (shmctl(shm_id, IPC_STAT, &shm_ds) != 0) { 00225 DEBUG(0,("ERROR shmctl : can't IPC_STAT. Error was %s\n", 00226 strerror(errno))); 00227 return False; 00228 } 00229 00230 if (shm_ds.shm_perm.cuid != sec_initial_uid() || 00231 shm_ds.shm_perm.cgid != sec_initial_gid()) { 00232 DEBUG(0,("ERROR: we did not create the shmem " 00233 "(owned by another user, uid %u, gid %u)\n", 00234 shm_ds.shm_perm.cuid, 00235 shm_ds.shm_perm.cgid)); 00236 return False; 00237 } 00238 00239 if (shm_ds.shm_segsz != sizeof(*profile_h)) { 00240 DEBUG(0,("WARNING: profile size is %d (expected %lu). Deleting\n", 00241 (int)shm_ds.shm_segsz, sizeof(*profile_h))); 00242 if (shmctl(shm_id, IPC_RMID, &shm_ds) == 0) { 00243 goto again; 00244 } else { 00245 return False; 00246 } 00247 } 00248 00249 if (!read_only && (shm_ds.shm_nattch == 1)) { 00250 memset((char *)profile_h, 0, sizeof(*profile_h)); 00251 profile_h->prof_shm_magic = PROF_SHM_MAGIC; 00252 profile_h->prof_shm_version = PROF_SHM_VERSION; 00253 DEBUG(3,("Initialised profile area\n")); 00254 } 00255 00256 profile_p = &profile_h->stats; 00257 message_register(MSG_PROFILE, profile_message, NULL); 00258 message_register(MSG_REQ_PROFILELEVEL, reqprofile_message, NULL); 00259 return True; 00260 }
const char* profile_value_name | ( | enum profile_stats_values | val | ) |
参照先 PR_VALUE_MAX.
00263 { 00264 static const char * valnames[PR_VALUE_MAX + 1] = 00265 { 00266 "smbd_idle", /* PR_VALUE_SMBD_IDLE */ 00267 "syscall_opendir", /* PR_VALUE_SYSCALL_OPENDIR */ 00268 "syscall_readdir", /* PR_VALUE_SYSCALL_READDIR */ 00269 "syscall_seekdir", /* PR_VALUE_SYSCALL_SEEKDIR */ 00270 "syscall_telldir", /* PR_VALUE_SYSCALL_TELLDIR */ 00271 "syscall_rewinddir", /* PR_VALUE_SYSCALL_REWINDDIR */ 00272 "syscall_mkdir", /* PR_VALUE_SYSCALL_MKDIR */ 00273 "syscall_rmdir", /* PR_VALUE_SYSCALL_RMDIR */ 00274 "syscall_closedir", /* PR_VALUE_SYSCALL_CLOSEDIR */ 00275 "syscall_open", /* PR_VALUE_SYSCALL_OPEN */ 00276 "syscall_close", /* PR_VALUE_SYSCALL_CLOSE */ 00277 "syscall_read", /* PR_VALUE_SYSCALL_READ */ 00278 "syscall_pread", /* PR_VALUE_SYSCALL_PREAD */ 00279 "syscall_write", /* PR_VALUE_SYSCALL_WRITE */ 00280 "syscall_pwrite", /* PR_VALUE_SYSCALL_PWRITE */ 00281 "syscall_lseek", /* PR_VALUE_SYSCALL_LSEEK */ 00282 "syscall_sendfile", /* PR_VALUE_SYSCALL_SENDFILE */ 00283 "syscall_rename", /* PR_VALUE_SYSCALL_RENAME */ 00284 "syscall_fsync", /* PR_VALUE_SYSCALL_FSYNC */ 00285 "syscall_stat", /* PR_VALUE_SYSCALL_STAT */ 00286 "syscall_fstat", /* PR_VALUE_SYSCALL_FSTAT */ 00287 "syscall_lstat", /* PR_VALUE_SYSCALL_LSTAT */ 00288 "syscall_unlink", /* PR_VALUE_SYSCALL_UNLINK */ 00289 "syscall_chmod", /* PR_VALUE_SYSCALL_CHMOD */ 00290 "syscall_fchmod", /* PR_VALUE_SYSCALL_FCHMOD */ 00291 "syscall_chown", /* PR_VALUE_SYSCALL_CHOWN */ 00292 "syscall_fchown", /* PR_VALUE_SYSCALL_FCHOWN */ 00293 "syscall_chdir", /* PR_VALUE_SYSCALL_CHDIR */ 00294 "syscall_getwd", /* PR_VALUE_SYSCALL_GETWD */ 00295 "syscall_ntimes", /* PR_VALUE_SYSCALL_NTIMES */ 00296 "syscall_ftruncate", /* PR_VALUE_SYSCALL_FTRUNCATE */ 00297 "syscall_fcntl_lock", /* PR_VALUE_SYSCALL_FCNTL_LOCK */ 00298 "syscall_kernel_flock", /* PR_VALUE_SYSCALL_KERNEL_FLOCK */ 00299 "syscall_linux_setlease", /* PR_VALUE_SYSCALL_LINUX_SETLEASE */ 00300 "syscall_fcntl_getlock", /* PR_VALUE_SYSCALL_FCNTL_GETLOCK */ 00301 "syscall_readlink", /* PR_VALUE_SYSCALL_READLINK */ 00302 "syscall_symlink", /* PR_VALUE_SYSCALL_SYMLINK */ 00303 "syscall_link", /* PR_VALUE_SYSCALL_LINK */ 00304 "syscall_mknod", /* PR_VALUE_SYSCALL_MKNOD */ 00305 "syscall_realpath", /* PR_VALUE_SYSCALL_REALPATH */ 00306 "syscall_get_quota", /* PR_VALUE_SYSCALL_GET_QUOTA */ 00307 "syscall_set_quota", /* PR_VALUE_SYSCALL_SET_QUOTA */ 00308 "SMBmkdir", /* PR_VALUE_SMBMKDIR */ 00309 "SMBrmdir", /* PR_VALUE_SMBRMDIR */ 00310 "SMBopen", /* PR_VALUE_SMBOPEN */ 00311 "SMBcreate", /* PR_VALUE_SMBCREATE */ 00312 "SMBclose", /* PR_VALUE_SMBCLOSE */ 00313 "SMBflush", /* PR_VALUE_SMBFLUSH */ 00314 "SMBunlink", /* PR_VALUE_SMBUNLINK */ 00315 "SMBmv", /* PR_VALUE_SMBMV */ 00316 "SMBgetatr", /* PR_VALUE_SMBGETATR */ 00317 "SMBsetatr", /* PR_VALUE_SMBSETATR */ 00318 "SMBread", /* PR_VALUE_SMBREAD */ 00319 "SMBwrite", /* PR_VALUE_SMBWRITE */ 00320 "SMBlock", /* PR_VALUE_SMBLOCK */ 00321 "SMBunlock", /* PR_VALUE_SMBUNLOCK */ 00322 "SMBctemp", /* PR_VALUE_SMBCTEMP */ 00323 "SMBmknew", /* PR_VALUE_SMBMKNEW */ 00324 "SMBcheckpath", /* PR_VALUE_SMBCHECKPATH */ 00325 "SMBexit", /* PR_VALUE_SMBEXIT */ 00326 "SMBlseek", /* PR_VALUE_SMBLSEEK */ 00327 "SMBlockread", /* PR_VALUE_SMBLOCKREAD */ 00328 "SMBwriteunlock", /* PR_VALUE_SMBWRITEUNLOCK */ 00329 "SMBreadbraw", /* PR_VALUE_SMBREADBRAW */ 00330 "SMBreadBmpx", /* PR_VALUE_SMBREADBMPX */ 00331 "SMBreadBs", /* PR_VALUE_SMBREADBS */ 00332 "SMBwritebraw", /* PR_VALUE_SMBWRITEBRAW */ 00333 "SMBwriteBmpx", /* PR_VALUE_SMBWRITEBMPX */ 00334 "SMBwriteBs", /* PR_VALUE_SMBWRITEBS */ 00335 "SMBwritec", /* PR_VALUE_SMBWRITEC */ 00336 "SMBsetattrE", /* PR_VALUE_SMBSETATTRE */ 00337 "SMBgetattrE", /* PR_VALUE_SMBGETATTRE */ 00338 "SMBlockingX", /* PR_VALUE_SMBLOCKINGX */ 00339 "SMBtrans", /* PR_VALUE_SMBTRANS */ 00340 "SMBtranss", /* PR_VALUE_SMBTRANSS */ 00341 "SMBioctl", /* PR_VALUE_SMBIOCTL */ 00342 "SMBioctls", /* PR_VALUE_SMBIOCTLS */ 00343 "SMBcopy", /* PR_VALUE_SMBCOPY */ 00344 "SMBmove", /* PR_VALUE_SMBMOVE */ 00345 "SMBecho", /* PR_VALUE_SMBECHO */ 00346 "SMBwriteclose", /* PR_VALUE_SMBWRITECLOSE */ 00347 "SMBopenX", /* PR_VALUE_SMBOPENX */ 00348 "SMBreadX", /* PR_VALUE_SMBREADX */ 00349 "SMBwriteX", /* PR_VALUE_SMBWRITEX */ 00350 "SMBtrans2", /* PR_VALUE_SMBTRANS2 */ 00351 "SMBtranss2", /* PR_VALUE_SMBTRANSS2 */ 00352 "SMBfindclose", /* PR_VALUE_SMBFINDCLOSE */ 00353 "SMBfindnclose", /* PR_VALUE_SMBFINDNCLOSE */ 00354 "SMBtcon", /* PR_VALUE_SMBTCON */ 00355 "SMBtdis", /* PR_VALUE_SMBTDIS */ 00356 "SMBnegprot", /* PR_VALUE_SMBNEGPROT */ 00357 "SMBsesssetupX", /* PR_VALUE_SMBSESSSETUPX */ 00358 "SMBulogoffX", /* PR_VALUE_SMBULOGOFFX */ 00359 "SMBtconX", /* PR_VALUE_SMBTCONX */ 00360 "SMBdskattr", /* PR_VALUE_SMBDSKATTR */ 00361 "SMBsearch", /* PR_VALUE_SMBSEARCH */ 00362 "SMBffirst", /* PR_VALUE_SMBFFIRST */ 00363 "SMBfunique", /* PR_VALUE_SMBFUNIQUE */ 00364 "SMBfclose", /* PR_VALUE_SMBFCLOSE */ 00365 "SMBnttrans", /* PR_VALUE_SMBNTTRANS */ 00366 "SMBnttranss", /* PR_VALUE_SMBNTTRANSS */ 00367 "SMBntcreateX", /* PR_VALUE_SMBNTCREATEX */ 00368 "SMBntcancel", /* PR_VALUE_SMBNTCANCEL */ 00369 "SMBntrename", /* PR_VALUE_SMBNTRENAME */ 00370 "SMBsplopen", /* PR_VALUE_SMBSPLOPEN */ 00371 "SMBsplwr", /* PR_VALUE_SMBSPLWR */ 00372 "SMBsplclose", /* PR_VALUE_SMBSPLCLOSE */ 00373 "SMBsplretq", /* PR_VALUE_SMBSPLRETQ */ 00374 "SMBsends", /* PR_VALUE_SMBSENDS */ 00375 "SMBsendb", /* PR_VALUE_SMBSENDB */ 00376 "SMBfwdname", /* PR_VALUE_SMBFWDNAME */ 00377 "SMBcancelf", /* PR_VALUE_SMBCANCELF */ 00378 "SMBgetmac", /* PR_VALUE_SMBGETMAC */ 00379 "SMBsendstrt", /* PR_VALUE_SMBSENDSTRT */ 00380 "SMBsendend", /* PR_VALUE_SMBSENDEND */ 00381 "SMBsendtxt", /* PR_VALUE_SMBSENDTXT */ 00382 "SMBinvalid", /* PR_VALUE_SMBINVALID */ 00383 "pathworks_setdir", /* PR_VALUE_PATHWORKS_SETDIR */ 00384 "Trans2_open", /* PR_VALUE_TRANS2_OPEN */ 00385 "Trans2_findfirst", /* PR_VALUE_TRANS2_FINDFIRST */ 00386 "Trans2_findnext", /* PR_VALUE_TRANS2_FINDNEXT */ 00387 "Trans2_qfsinfo", /* PR_VALUE_TRANS2_QFSINFO */ 00388 "Trans2_setfsinfo", /* PR_VALUE_TRANS2_SETFSINFO */ 00389 "Trans2_qpathinfo", /* PR_VALUE_TRANS2_QPATHINFO */ 00390 "Trans2_setpathinfo", /* PR_VALUE_TRANS2_SETPATHINFO */ 00391 "Trans2_qfileinfo", /* PR_VALUE_TRANS2_QFILEINFO */ 00392 "Trans2_setfileinfo", /* PR_VALUE_TRANS2_SETFILEINFO */ 00393 "Trans2_fsctl", /* PR_VALUE_TRANS2_FSCTL */ 00394 "Trans2_ioctl", /* PR_VALUE_TRANS2_IOCTL */ 00395 "Trans2_findnotifyfirst", /* PR_VALUE_TRANS2_FINDNOTIFYFIRST */ 00396 "Trans2_findnotifynext", /* PR_VALUE_TRANS2_FINDNOTIFYNEXT */ 00397 "Trans2_mkdir", /* PR_VALUE_TRANS2_MKDIR */ 00398 "Trans2_session_setup", /* PR_VALUE_TRANS2_SESSION_SETUP */ 00399 "Trans2_get_dfs_referral", /* PR_VALUE_TRANS2_GET_DFS_REFERRAL */ 00400 "Trans2_report_dfs_inconsistancy", /* PR_VALUE_TRANS2_REPORT_DFS_INCONSISTANCY */ 00401 "NT_transact_create", /* PR_VALUE_NT_TRANSACT_CREATE */ 00402 "NT_transact_ioctl", /* PR_VALUE_NT_TRANSACT_IOCTL */ 00403 "NT_transact_set_security_desc", /* PR_VALUE_NT_TRANSACT_SET_SECURITY_DESC */ 00404 "NT_transact_notify_change",/* PR_VALUE_NT_TRANSACT_NOTIFY_CHANGE */ 00405 "NT_transact_rename", /* PR_VALUE_NT_TRANSACT_RENAME */ 00406 "NT_transact_query_security_desc", /* PR_VALUE_NT_TRANSACT_QUERY_SECURITY_DESC */ 00407 "NT_transact_get_user_quota",/* PR_VALUE_NT_TRANSACT_GET_USER_QUOTA */ 00408 "NT_transact_set_user_quota",/* PR_VALUE_NT_TRANSACT_SET_USER_QUOTA */ 00409 "get_nt_acl", /* PR_VALUE_GET_NT_ACL */ 00410 "fget_nt_acl", /* PR_VALUE_FGET_NT_ACL */ 00411 "set_nt_acl", /* PR_VALUE_SET_NT_ACL */ 00412 "fset_nt_acl", /* PR_VALUE_FSET_NT_ACL */ 00413 "chmod_acl", /* PR_VALUE_CHMOD_ACL */ 00414 "fchmod_acl", /* PR_VALUE_FCHMOD_ACL */ 00415 "name_release", /* PR_VALUE_NAME_RELEASE */ 00416 "name_refresh", /* PR_VALUE_NAME_REFRESH */ 00417 "name_registration", /* PR_VALUE_NAME_REGISTRATION */ 00418 "node_status", /* PR_VALUE_NODE_STATUS */ 00419 "name_query", /* PR_VALUE_NAME_QUERY */ 00420 "host_announce", /* PR_VALUE_HOST_ANNOUNCE */ 00421 "workgroup_announce", /* PR_VALUE_WORKGROUP_ANNOUNCE */ 00422 "local_master_announce", /* PR_VALUE_LOCAL_MASTER_ANNOUNCE */ 00423 "master_browser_announce", /* PR_VALUE_MASTER_BROWSER_ANNOUNCE */ 00424 "lm_host_announce", /* PR_VALUE_LM_HOST_ANNOUNCE */ 00425 "get_backup_list", /* PR_VALUE_GET_BACKUP_LIST */ 00426 "reset_browser", /* PR_VALUE_RESET_BROWSER */ 00427 "announce_request", /* PR_VALUE_ANNOUNCE_REQUEST */ 00428 "lm_announce_request", /* PR_VALUE_LM_ANNOUNCE_REQUEST */ 00429 "domain_logon", /* PR_VALUE_DOMAIN_LOGON */ 00430 "sync_browse_lists", /* PR_VALUE_SYNC_BROWSE_LISTS */ 00431 "run_elections", /* PR_VALUE_RUN_ELECTIONS */ 00432 "election", /* PR_VALUE_ELECTION */ 00433 "" /* PR_VALUE_MAX */ 00434 }; 00435 00436 SMB_ASSERT(val >= 0); 00437 SMB_ASSERT(val < PR_VALUE_MAX); 00438 return valnames[val]; 00439 }
int shm_id [static] |
clockid_t __profile_clock |
BOOL have_profiling_clock = False |
struct profile_header* profile_h |
struct profile_stats* profile_p |
BOOL do_profile_flag = False |
BOOL do_profile_times = False |