1#ifndef LINUX_MM_DEBUG_H 2#define LINUX_MM_DEBUG_H 1 3 4#include <linux/stringify.h> 5 6struct page; 7struct vm_area_struct; 8struct mm_struct; 9 10extern void dump_page(struct page *page, const char *reason); 11extern void dump_page_badflags(struct page *page, const char *reason, 12 unsigned long badflags); 13void dump_vma(const struct vm_area_struct *vma); 14void dump_mm(const struct mm_struct *mm); 15 16#ifdef CONFIG_DEBUG_VM 17#define VM_BUG_ON(cond) BUG_ON(cond) 18#define VM_BUG_ON_PAGE(cond, page) \ 19 do { \ 20 if (unlikely(cond)) { \ 21 dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\ 22 BUG(); \ 23 } \ 24 } while (0) 25#define VM_BUG_ON_VMA(cond, vma) \ 26 do { \ 27 if (unlikely(cond)) { \ 28 dump_vma(vma); \ 29 BUG(); \ 30 } \ 31 } while (0) 32#define VM_BUG_ON_MM(cond, mm) \ 33 do { \ 34 if (unlikely(cond)) { \ 35 dump_mm(mm); \ 36 BUG(); \ 37 } \ 38 } while (0) 39#define VM_WARN_ON(cond) WARN_ON(cond) 40#define VM_WARN_ON_ONCE(cond) WARN_ON_ONCE(cond) 41#define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format) 42#else 43#define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond) 44#define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond) 45#define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond) 46#define VM_BUG_ON_MM(cond, mm) VM_BUG_ON(cond) 47#define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond) 48#define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond) 49#define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond) 50#endif 51 52#ifdef CONFIG_DEBUG_VIRTUAL 53#define VIRTUAL_BUG_ON(cond) BUG_ON(cond) 54#else 55#define VIRTUAL_BUG_ON(cond) do { } while (0) 56#endif 57 58#endif 59