Suppress uninteresting data race reports
authorBart Van Assche <bart.vanassche@wdc.com>
Tue, 13 Mar 2018 21:44:51 +0000 (14:44 -0700)
committerBart Van Assche <bart.vanassche@wdc.com>
Thu, 15 Mar 2018 16:56:43 +0000 (09:56 -0700)
Thread checkers like Helgrind and DRD report all concurrent
modifications of variables that are serialized by a recognized
synchronization primitive. Suppress reports about intentionally
unsynchronized accesses.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
diskutil.c
eta.c
helper_thread.c
init.c

index 1f2471be50470377c0acca7bdec3e441e5c1b8fa..dd8fc6a20b3aec09875823f416369743a897af3e 100644 (file)
@@ -8,6 +8,11 @@
 #include <libgen.h>
 #include <math.h>
 #include <assert.h>
+#ifdef CONFIG_VALGRIND_DEV
+#include <valgrind/drd.h>
+#else
+#define DRD_IGNORE_VAR(x) do { } while (0)
+#endif
 
 #include "fio.h"
 #include "smalloc.h"
@@ -297,6 +302,7 @@ static struct disk_util *disk_util_add(struct thread_data *td, int majdev,
        if (!du)
                return NULL;
 
+       DRD_IGNORE_VAR(du->users);
        memset(du, 0, sizeof(*du));
        INIT_FLIST_HEAD(&du->list);
        l = snprintf(du->path, sizeof(du->path), "%s/stat", path);
diff --git a/eta.c b/eta.c
index 0b795263325bbef5372cfb8a6760ed3b089da521..3126f217d490ba27e05abe65394be285354f77a2 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -4,6 +4,11 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
+#ifdef CONFIG_VALGRIND_DEV
+#include <valgrind/drd.h>
+#else
+#define DRD_IGNORE_VAR(x) do { } while (0)
+#endif
 
 #include "fio.h"
 #include "lib/pow2.h"
@@ -668,6 +673,7 @@ void print_thread_status(void)
 
 void print_status_init(int thr_number)
 {
+       DRD_IGNORE_VAR(__run_str);
        __run_str[thr_number] = 'P';
        update_condensed_str(__run_str, run_str);
 }
index c890da4a3869327a9a5387d1f306487e8488cb1a..f0c717f5026db994509d88f6d86d21cebc447c3a 100644 (file)
@@ -1,3 +1,9 @@
+#ifdef CONFIG_VALGRIND_DEV
+#include <valgrind/drd.h>
+#else
+#define DRD_IGNORE_VAR(x) do { } while (0)
+#endif
+
 #include "fio.h"
 #include "smalloc.h"
 #include "helper_thread.h"
@@ -170,6 +176,8 @@ int helper_thread_create(struct fio_sem *startup_sem, struct sk_out *sk_out)
 
        hd->startup_sem = startup_sem;
 
+       DRD_IGNORE_VAR(helper_data);
+
        ret = pthread_create(&hd->thread, NULL, helper_thread_main, hd);
        if (ret) {
                log_err("Can't create helper thread: %s\n", strerror(ret));
diff --git a/init.c b/init.c
index 53aba18899c9129986b06786d8f35c0436526de4..e47e5384119b369891119b54467ed558dfa082c3 100644 (file)
--- a/init.c
+++ b/init.c
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dlfcn.h>
+#ifdef CONFIG_VALGRIND_DEV
+#include <valgrind/drd.h>
+#else
+#define DRD_IGNORE_VAR(x) do { } while (0)
+#endif
 
 #include "fio.h"
 #ifndef FIO_NO_HAVE_SHM_H
@@ -333,6 +338,8 @@ static void free_shm(void)
  */
 static int setup_thread_area(void)
 {
+       int i;
+
        if (threads)
                return 0;
 
@@ -376,6 +383,8 @@ static int setup_thread_area(void)
 #endif
 
        memset(threads, 0, max_jobs * sizeof(struct thread_data));
+       for (i = 0; i < max_jobs; i++)
+               DRD_IGNORE_VAR(threads[i]);
        fio_debug_jobp = (unsigned int *)(threads + max_jobs);
        *fio_debug_jobp = -1;
        fio_warned = fio_debug_jobp + 1;