diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-12-04 17:49:34 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2019-12-04 17:49:34 -0500 |
commit | f712a866a474d70bfbe3a43aad2b04ceec13ddd3 (patch) | |
tree | 53a63cca6f67ddcf0a6da1afed417fedf8df17b1 | |
parent | ffced87f08a9ff929f78fd941536d4f88507588a (diff) |
Put valgrind support behind CONFIG_VALGRIND
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | include/linux/bug.h | 7 | ||||
-rw-r--r-- | linux/blkdev.c | 4 |
3 files changed, 10 insertions, 2 deletions
@@ -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 = { |