summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-12-04 17:49:34 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2019-12-04 17:49:34 -0500
commitf712a866a474d70bfbe3a43aad2b04ceec13ddd3 (patch)
tree53a63cca6f67ddcf0a6da1afed417fedf8df17b1
parentffced87f08a9ff929f78fd941536d4f88507588a (diff)
Put valgrind support behind CONFIG_VALGRIND
-rw-r--r--Makefile1
-rw-r--r--include/linux/bug.h7
-rw-r--r--linux/blkdev.c4
3 files changed, 10 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index adea7611..5bd696a2 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,7 @@ endif
ifdef D
CFLAGS+=-Werror
CFLAGS+=-DCONFIG_BCACHEFS_DEBUG=y
+ CFLAGS+=-DCONFIG_VALGRIND=y
endif
PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib liblz4 libzstd"
diff --git a/include/linux/bug.h b/include/linux/bug.h
index eb53f39c..d47f5a49 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -3,8 +3,13 @@
#include <assert.h>
#include <linux/compiler.h>
+
+#ifdef CONFIG_VALGRIND
#include <valgrind/memcheck.h>
+#define DEBUG_MEMORY_FREED(p, len) VALGRIND_MAKE_MEM_UNDEFINED(p, len)
+#endif
+
#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
@@ -53,6 +58,4 @@
__ret_warn_on; \
})
-#define DEBUG_MEMORY_FREED(p, len) VALGRIND_MAKE_MEM_UNDEFINED(p, len)
-
#endif /* __TOOLS_LINUX_BUG_H */
diff --git a/linux/blkdev.c b/linux/blkdev.c
index 219f888e..709e7703 100644
--- a/linux/blkdev.c
+++ b/linux/blkdev.c
@@ -10,7 +10,9 @@
#include <libaio.h>
+#ifdef CONFIG_VALGRIND
#include <valgrind/memcheck.h>
+#endif
#include <linux/bio.h>
#include <linux/blkdev.h>
@@ -57,9 +59,11 @@ void generic_make_request(struct bio *bio)
.iov_len = len,
};
+#ifdef CONFIG_VALGRIND
/* To be pedantic it should only be on IO completion. */
if (bio_op(bio) == REQ_OP_READ)
VALGRIND_MAKE_MEM_DEFINED(start, len);
+#endif
}
struct iocb iocb = {