[SCM] Samba Shared Repository - branch v3-6-test updated

Björn Jacke bjacke at samba.org
Thu Sep 16 13:53:46 MDT 2010


The branch, v3-6-test has been updated
       via  318f727 s3: remove TspecDiff macro, we can use the shared nsec_time_diff function
       via  f454f13 s3: use nsec_time_diff instead of TspecDiff
       via  3f40dd4 s3/vfs_scannedonly: use smb_msleep instead of nanosleep
       via  5162140 s3/profile: remove the magical clock initialization from the profile code
       via  5626f1d s3/profiling: don't use CLOCK_PROCESS_CPUTIME_ID
       via  0dc37a6 libreplace: use CLOCK_HIGHRES when available
      from  e7ab997 s3: Add the PAC info3 struct to the netsamlogon_cache in ntlm_auth

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 318f727cb9d87617e86eaafa76005a08578eaf41
Author: Björn Jacke <bj at sernet.de>
Date:   Thu Sep 16 19:45:43 2010 +0200

    s3: remove TspecDiff macro, we can use the shared nsec_time_diff function

commit f454f13209d25d9c860b9c31f72ae0d996efbb31
Author: Björn Jacke <bj at sernet.de>
Date:   Thu Sep 16 19:02:27 2010 +0200

    s3: use nsec_time_diff instead of TspecDiff

commit 3f40dd42eda30c43333826dd381b8aa9f02821b2
Author: Björn Jacke <bj at sernet.de>
Date:   Thu Sep 16 18:52:45 2010 +0200

    s3/vfs_scannedonly: use smb_msleep instead of nanosleep
    
    Thanks to Joachim Schmitz. This fixes bug #7478

commit 5162140e3a91edadb5e2e4e858e42cd6721bd29f
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.
    (cherry picked from commit 4e8d6a779c9aa9b9418b4f835d831ad4492c3f6c)

commit 5626f1dec255b91f04097297f94ad71d86ddaa31
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Sep 14 22:17:47 2010 +0200

    s3/profiling: don't use CLOCK_PROCESS_CPUTIME_ID
    
    that clock is a CPU burnometer but we need a chronometer for profiling.
    (cherry picked from commit 5f6a145800a9e67c638f3ee05e43bb12fafffb48)

commit 0dc37a62ff21477a025d466868ececdf60791aca
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Sep 14 14:08:44 2010 +0200

    libreplace: use CLOCK_HIGHRES when available
    
    in Solaris 8 CLOCK_HIGHRES was the (only) name for CLOCK_MONOTONIC
    (cherry picked from commit 9c00fb4aa68ac7b044e954906e5ed20e039373a3)

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

Summary of changes:
 lib/replace/system/time.h         |    8 ++-
 source3/client/client.c           |    4 +-
 source3/include/proto.h           |    1 -
 source3/include/smb_macros.h      |    9 ----
 source3/include/smbprofile.h      |   11 +----
 source3/lib/util.c                |   17 --------
 source3/libsmb/namequery.c        |    4 +-
 source3/modules/vfs_scannedonly.c |    3 +-
 source3/profile/profile.c         |   74 -------------------------------------
 9 files changed, 13 insertions(+), 118 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/replace/system/time.h b/lib/replace/system/time.h
index 3605d26..5fce4db 100644
--- a/lib/replace/system/time.h
+++ b/lib/replace/system/time.h
@@ -73,10 +73,12 @@ typedef int clockid_t;
 int rep_clock_gettime(clockid_t clk_id, struct timespec *tp);
 #endif
 /* make sure we have a best effort CUSTOM_CLOCK_MONOTONIC we can rely on */
-#ifndef CLOCK_MONOTONIC
-#define CUSTOM_CLOCK_MONOTONIC CLOCK_REALTIME
-#else
+#if defined(CLOCK_MONOTONIC)
 #define CUSTOM_CLOCK_MONOTONIC CLOCK_MONOTONIC
+#elif defined(CLOCK_HIGHRES)
+#define CUSTOM_CLOCK_MONOTONIC CLOCK_HIGHRES
+#else
+#define CUSTOM_CLOCK_MONOTONIC CLOCK_REALTIME
 #endif
 
 #endif
diff --git a/source3/client/client.c b/source3/client/client.c
index 36cb112..62ff5d1 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1106,7 +1106,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
 		int this_time;
 
 		clock_gettime_mono(&tp_end);
-		this_time = TspecDiff(&tp_start,&tp_end);
+		this_time = nsec_time_diff(&tp_start,&tp_end)/1000000;
 		get_total_time_ms += this_time;
 		get_total_size += nread;
 
@@ -1749,7 +1749,7 @@ static int do_put(const char *rname, const char *lname, bool reput)
 		int this_time;
 
 		clock_gettime_mono(&tp_end);
-		this_time = TspecDiff(&tp_start,&tp_end);
+		this_time = nsec_time_diff(&tp_start,&tp_end)/1000000;
 		put_total_time_ms += this_time;
 		put_total_size += state.nread;
 
