From f712a866a474d70bfbe3a43aad2b04ceec13ddd3 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 4 Dec 2019 17:49:34 -0500 Subject: Put valgrind support behind CONFIG_VALGRIND --- Makefile | 1 + include/linux/bug.h | 7 +++++-- linux/blkdev.c | 4 ++++ 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 #include + +#ifdef CONFIG_VALGRIND #include +#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 +#ifdef CONFIG_VALGRIND #include +#endif #include #include @@ -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 = { -- cgit v1.2.3