Changeset 740 for vendor/current/source3/profile/profile.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/profile/profile.c
r414 r740 21 21 22 22 #include "includes.h" 23 #include "system/shmem.h" 24 #include "system/filesys.h" 25 #include "messages.h" 26 #include "smbprofile.h" 23 27 24 28 #ifdef WITH_PROFILE … … 29 33 static int shm_id; 30 34 static bool read_only; 31 #if defined(HAVE_CLOCK_GETTIME)32 clockid_t __profile_clock;33 bool have_profiling_clock = False;34 #endif35 35 #endif 36 36 … … 61 61 break; 62 62 case 2: /* turn on complete profiling */ 63 64 #if defined(HAVE_CLOCK_GETTIME)65 if (!have_profiling_clock) {66 do_profile_flag = True;67 do_profile_times = False;68 DEBUG(1,("INFO: Profiling counts turned ON from "69 "pid %d\n", (int)procid_to_pid(&src)));70 DEBUGADD(1,("INFO: Profiling times disabled "71 "due to lack of a suitable clock\n"));72 break;73 }74 #endif75 76 63 do_profile_flag = True; 77 64 do_profile_times = True; … … 137 124 open the profiling shared memory area 138 125 ******************************************************************/ 139 140 #ifdef HAVE_CLOCK_GETTIME141 142 /* Find a clock. Just because the definition for a particular clock ID is143 * present doesn't mean the system actually supports it.144 */145 static void init_clock_gettime(void)146 {147 struct timespec ts;148 149 have_profiling_clock = False;150 151 #ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID152 /* CLOCK_PROCESS_CPUTIME_ID is sufficiently fast that the153 * always profiling times is plausible. Unfortunately on Linux154 * it is only accurate if we can guarantee we will not be scheduled155 * scheduled onto a different CPU between samples. Until there is156 * some way to set processor affinity, we can only use this on157 * uniprocessors.158 */159 if (!this_is_smp()) {160 if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == 0) {161 DEBUG(10, ("Using CLOCK_PROCESS_CPUTIME_ID "162 "for profile_clock\n"));163 __profile_clock = CLOCK_PROCESS_CPUTIME_ID;164 have_profiling_clock = True;165 }166 }167 #endif168 169 #ifdef HAVE_CLOCK_MONOTONIC170 if (!have_profiling_clock &&171 clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {172 DEBUG(10, ("Using CLOCK_MONOTONIC for profile_clock\n"));173 __profile_clock = CLOCK_MONOTONIC;174 have_profiling_clock = True;175 }176 #endif177 178 #ifdef HAVE_CLOCK_REALTIME179 /* POSIX says that CLOCK_REALTIME should be defined everywhere180 * where we have clock_gettime...181 */182 if (!have_profiling_clock &&183 clock_gettime(CLOCK_REALTIME, &ts) == 0) {184 __profile_clock = CLOCK_REALTIME;185 have_profiling_clock = True;186 187 SMB_WARN(__profile_clock != CLOCK_REALTIME,188 ("forced to use a slow profiling clock"));189 }190 191 #endif192 193 SMB_WARN(have_profiling_clock == True,194 ("could not find a working clock for profiling"));195 return;196 }197 #endif198 199 126 bool profile_setup(struct messaging_context *msg_ctx, bool rdonly) 200 127 { … … 202 129 203 130 read_only = rdonly; 204 205 #ifdef HAVE_CLOCK_GETTIME206 init_clock_gettime();207 #endif208 131 209 132 again: … … 315 238 "syscall_ntimes", /* PR_VALUE_SYSCALL_NTIMES */ 316 239 "syscall_ftruncate", /* PR_VALUE_SYSCALL_FTRUNCATE */ 240 "syscall_fallocate", /* PR_VALUE_SYSCALL_FALLOCATE */ 317 241 "syscall_fcntl_lock", /* PR_VALUE_SYSCALL_FCNTL_LOCK */ 318 242 "syscall_kernel_flock", /* PR_VALUE_SYSCALL_KERNEL_FLOCK */ … … 455 379 "run_elections", /* PR_VALUE_RUN_ELECTIONS */ 456 380 "election", /* PR_VALUE_ELECTION */ 381 "smb2_negprot", /* PR_VALUE_SMB2_NEGPROT */ 382 "smb2_sesssetup", /* PR_VALUE_SMB2_SESSETUP */ 383 "smb2_logoff", /* PR_VALUE_SMB2_LOGOFF */ 384 "smb2_tcon", /* PR_VALUE_SMB2_TCON */ 385 "smb2_tdis", /* PR_VALUE_SMB2_TDIS */ 386 "smb2_create", /* PR_VALUE_SMB2_CREATE */ 387 "smb2_close", /* PR_VALUE_SMB2_CLOSE */ 388 "smb2_flush", /* PR_VALUE_SMB2_FLUSH */ 389 "smb2_read", /* PR_VALUE_SMB2_READ */ 390 "smb2_write", /* PR_VALUE_SMB2_WRITE */ 391 "smb2_lock", /* PR_VALUE_SMB2_LOCK */ 392 "smb2_ioctl", /* PR_VALUE_SMB2_IOCTL */ 393 "smb2_cancel", /* PR_VALUE_SMB2_CANCEL */ 394 "smb2_keepalive", /* PR_VALUE_SMB2_KEEPALIVE */ 395 "smb2_find", /* PR_VALUE_SMB2_FIND */ 396 "smb2_notify", /* PR_VALUE_SMB2_NOTIFY */ 397 "smb2_getinfo", /* PR_VALUE_SMB2_GETINFO */ 398 "smb2_setinfo" /* PR_VALUE_SMB2_SETINFO */ 399 "smb2_break", /* PR_VALUE_SMB2_BREAK */ 457 400 "" /* PR_VALUE_MAX */ 458 401 };
Note:
See TracChangeset
for help on using the changeset viewer.