Put valgrind support behind CONFIG_VALGRIND

This commit is contained in:
Kent Overstreet 2019-12-04 17:49:34 -05:00
parent ffced87f08
commit f712a866a4
3 changed files with 10 additions and 2 deletions

View File

@ -36,6 +36,7 @@ endif
ifdef D ifdef D
CFLAGS+=-Werror CFLAGS+=-Werror
CFLAGS+=-DCONFIG_BCACHEFS_DEBUG=y CFLAGS+=-DCONFIG_BCACHEFS_DEBUG=y
CFLAGS+=-DCONFIG_VALGRIND=y
endif endif
PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib liblz4 libzstd" PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib liblz4 libzstd"

View File

@ -3,8 +3,13 @@
#include <assert.h> #include <assert.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#ifdef CONFIG_VALGRIND
#include <valgrind/memcheck.h> #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) \ #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
@ -53,6 +58,4 @@
__ret_warn_on; \ __ret_warn_on; \
}) })
#define DEBUG_MEMORY_FREED(p, len) VALGRIND_MAKE_MEM_UNDEFINED(p, len)
#endif /* __TOOLS_LINUX_BUG_H */ #endif /* __TOOLS_LINUX_BUG_H */

View File

@ -10,7 +10,9 @@
#include <libaio.h> #include <libaio.h>
#ifdef CONFIG_VALGRIND
#include <valgrind/memcheck.h> #include <valgrind/memcheck.h>
#endif
#include <linux/bio.h> #include <linux/bio.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
@ -57,9 +59,11 @@ void generic_make_request(struct bio *bio)
.iov_len = len, .iov_len = len,
}; };
#ifdef CONFIG_VALGRIND
/* To be pedantic it should only be on IO completion. */ /* To be pedantic it should only be on IO completion. */
if (bio_op(bio) == REQ_OP_READ) if (bio_op(bio) == REQ_OP_READ)
VALGRIND_MAKE_MEM_DEFINED(start, len); VALGRIND_MAKE_MEM_DEFINED(start, len);
#endif
} }
struct iocb iocb = { struct iocb iocb = {