The intention of this page is to enumerate debugging knobs that are enabled (by default) in HEAD, with instructions on what do they do, their impact on performance and how to turn them off. All of these options are turned off by default in RELENG_x branches.
The canonical documentation for kernel debugging options is http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/kerneldebug-options.html .
INVARIANTS, INVARIANT_SUPPORT
Scope: kernel config file
Performance impact: low
INVARIANT_SUPPORT brings a set of debugging functions to the kernel. INVARIANTS enables the use of this options for various parts of the kernel. The reason for this distinction is because kernel modules might be built with INVARIANTS but the kernel proper only needs INVARIANT_SUPPORT, thus reducing performance impact for the bulk of it. INVARIANTS_SUPPORT is what makes KASSERT work.
How to disable: Don't include INVARIANTS and INVARIANT_SUPPORT in the kernel config file
WITNESS
Scope: kernel config file
Performance impact: large
WITNESS enables advanced and computationally intensive checks of kernel locks. All aspects of the kernel take a big performance hit if this option is enabled, because the kernel is multi-threaded.
How to disable: Don't include WITNESS option in the kernel config file
Malloc debug flags
Scope: runtime
Performance impact: medium
The userland memory allocator has several debugging flags that can always be enabled or disabled during system operation. They are useful mostly to developers and for tracking certain memory allocation problems. See malloc(3) for the list of available flags.
How to disable: See malloc(3)
MALLOC_PRODUCTION
Scope: libc
Performance impact: medium
The userland memory allocator can do several checks for consistency of the allocations and its internal structures. This is an "inverse knob" - the existence of MALLOC_PRODUCTION disables these checks.
How to disable: edit lib/libc/stdlib/malloc.c or define it in /etc/src.conf