Replace two mutexes in struct clock_thread that are intended to make
the clock threads start simultaneously by a fio_mutex.
This patch avoids that drd reports the following:
==23831== Thread 2:
==23831== Mutex not locked by calling thread: mutex 0x6cb7bf8, recursion count 1, owner 1.
==23831== at 0x4C38EC3: pthread_mutex_unlock_intercept (drd_pthread_intercepts.c:978)
==23831== by 0x4C38EC3: pthread_mutex_unlock (drd_pthread_intercepts.c:991)
==23831== by 0x420974: clock_thread_fn (gettime.c:604)
==23831== by 0x4C34C44: vgDrd_thread_wrapper (drd_pthread_intercepts.c:444)
==23831== by 0x5E4159A: start_thread (in /lib64/libpthread-2.27.so)
==23831== by 0x6356A1E: clone (in /lib64/libc-2.27.so)
==23924== Mutex still locked at thread exit: mutex 0x6cb7bd0, recursion count 1, owner 2.
==23924== at 0x4C35BF2: pthread_join_intercept (drd_pthread_intercepts.c:711)
==23924== by 0x4C35BF2: pthread_join (drd_pthread_intercepts.c:718)
==23924== by 0x420D7F: fio_monotonic_clocktest (gettime.c:722)
==23924== by 0x420441: fio_clock_init (gettime.c:424)
==23924== by 0x437526: fio_time_init (time.c:141)
==23924== by 0x49BF41: main (fio.c:56)
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
T_AXMAP_PROGS = t/axmap
T_LFSR_TEST_OBJS = t/lfsr-test.o
T_AXMAP_PROGS = t/axmap
T_LFSR_TEST_OBJS = t/lfsr-test.o
-T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o t/log.o t/debug.o t/arch.o
+T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o fio_sem.o pshared.o \
+ t/log.o t/debug.o t/arch.o
T_LFSR_TEST_PROGS = t/lfsr-test
T_GEN_RAND_OBJS = t/gen-rand.o
T_LFSR_TEST_PROGS = t/lfsr-test
T_GEN_RAND_OBJS = t/gen-rand.o
#include <time.h>
#include "fio.h"
#include <time.h>
#include "fio.h"
#include "smalloc.h"
#include "hash.h"
#include "smalloc.h"
#include "hash.h"
pthread_t thread;
int cpu;
int debug;
pthread_t thread;
int cpu;
int debug;
- pthread_mutex_t lock;
- pthread_mutex_t started;
unsigned long nr_entries;
uint32_t *seq;
struct clock_entry *entries;
unsigned long nr_entries;
uint32_t *seq;
struct clock_entry *entries;
- pthread_mutex_lock(&t->lock);
- pthread_mutex_unlock(&t->started);
+ fio_sem_down(&t->lock);
first = get_cpu_clock();
c = &t->entries[0];
first = get_cpu_clock();
c = &t->entries[0];
t->seq = &seq;
t->nr_entries = nr_entries;
t->entries = &entries[i * nr_entries];
t->seq = &seq;
t->nr_entries = nr_entries;
t->entries = &entries[i * nr_entries];
- pthread_mutex_init(&t->lock, NULL);
- pthread_mutex_init(&t->started, NULL);
- pthread_mutex_lock(&t->lock);
+ __fio_sem_init(&t->lock, FIO_SEM_LOCKED);
if (pthread_create(&t->thread, NULL, clock_thread_fn, t)) {
failed++;
nr_cpus = i;
if (pthread_create(&t->thread, NULL, clock_thread_fn, t)) {
failed++;
nr_cpus = i;
for (i = 0; i < nr_cpus; i++) {
struct clock_thread *t = &cthreads[i];
for (i = 0; i < nr_cpus; i++) {
struct clock_thread *t = &cthreads[i];
- pthread_mutex_lock(&t->started);
- }
-
- for (i = 0; i < nr_cpus; i++) {
- struct clock_thread *t = &cthreads[i];
-
- pthread_mutex_unlock(&t->lock);
}
for (i = 0; i < nr_cpus; i++) {
}
for (i = 0; i < nr_cpus; i++) {
pthread_join(t->thread, &ret);
if (ret)
failed++;
pthread_join(t->thread, &ret);
if (ret)
failed++;
+ __fio_sem_remove(&t->lock);