[SCM] Samba Shared Repository - branch master updated

Björn Jacke bjacke at samba.org
Tue Sep 14 14:45:30 MDT 2010


The branch, master has been updated
       via  4e8d6a7 s3/profile: remove the magical clock initialization from the profile code
      from  5f6a145 s3/profiling: don't use CLOCK_PROCESS_CPUTIME_ID

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4e8d6a779c9aa9b9418b4f835d831ad4492c3f6c
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Sep 14 22:40:51 2010 +0200

    s3/profile: remove the magical clock initialization from the profile code
    
    there's no point in not profiling times if no monotonic clock is found -
    monotonic and realtime clock are equally fast. Just use clock_gettime_mono
    instead.

-----------------------------------------------------------------------

Summary of changes:
 source3/include/smbprofile.h |   11 ++------
 source3/profile/profile.c    |   56 ------------------------------------------
 2 files changed, 3 insertions(+), 64 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h
index 6076479..5015d2a 100644
--- a/source3/include/smbprofile.h
+++ b/source3/include/smbprofile.h
@@ -894,18 +894,13 @@ extern bool do_profile_times;
 #define DEC_PROFILE_COUNT(x) profile_p->x--
 #define ADD_PROFILE_COUNT(x,y) profile_p->x += (y)
 
-extern clockid_t __profile_clock;
-
 static inline uint64_t profile_timestamp(void)
 {
 	struct timespec ts;
 
-	/* FIXME: On a single-CPU system, or a system where we have bound
-	 * daemon threads to single CPUs (eg. using cpusets or processor
-	 * affinity), it might be preferable to use CLOCK_PROCESS_CPUTIME_ID.
-	 */
-
-	clock_gettime(__profile_clock, &ts);
+	/* we might prefer to use the _COARSE clock variant of CLOCK_MONOTONIC
+	   that one is faster but cached and "just" tick-wise precise */
+	clock_gettime_mono(&ts);
 	return (ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); /* usec */
 }
 
diff --git a/source3/profile/profile.c b/source3/profile/profile.c
index 3e0df15..59b409d 100644
--- a/source3/profile/profile.c
+++ b/source3/profile/profile.c
@@ -29,8 +29,6 @@
 #ifdef WITH_PROFILE
 static int shm_id;
 static bool read_only;
-clockid_t __profile_clock;
-bool have_profiling_clock = False;
 #endif
 
 struct profile_header *profile_h;
@@ -59,19 +57,6 @@ void set_profile_level(int level, struct server_id src)
 			 (int)procid_to_pid(&src)));
 		break;
 	case 2:		/* turn on complete profiling */
-
-#if defined(HAVE_CLOCK_GETTIME)
-		if (!have_profiling_clock) {
-			do_profile_flag = True;
-			do_profile_times = False;
-			DEBUG(1,("INFO: Profiling counts turned ON from "
-				"pid %d\n", (int)procid_to_pid(&src)));
-			DEBUGADD(1,("INFO: Profiling times disabled "
-				"due to lack of a suitable clock\n"));
-			break;
-		}
-#endif
-
 		do_profile_flag = True;
 		do_profile_times = True;
 		DEBUG(1,("INFO: Full profiling turned ON from pid %d\n",
@@ -135,53 +120,12 @@ static void reqprofile_message(struct messaging_context *msg_ctx,
 /*******************************************************************
   open the profiling shared memory area
   ******************************************************************/
-
-/* Find a clock. Just because the definition for a particular clock ID is
- * present doesn't mean the system actually supports it.
- */
-static void init_clock_gettime(void)
-{
-	struct timespec ts;
-
-	have_profiling_clock = False;
-
-#ifdef HAVE_CLOCK_MONOTONIC
-	if (!have_profiling_clock &&
-	    clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
-		DEBUG(10, ("Using CLOCK_MONOTONIC for profile_clock\n"));
-		__profile_clock = CLOCK_MONOTONIC;
-		have_profiling_clock = True;
-	}
-#endif
-
-#ifdef HAVE_CLOCK_REALTIME
-	/* POSIX says that CLOCK_REALTIME should be defined everywhere
-	 * where we have clock_gettime...
-	 */
-	if (!have_profiling_clock &&
-	    clock_gettime(CLOCK_REALTIME, &ts) == 0) {
-		__profile_clock = CLOCK_REALTIME;
-		have_profiling_clock = True;
-
-		SMB_WARN(__profile_clock != CLOCK_REALTIME,
-			("forced to use a slow profiling clock"));
-	}
-
-#endif
-
-	SMB_WARN(have_profiling_clock == True,
-		("could not find a working clock for profiling"));
-	return;
-}
-
 bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
 {
 	struct shmid_ds shm_ds;
 
 	read_only = rdonly;
 
-	init_clock_gettime();
-
  again:
 	/* try to use an existing key */
 	shm_id = shmget(PROF_SHMEM_KEY, 0, 0);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list