diff options
-rw-r--r-- | include/linux/mmdebug.h | 10 | ||||
-rw-r--r-- | mm/debug.c | 78 |
2 files changed, 88 insertions, 0 deletions
diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h index 569e4c8d0ebb..877ef226f90f 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h | |||
@@ -5,11 +5,13 @@ | |||
5 | 5 | ||
6 | struct page; | 6 | struct page; |
7 | struct vm_area_struct; | 7 | struct vm_area_struct; |
8 | struct mm_struct; | ||
8 | 9 | ||
9 | extern void dump_page(struct page *page, const char *reason); | 10 | extern void dump_page(struct page *page, const char *reason); |
10 | extern void dump_page_badflags(struct page *page, const char *reason, | 11 | extern void dump_page_badflags(struct page *page, const char *reason, |
11 | unsigned long badflags); | 12 | unsigned long badflags); |
12 | void dump_vma(const struct vm_area_struct *vma); | 13 | void dump_vma(const struct vm_area_struct *vma); |
14 | void dump_mm(const struct mm_struct *mm); | ||
13 | 15 | ||
14 | #ifdef CONFIG_DEBUG_VM | 16 | #ifdef CONFIG_DEBUG_VM |
15 | #define VM_BUG_ON(cond) BUG_ON(cond) | 17 | #define VM_BUG_ON(cond) BUG_ON(cond) |
@@ -27,6 +29,13 @@ void dump_vma(const struct vm_area_struct *vma); | |||
27 | BUG(); \ | 29 | BUG(); \ |
28 | } \ | 30 | } \ |
29 | } while (0) | 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) | ||
30 | #define VM_WARN_ON(cond) WARN_ON(cond) | 39 | #define VM_WARN_ON(cond) WARN_ON(cond) |
31 | #define VM_WARN_ON_ONCE(cond) WARN_ON_ONCE(cond) | 40 | #define VM_WARN_ON_ONCE(cond) WARN_ON_ONCE(cond) |
32 | #define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format) | 41 | #define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format) |
@@ -34,6 +43,7 @@ void dump_vma(const struct vm_area_struct *vma); | |||
34 | #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond) | 43 | #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond) |
35 | #define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond) | 44 | #define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond) |
36 | #define VM_BUG_ON_VMA(cond, vma) 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) | ||
37 | #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond) | 47 | #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond) |
38 | #define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond) | 48 | #define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond) |
39 | #define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond) | 49 | #define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond) |
diff --git a/mm/debug.c b/mm/debug.c index 697df9050193..5a1b6194089c 100644 --- a/mm/debug.c +++ b/mm/debug.c | |||
@@ -1,3 +1,10 @@ | |||
1 | /* | ||
2 | * mm/debug.c | ||
3 | * | ||
4 | * mm/ specific debug routines. | ||
5 | * | ||
6 | */ | ||
7 | |||
1 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
2 | #include <linux/mm.h> | 9 | #include <linux/mm.h> |
3 | #include <linux/ftrace_event.h> | 10 | #include <linux/ftrace_event.h> |
@@ -159,4 +166,75 @@ void dump_vma(const struct vm_area_struct *vma) | |||
159 | } | 166 | } |
160 | EXPORT_SYMBOL(dump_vma); | 167 | EXPORT_SYMBOL(dump_vma); |
161 | 168 | ||
169 | void dump_mm(const struct mm_struct *mm) | ||
170 | { | ||
171 | printk(KERN_ALERT | ||
172 | "mm %p mmap %p seqnum %d task_size %lu\n" | ||
173 | #ifdef CONFIG_MMU | ||
174 | "get_unmapped_area %p\n" | ||
175 | #endif | ||
176 | "mmap_base %lu mmap_legacy_base %lu highest_vm_end %lu\n" | ||
177 | "pgd %p mm_users %d mm_count %d nr_ptes %lu map_count %d\n" | ||
178 | "hiwater_rss %lx hiwater_vm %lx total_vm %lx locked_vm %lx\n" | ||
179 | "pinned_vm %lx shared_vm %lx exec_vm %lx stack_vm %lx\n" | ||
180 | "start_code %lx end_code %lx start_data %lx end_data %lx\n" | ||
181 | "start_brk %lx brk %lx start_stack %lx\n" | ||
182 | "arg_start %lx arg_end %lx env_start %lx env_end %lx\n" | ||
183 | "binfmt %p flags %lx core_state %p\n" | ||
184 | #ifdef CONFIG_AIO | ||
185 | "ioctx_table %p\n" | ||
186 | #endif | ||
187 | #ifdef CONFIG_MEMCG | ||
188 | "owner %p " | ||
189 | #endif | ||
190 | "exe_file %p\n" | ||
191 | #ifdef CONFIG_MMU_NOTIFIER | ||
192 | "mmu_notifier_mm %p\n" | ||
193 | #endif | ||
194 | #ifdef CONFIG_NUMA_BALANCING | ||
195 | "numa_next_scan %lu numa_scan_offset %lu numa_scan_seq %d\n" | ||
196 | #endif | ||
197 | #if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) | ||
198 | "tlb_flush_pending %d\n" | ||
199 | #endif | ||
200 | "%s", /* This is here to hold the comma */ | ||
201 | |||
202 | mm, mm->mmap, mm->vmacache_seqnum, mm->task_size, | ||
203 | #ifdef CONFIG_MMU | ||
204 | mm->get_unmapped_area, | ||
205 | #endif | ||
206 | mm->mmap_base, mm->mmap_legacy_base, mm->highest_vm_end, | ||
207 | mm->pgd, atomic_read(&mm->mm_users), | ||
208 | atomic_read(&mm->mm_count), | ||
209 | atomic_long_read((atomic_long_t *)&mm->nr_ptes), | ||
210 | mm->map_count, | ||
211 | mm->hiwater_rss, mm->hiwater_vm, mm->total_vm, mm->locked_vm, | ||
212 | mm->pinned_vm, mm->shared_vm, mm->exec_vm, mm->stack_vm, | ||
213 | mm->start_code, mm->end_code, mm->start_data, mm->end_data, | ||
214 | mm->start_brk, mm->brk, mm->start_stack, | ||
215 | mm->arg_start, mm->arg_end, mm->env_start, mm->env_end, | ||
216 | mm->binfmt, mm->flags, mm->core_state, | ||
217 | #ifdef CONFIG_AIO | ||
218 | mm->ioctx_table, | ||
219 | #endif | ||
220 | #ifdef CONFIG_MEMCG | ||
221 | mm->owner, | ||
222 | #endif | ||
223 | mm->exe_file, | ||
224 | #ifdef CONFIG_MMU_NOTIFIER | ||
225 | mm->mmu_notifier_mm, | ||
226 | #endif | ||
227 | #ifdef CONFIG_NUMA_BALANCING | ||
228 | mm->numa_next_scan, mm->numa_scan_offset, mm->numa_scan_seq, | ||
229 | #endif | ||
230 | #if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) | ||
231 | mm->tlb_flush_pending, | ||
232 | #endif | ||
233 | "" /* This is here to not have a comma! */ | ||
234 | ); | ||
235 | |||
236 | dump_flags(mm->def_flags, vmaflags_names, | ||
237 | ARRAY_SIZE(vmaflags_names)); | ||
238 | } | ||
239 | |||
162 | #endif /* CONFIG_DEBUG_VM */ | 240 | #endif /* CONFIG_DEBUG_VM */ |