infra: add CONFIG_MARS_CHECKS

This commit is contained in:
Thomas Schoebel-Theuer 2013-04-26 21:05:35 +02:00
parent b0c09061e9
commit 54a8eb31f5
2 changed files with 27 additions and 3 deletions

View File

@ -9,11 +9,27 @@ config MARS
---help---
Experimental storage System. Only compile as a module!
config MARS_CHECKS
bool "enable simple runtime checks in MARS"
depends on MARS
default y
---help---
These checks should be rather lightweight. Use them
for beta testing and for production systems where
safety is more important than performance.
In case of bugs in the reference counting, an automatic repair
is attempted, which lowers the risk of memory corruptions.
Disable only if you need the absolutely last grain of
performance.
If unsure, say Y here.
config MARS_DEBUG
bool "enable runtime checks in MARS"
bool "enable full runtime checks and some tracing in MARS"
depends on MARS
default n
---help---
Some of these checks and some additional error tracing may
consume noticable amounts of memory.
OFF for production systems. ON for testing!
config MARS_DEBUG_DEFAULT

View File

@ -6,7 +6,7 @@
// checking
#ifdef CONFIG_MARS_DEBUG
#if defined(CONFIG_MARS_DEBUG) || defined(CONFIG_MARS_CHECKS)
#define BRICK_CHECKING true
#else
#define BRICK_CHECKING false
@ -16,7 +16,7 @@
do { \
if (BRICK_CHECKING) { \
int __test = atomic_read(atom); \
if (__test OP (minval)) { \
if (unlikely(__test OP (minval))) { \
atomic_set(atom, minval); \
BRICK_ERR("%d: atomic " #atom " " #OP " " #minval " (%d)\n", __LINE__, __test); \
} \
@ -34,6 +34,7 @@ do { \
} \
} while (0)
#ifdef CONFIG_MARS_DEBUG_MEM
#define CHECK_PTR_DEAD(ptr,label) \
do { \
if (BRICK_CHECKING && unlikely((ptr) == (void*)0x5a5a5a5a5a5a5a5a)) { \
@ -41,6 +42,9 @@ do { \
goto label; \
} \
} while (0)
#else
#define CHECK_PTR_DEAD(ptr,label) /*empty*/
#endif
#define CHECK_PTR_NULL(ptr,label) \
do { \
@ -51,6 +55,7 @@ do { \
} \
} while (0)
#ifdef CONFIG_MARS_DEBUG
#define CHECK_PTR(ptr,label) \
do { \
CHECK_PTR_NULL(ptr, label); \
@ -59,6 +64,9 @@ do { \
goto label; \
} \
} while (0)
#else
#define CHECK_PTR(ptr,label) CHECK_PTR_NULL(ptr,label)
#endif
#define CHECK_ASPECT(a_ptr, o_ptr,label) \
do { \