summaryrefslogtreecommitdiff
path: root/source/profile
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2006-05-23 15:21:55 +0000
committerGerald Carter <jerry@samba.org>2006-05-23 15:21:55 +0000
commit3f7bb704a9e62e7a46a05838ec9300c2f6916c16 (patch)
treee2ca7f1b8da68d725e5359d7746f391fedcad6be /source/profile
parent34b471724d1c8eb9e020fce02fc538bd0993d1c4 (diff)
downloadsamba-3f7bb704a9e62e7a46a05838ec9300c2f6916c16.tar.gz
r15837: starting sync up for 3.0.23rc1 (in sync with SAMBA_3_0 r15822)
Diffstat (limited to 'source/profile')
-rw-r--r--source/profile/profile.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/source/profile/profile.c b/source/profile/profile.c
index 838383b1afe..ba9596301c6 100644
--- a/source/profile/profile.c
+++ b/source/profile/profile.c
@@ -28,6 +28,9 @@
#ifdef WITH_PROFILE
static int shm_id;
static BOOL read_only;
+#if defined(HAVE_CLOCK_GETTIME)
+clockid_t __profile_clock;
+#endif
#endif
struct profile_header *profile_h;
@@ -36,11 +39,6 @@ struct profile_stats *profile_p;
BOOL do_profile_flag = False;
BOOL do_profile_times = False;
-struct timeval profile_starttime;
-struct timeval profile_endtime;
-struct timeval profile_starttime_nested;
-struct timeval profile_endtime_nested;
-
/****************************************************************************
receive a set profile level message
****************************************************************************/
@@ -108,6 +106,24 @@ BOOL profile_setup(BOOL rdonly)
read_only = rdonly;
+#if defined(HAVE_CLOCK_GETTIME)
+ if (this_is_smp()) {
+ /* This is faster that gettimeofday, but not fast enough to
+ * leave it enabled in production.
+ */
+ __profile_clock = CLOCK_MONOTONIC;
+ } else {
+ /* CLOCK_PROCESS_CPUTIME_ID is sufficiently fast that the
+ * always profiling times is plausible. Unfortunately it is
+ * only accurate if we can guarantee we will not be scheduled
+ * onto a different CPU between samples. Until there is some
+ * way to set processor affinity, we can only use this on
+ * uniprocessors.
+ */
+ __profile_clock = CLOCK_PROCESS_CPUTIME_ID;
+ }
+#endif
+
again:
/* try to use an existing key */
shm_id = shmget(PROF_SHMEM_KEY, 0, 0);
@@ -142,8 +158,12 @@ BOOL profile_setup(BOOL rdonly)
return False;
}
- if (shm_ds.shm_perm.cuid != sec_initial_uid() || shm_ds.shm_perm.cgid != sec_initial_gid()) {
- DEBUG(0,("ERROR: we did not create the shmem (owned by another user)\n"));
+ if (shm_ds.shm_perm.cuid != sec_initial_uid() ||
+ shm_ds.shm_perm.cgid != sec_initial_gid()) {
+ DEBUG(0,("ERROR: we did not create the shmem "
+ "(owned by another user, uid %u, gid %u)\n",
+ shm_ds.shm_perm.cuid,
+ shm_ds.shm_perm.cgid));
return False;
}