Blame view

include/linux/mmdebug.h 1.88 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
59ea74633   Jiri Slaby   MM: virtual addre...
2
3
  #ifndef LINUX_MM_DEBUG_H
  #define LINUX_MM_DEBUG_H 1
1d5cda407   James Morse   include/linux/mmd...
4
  #include <linux/bug.h>
e4f674229   Dave Hansen   mm: pass VM_BUG_O...
5
  #include <linux/stringify.h>
309381fea   Sasha Levin   mm: dump page whe...
6
  struct page;
0bf551397   Sasha Levin   mm: introduce dum...
7
  struct vm_area_struct;
31c9afa6d   Sasha Levin   mm: introduce VM_...
8
  struct mm_struct;
309381fea   Sasha Levin   mm: dump page whe...
9

d230dec18   Kirill A. Shutemov   mm: use 'const ch...
10
  extern void dump_page(struct page *page, const char *reason);
ff8e81163   Vlastimil Babka   mm, debug: move b...
11
  extern void __dump_page(struct page *page, const char *reason);
0bf551397   Sasha Levin   mm: introduce dum...
12
  void dump_vma(const struct vm_area_struct *vma);
31c9afa6d   Sasha Levin   mm: introduce VM_...
13
  void dump_mm(const struct mm_struct *mm);
309381fea   Sasha Levin   mm: dump page whe...
14

59ea74633   Jiri Slaby   MM: virtual addre...
15
16
  #ifdef CONFIG_DEBUG_VM
  #define VM_BUG_ON(cond) BUG_ON(cond)
e4f674229   Dave Hansen   mm: pass VM_BUG_O...
17
18
19
20
21
22
23
  #define VM_BUG_ON_PAGE(cond, page)					\
  	do {								\
  		if (unlikely(cond)) {					\
  			dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\
  			BUG();						\
  		}							\
  	} while (0)
fa3759ccd   Sasha Levin   mm: introduce VM_...
24
25
26
27
28
29
30
  #define VM_BUG_ON_VMA(cond, vma)					\
  	do {								\
  		if (unlikely(cond)) {					\
  			dump_vma(vma);					\
  			BUG();						\
  		}							\
  	} while (0)
31c9afa6d   Sasha Levin   mm: introduce VM_...
31
32
33
34
35
36
37
  #define VM_BUG_ON_MM(cond, mm)						\
  	do {								\
  		if (unlikely(cond)) {					\
  			dump_mm(mm);					\
  			BUG();						\
  		}							\
  	} while (0)
02a8efeda   Andrew Morton   include/linux/mmd...
38
39
  #define VM_WARN_ON(cond) WARN_ON(cond)
  #define VM_WARN_ON_ONCE(cond) WARN_ON_ONCE(cond)
ef6b571fb   Andrew Morton   include/linux/mmd...
40
  #define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format)
a54f9aeba   Aneesh Kumar K.V   include/linux/mmd...
41
  #define VM_WARN(cond, format...) WARN(cond, format)
59ea74633   Jiri Slaby   MM: virtual addre...
42
  #else
02602a18c   Konstantin Khlebnikov   bug: completely r...
43
  #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond)
309381fea   Sasha Levin   mm: dump page whe...
44
  #define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond)
fa3759ccd   Sasha Levin   mm: introduce VM_...
45
  #define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond)
31c9afa6d   Sasha Levin   mm: introduce VM_...
46
  #define VM_BUG_ON_MM(cond, mm) VM_BUG_ON(cond)
02a8efeda   Andrew Morton   include/linux/mmd...
47
48
  #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond)
  #define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)
ef6b571fb   Andrew Morton   include/linux/mmd...
49
  #define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)
a54f9aeba   Aneesh Kumar K.V   include/linux/mmd...
50
  #define VM_WARN(cond, format...) BUILD_BUG_ON_INVALID(cond)
59ea74633   Jiri Slaby   MM: virtual addre...
51
52
53
54
55
  #endif
  
  #ifdef CONFIG_DEBUG_VIRTUAL
  #define VIRTUAL_BUG_ON(cond) BUG_ON(cond)
  #else
7aa413def   Ingo Molnar   x86, MM: virtual ...
56
  #define VIRTUAL_BUG_ON(cond) do { } while (0)
59ea74633   Jiri Slaby   MM: virtual addre...
57
  #endif
95ad97554   Kirill A. Shutemov   page-flags: intro...
58
59
60
61
62
  #ifdef CONFIG_DEBUG_VM_PGFLAGS
  #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page)
  #else
  #define VM_BUG_ON_PGFLAGS(cond, page) BUILD_BUG_ON_INVALID(cond)
  #endif
59ea74633   Jiri Slaby   MM: virtual addre...
63
  #endif