Skip to contentSkip to conversation

multipathd: Suppress uninteresting data race reports

PATCH In review Bart Van Assche 2 participants 4 messages Aug 16, 2016 – Aug 29, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 multipathd: Suppress uninteresting data race reports

The global variable multipath_conf is modified through RCU. Hence avoid that the data race detection tools Helgrind and DRD report data races for this variable.

The global variable running_state is read without holding the mutex that protects changes of this variable. Suppress complaints about these reads.

The global variable uxsock_timeout is not protected by any mutex. Suppress complaints about using this variable.

This patch introduces a new build-time requirement, namely that the valgrind-devel package has been installed.

---
 multipathd/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
multipathd/main.c +8 -0
index 1d73b4c..54abfef 100644
@@ -23,6 +23,7 @@
 #endif
 #include <semaphore.h>
 #include <time.h>
+#include <valgrind/helgrind.h>
 
 /*
  * libcheckers
@@ -2520,6 +2521,13 @@ main (int argc, char *argv[])
 	int foreground = 0;
 	struct config *conf;
 
+	ANNOTATE_BENIGN_RACE_SIZED(&multipath_conf, sizeof(multipath_conf),
+				   "Manipulated through RCU");
+	ANNOTATE_BENIGN_RACE_SIZED(&running_state, sizeof(running_state),
+		"Suppress complaints about unprotected running_state reads");
+	ANNOTATE_BENIGN_RACE_SIZED(&uxsock_timeout, sizeof(uxsock_timeout),
+		"Suppress complaints about this scalar variable");
+
 	logsink = 1;
 
 	if (getuid() != 0) {
Signature · 1 line
2.9.2
#1 lore raw

Hi,

I think it would be fair to detect the valgrind headers presence in the Makefile and ifdef the include (else define dummy ANNOTATE_* macros).

Would you care to prepare that ?

Thanks.

Quoted 52 lines · Bart Van Assche

The global variable multipath_conf is modified through RCU. Hence avoid that the data race detection tools Helgrind and DRD report data races for this variable.

The global variable running_state is read without holding the mutex that protects changes of this variable. Suppress complaints about these reads.

The global variable uxsock_timeout is not protected by any mutex. Suppress complaints about using this variable.

This patch introduces a new build-time requirement, namely that the valgrind-devel package has been installed.

---
 multipathd/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
multipathd/main.c +8 -0
index 1d73b4c..54abfef 100644
@@ -23,6 +23,7 @@
 #endif
 #include <semaphore.h>
 #include <time.h>
+#include <valgrind/helgrind.h>
 
 /*
  * libcheckers
@@ -2520,6 +2521,13 @@ main (int argc, char *argv[])
        int foreground = 0;
        struct config *conf;
 
+       ANNOTATE_BENIGN_RACE_SIZED(&multipath_conf,
 sizeof(multipath_conf),
+                                  "Manipulated through RCU");
+       ANNOTATE_BENIGN_RACE_SIZED(&running_state, sizeof(running_state),
+               "Suppress complaints about unprotected running_state
 reads");
+       ANNOTATE_BENIGN_RACE_SIZED(&uxsock_timeout,
 sizeof(uxsock_timeout),
+               "Suppress complaints about this scalar variable");
+
        logsink = 1;

        if (getuid() != 0) {

--
2.9.2

#2 lore raw
Quoted 4 lines · Christophe Varoqui

I think it would be fair to detect the valgrind headers presence in the Makefile and ifdef the include (else define dummy ANNOTATE_* macros).

Would you care to prepare that ?

Hello Christophe,

How about adding a copy of the valgrind.h and helgrind.h header files to the multipath-tools source tree? This is the approach that is followed by several other projects, e.g. chromium. See also https://chromium.googlesource.com/chromium/src/base/+/master/third_party/valgrind/valgrind.h.

Thanks,

Bart.

#3 lore raw

I would merge that too, sure.

On Mon, Aug 29, 2016 at 5:51 PM, Bart Van Assche <[email protected]

Quoted 22 lines

wrote:

Quoted 5 lines · Christophe Varoqui

I think it would be fair to detect the valgrind headers presence in the Makefile and ifdef the include (else define dummy ANNOTATE_* macros).

Would you care to prepare that ?

Hello Christophe,

How about adding a copy of the valgrind.h and helgrind.h header files to the multipath-tools source tree? This is the approach that is followed by several other projects, e.g. chromium. See also
https://chromium.googlesource.com/chromium/src/base/+/master
/third_party/valgrind/valgrind.h.

Thanks,

Bart.