diff --git a/source3/include/proto.h b/source3/include/proto.h
index b6d15fb..596bd45 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1281,7 +1281,6 @@ char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid);
 char *procid_str_static(const struct server_id *pid);
 bool procid_valid(const struct server_id *pid);
 bool procid_is_local(const struct server_id *pid);
-int this_is_smp(void);
 bool trans_oob(uint32_t bufsize, uint32_t offset, uint32_t length);
 bool is_offset_safe(const char *buf_base, size_t buf_len, char *ptr, size_t off);
 char *get_safe_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index e72f2aa..757c8a2 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -153,15 +153,6 @@ values
   (((tvalnew)->tv_sec - (tvalold)->tv_sec)*1000 +  \
 	 ((int)(tvalnew)->tv_usec - (int)(tvalold)->tv_usec)/1000)
 
-/*******************************************************************
-find the difference in milliseconds between two struct timespec
-values
-********************************************************************/
-
-#define TspecDiff(tvalold,tvalnew) \
-  (((tvalnew)->tv_sec - (tvalold)->tv_sec)*1000 +  \
-	 ((int)(tvalnew)->tv_nsec - (int)(tvalold)->tv_nsec)/1000000)
-
 /****************************************************************************
 true if two IPv4 addresses are equal
 ****************************************************************************/
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/lib/util.c b/source3/lib/util.c
index fd7cdca..efa2ca2 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2737,23 +2737,6 @@ bool procid_is_local(const struct server_id *pid)
 #endif
 }
 
-int this_is_smp(void)
-{
-#if defined(HAVE_SYSCONF)
-
-#if defined(SYSCONF_SC_NPROC_ONLN)
-        return (sysconf(_SC_NPROC_ONLN) > 1) ? 1 : 0;
-#elif defined(SYSCONF_SC_NPROCESSORS_ONLN)
-        return (sysconf(_SC_NPROCESSORS_ONLN) > 1) ? 1 : 0;
-#else
-	return 0;
-#endif
-
-#else
-	return 0;
-#endif
-}
-
 /****************************************************************
  Check if offset/length fit into bufsize. Should probably be
  merged with is_offset_safe, but this would require a rewrite
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index c949d3b..00a3b97 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -307,7 +307,7 @@ NODE_STATUS_STRUCT *node_status_query(int fd,
 	while (1) {
 		struct timespec tp2;
 		clock_gettime_mono(&tp2);
-		if (TspecDiff(&tp,&tp2) > retry_time) {
+		if (nsec_time_diff(&tp,&tp2)/1000000 > retry_time) {
 			if (!retries)
 				break;
 			if (!found && !send_packet(&p))
@@ -716,7 +716,7 @@ struct sockaddr_storage *name_query(int fd,
 		struct timespec tp2;
 
 		clock_gettime_mono(&tp2);
-		if (TspecDiff(&tp,&tp2) > retry_time) {
+		if (nsec_time_diff(&tp,&tp2)/1000000 > retry_time) {
 			if (!retries)
 				break;
 			if (!found && !send_packet(&p))
diff --git a/source3/modules/vfs_scannedonly.c b/source3/modules/vfs_scannedonly.c
index b76bef4..ab5a7f4 100644
--- a/source3/modules/vfs_scannedonly.c
+++ b/source3/modules/vfs_scannedonly.c
@@ -476,13 +476,12 @@ static bool scannedonly_allow_access(vfs_handle_struct * handle,
 		flush_sendbuffer(handle);
 		while (retval != 0	/*&& errno == ENOENT */
 		       && i < recheck_tries) {
-			struct timespec req = { 0, recheck_time * 10000 };
 			DEBUG(SCANNEDONLY_DEBUG,
 			      ("scannedonly_allow_access, wait (try=%d "
 			       "(max %d), %d ms) for %s\n",
 			       i, recheck_tries,
 			       recheck_time, cache_smb_fname->base_name));
-			nanosleep(&req, NULL);
+			smb_msleep(recheck_time);
 			retval = SMB_VFS_NEXT_STAT(handle, cache_smb_fname);
 			i++;
 		}
diff --git a/source3/profile/profile.c b/source3/profile/profile.c
index 4a61753..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,71 +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_PROCESS_CPUTIME_ID
-	/* CLOCK_PROCESS_CPUTIME_ID is sufficiently fast that the
-	 * always profiling times is plausible. Unfortunately on Linux
-	 * it is only accurate if we can guarantee we will not be scheduled
-	 * scheduled onto a different CPU between samples. Until there is
-	 * some way to set processor affinity, we can only use this on
-	 * uniprocessors.
-	 */
-	if (!this_is_smp()) {
-	    if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == 0) {
-		    DEBUG(10, ("Using CLOCK_PROCESS_CPUTIME_ID "
-				"for profile_clock\n"));
-		    __profile_clock = CLOCK_PROCESS_CPUTIME_ID;
-		    have_profiling_clock = True;
-	    }
-	}
-#endif
-
-#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