[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Jan 5 20:17:02 MST 2012


The branch, master has been updated
       via  7b42ceb Fix compile when TDB_TRACE is enabled.
       via  e8a7d9c Add a sys_get_number_of_cores() function that calls sysconf or sysctl and tunes the aio threads.
      from  200c22b samba-tool:dns: Check through all the DNS records for a match

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


- Log -----------------------------------------------------------------
commit 7b42ceb414d3e14c411dd95dcd0b200113fe1191
Author: Ira Cooper <samba at ira.wakeful.net>
Date:   Thu Jan 5 17:13:27 2012 -0800

    Fix compile when TDB_TRACE is enabled.
    
    Autobuild-User: Jeremy Allison <jra at samba.org>
    Autobuild-Date: Fri Jan  6 04:16:41 CET 2012 on sn-devel-104

commit e8a7d9c822ae4be4533f9e34885816a5b7831154
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 5 15:48:24 2012 -0800

    Add a sys_get_number_of_cores() function that calls sysconf or sysctl
    and tunes the aio threads.

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

Summary of changes:
 lib/tdb/common/tdb.c              |    2 +-
 source3/configure.in              |    3 +-
 source3/include/proto.h           |    1 +
 source3/lib/system.c              |   49 +++++++++++++++++++++++++++++++++++++
 source3/modules/vfs_aio_pthread.c |   15 ++++++++++-
 source3/wscript                   |    2 +-
 6 files changed, 67 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index c0f934a..fc1f560 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -1003,7 +1003,7 @@ bool tdb_write_all(int fd, const void *buf, size_t count)
 #ifdef TDB_TRACE
 static void tdb_trace_write(struct tdb_context *tdb, const char *str)
 {
-	if (!tdb_write_alltdb->tracefd, str, strlen(str)) {
+	if (!tdb_write_all(tdb->tracefd, str, strlen(str))) {
 		close(tdb->tracefd);
 		tdb->tracefd = -1;
 	}
diff --git a/source3/configure.in b/source3/configure.in
index 7ed093c..6a41f97 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -1119,8 +1119,9 @@ AC_SEARCH_LIBS(backtrace_symbols, [execinfo])
 AC_CHECK_FUNCS(backtrace_symbols)
 AC_CHECK_LIB(exc, trace_back_stack)
 
-# check for sysctlbyname for BSD systems
+# check for sysctlbyname and sysctl for BSD systems
 AC_CHECK_FUNCS(sysctlbyname)
+AC_CHECK_FUNCS(sysctl)
 
 #################################################
 # Check to see if core dump directory is defined in linux
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 2c12a5f..7a7f60a 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -390,6 +390,7 @@ int sys_lsetxattr (const char *path, const char *name, const void *value, size_t
 int sys_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags);
 uint32 unix_dev_major(SMB_DEV_T dev);
 uint32 unix_dev_minor(SMB_DEV_T dev);
+int sys_get_number_of_cores(void);
 int sys_aio_read(SMB_STRUCT_AIOCB *aiocb);
 int sys_aio_write(SMB_STRUCT_AIOCB *aiocb);
 ssize_t sys_aio_return(SMB_STRUCT_AIOCB *aiocb);
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 8598841..6934f62 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -26,6 +26,10 @@
 #include "system/passwd.h"
 #include "system/filesys.h"
 
+#ifdef HAVE_SYS_SYSCTL_H
+#include <sys/sysctl.h>
+#endif
+
 #ifdef HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
 #endif
@@ -2476,6 +2480,51 @@ uint32 unix_dev_minor(SMB_DEV_T dev)
 #endif
 }
 
+/*******************************************************************
+ Return the number of CPUs.
+********************************************************************/
+
+int sys_get_number_of_cores(void)
+{
+	int ret = -1;
+
+#if defined(HAVE_SYSCONF)
+#if defined(_SC_NPROCESSORS_ONLN)
+	ret = (int)sysconf(_SC_NPROCESSORS_ONLN);
+#endif
+#if defined(_SC_NPROCESSORS_CONF)
+	if (ret < 1) {
+		ret = (int)sysconf(_SC_NPROCESSORS_CONF);
+	}
+#endif
+#elif defined(HAVE_SYSCTL) && defined(CTL_HW)
+	int name[2];
+	unsigned int len = sizeof(ret);
+
+	name[0] = CTL_HW;
+#if defined(HW_AVAILCPU)
+	name[1] = HW_AVAILCPU;
+
+	if (sysctl(name, 2, &ret, &len, NULL, 0) == -1) {
+		ret = -1;
+	}
+#endif
+#if defined(HW_NCPU)
+	if(ret < 1) {
+		name[0] = CTL_HW;
+		name[1] = HW_NCPU;
+		if (sysctl(nm, 2, &count, &len, NULL, 0) == -1) {
+			ret = -1;
+		}
+	}
+#endif
+#endif
+	if (ret < 1) {
+		ret = 1;
+	}
+	return ret;
+}
+
 #if defined(WITH_AIO)
 
 /*******************************************************************
diff --git a/source3/modules/vfs_aio_pthread.c b/source3/modules/vfs_aio_pthread.c
index cccaa33..9217b69 100644
--- a/source3/modules/vfs_aio_pthread.c
+++ b/source3/modules/vfs_aio_pthread.c
@@ -55,7 +55,17 @@ static void aio_pthread_handle_completion(struct event_context *event_ctx,
 
 static int aio_get_num_threads(void)
 {
-	return 10;
+	int num_cores = sys_get_number_of_cores();
+	DEBUG(10,("aio_get_num_threads: sys_get_number_of_cores "
+		"returned %d\n",
+		num_cores));
+	num_cores *= 2;
+	if (num_cores < 1) {
+		num_cores = 1;
+	}
+	/* Even on a single processor box give a little
+	   concurrency. */
+	return MIN(4,num_cores);
 }
 
 #if 0
@@ -102,7 +112,7 @@ static bool init_aio_threadpool(void)
 {
 	struct fd_event *sock_event = NULL;
 	int ret = 0;
-	int num_threads = aio_get_num_threads();
+	int num_threads;
 #if 0
 	struct timeval ne;
 #endif
@@ -111,6 +121,7 @@ static bool init_aio_threadpool(void)
 		return true;
 	}
 
+	num_threads = aio_get_num_threads();
 	ret = pthreadpool_init(num_threads, &pool);
 	if (ret) {
 		errno = ret;
diff --git a/source3/wscript b/source3/wscript
index 846917c..9a32ab7 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -256,7 +256,7 @@ seekdir64 select setea setenv setgidx setgroups setlocale setluid
 setmntent setpgid setpriv setproplist setsid setuidx
 setxattr shmget shm_open sigaction sigblock sigprocmask sigset
 sizeof_proplist_entry _stat __stat stat64 _stat64 __stat64 statvfs
-strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctlbyname
+strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctl sysctlbyname
 __sys_llseek syslog _telldir __telldir telldir64 textdomain timegm
 utimensat vsyslog _write __write __xstat
 ''')


-- 
Samba Shared Repository


More information about the samba-cvs mailing list