Below is the list of changes that have just been committed into a local
5.1 repository of kgeorge. When kgeorge does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-08-24 18:06:44+03:00, gkodinov@stripped +3 -0
Bug #28284: Test "mysqlslap" reports "out of memory"
When locking a "fast" mutex a static variable cpu_count
was used as a flag to initialize itself on the first usage
by calling sysconf() and setting non-zero value.
This is not thread and optimization safe on some
platforms. That's why the global initialization needs
to be done once in a designated function.
This will also speed up the usage (by a small bit)
because it won't have to check if it's initialized on
every call.
Fixed by moving the fast mutexes initialization out of
my_pthread_fastmutex_lock() to fastmutex_global_init()
and call it from my_init()
include/my_pthread.h@stripped, 2007-08-24 18:06:42+03:00, gkodinov@stripped +1 -0
Bug #28284: move the fast mutexes initialization out of
my_pthread_fastmutex_lock() to fastmutex_global_init()
and call it from my_init()
mysys/my_init.c@stripped, 2007-08-24 18:06:42+03:00, gkodinov@stripped +3 -0
Bug #28284: move the fast mutexes initialization out of
my_pthread_fastmutex_lock() to fastmutex_global_init()
and call it from my_init()
mysys/thr_mutex.c@stripped, 2007-08-24 18:06:42+03:00, gkodinov@stripped +11 -6
Bug #28284: move the fast mutexes initialization out of
my_pthread_fastmutex_lock() to fastmutex_global_init()
and call it from my_init()
diff -Nrup a/include/my_pthread.h b/include/my_pthread.h
--- a/include/my_pthread.h 2007-06-25 19:21:16 +03:00
+++ b/include/my_pthread.h 2007-08-24 18:06:42 +03:00
@@ -538,6 +538,7 @@ typedef struct st_my_pthread_fastmutex_t
pthread_mutex_t mutex;
uint spins;
} my_pthread_fastmutex_t;
+void fastmutex_global_init(void);
int my_pthread_fastmutex_init(my_pthread_fastmutex_t *mp,
const pthread_mutexattr_t *attr);
diff -Nrup a/mysys/my_init.c b/mysys/my_init.c
--- a/mysys/my_init.c 2007-08-02 07:49:24 +03:00
+++ b/mysys/my_init.c 2007-08-24 18:06:42 +03:00
@@ -79,6 +79,9 @@ my_bool my_init(void)
#if defined(THREAD) && defined(SAFE_MUTEX)
safe_mutex_global_init(); /* Must be called early */
#endif
+#if defined(THREAD) && defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
+ fastmutex_global_init(); /* Must be called early */
+#endif
netware_init();
#ifdef THREAD
#if defined(HAVE_PTHREAD_INIT)
diff -Nrup a/mysys/thr_mutex.c b/mysys/thr_mutex.c
--- a/mysys/thr_mutex.c 2007-02-23 13:13:48 +02:00
+++ b/mysys/thr_mutex.c 2007-08-24 18:06:42 +03:00
@@ -394,15 +394,11 @@ ulong mutex_delay(ulong delayloops)
#define MY_PTHREAD_FASTMUTEX_SPINS 8
#define MY_PTHREAD_FASTMUTEX_DELAY 4
+static int cpu_count= 0;
+
int my_pthread_fastmutex_init(my_pthread_fastmutex_t *mp,
const pthread_mutexattr_t *attr)
{
- static int cpu_count= 0;
-#ifdef _SC_NPROCESSORS_CONF
- if (!cpu_count && (attr == MY_MUTEX_INIT_FAST))
- cpu_count= sysconf(_SC_NPROCESSORS_CONF);
-#endif
-
if ((cpu_count > 1) && (attr == MY_MUTEX_INIT_FAST))
mp->spins= MY_PTHREAD_FASTMUTEX_SPINS;
else
@@ -432,4 +428,13 @@ int my_pthread_fastmutex_lock(my_pthread
}
return pthread_mutex_lock(&mp->mutex);
}
+
+
+void fastmutex_global_init(void)
+{
+#ifdef _SC_NPROCESSORS_CONF
+ cpu_count= sysconf(_SC_NPROCESSORS_CONF);
+#endif
+}
+
#endif /* defined(THREAD) && defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX) */
| Thread |
|---|
| • bk commit into 5.1 tree (gkodinov:1.2572) BUG#28284 | kgeorge | 24 Aug |