diff options
author | Sasha Levin <sasha.levin@oracle.com> | 2014-10-09 18:28:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-09 22:25:58 -0400 |
commit | 82742a3a5152195edd69528c0c9a1a6fb9caa293 (patch) | |
tree | 0949f1c68de59c8fbd88b8af383383bb882f8520 | |
parent | 81d0fa623c5b8dbd5279d9713094b0f9b0a00fb4 (diff) |
mm: move debug code out of page_alloc.c
dump_page() and dump_vma() are not specific to page_alloc.c, move them out
so page_alloc.c won't turn into the unofficial debug repository.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/Makefile | 2 | ||||
-rw-r--r-- | mm/debug.c | 162 | ||||
-rw-r--r-- | mm/page_alloc.c | 160 |
3 files changed, 163 insertions, 161 deletions
diff --git a/mm/Makefile b/mm/Makefile index fe7a053c0f45..f8ed7ab417b1 100644 --- a/mm/Makefile +++ b/mm/Makefile | |||
@@ -18,7 +18,7 @@ obj-y := filemap.o mempool.o oom_kill.o \ | |||
18 | mm_init.o mmu_context.o percpu.o slab_common.o \ | 18 | mm_init.o mmu_context.o percpu.o slab_common.o \ |
19 | compaction.o balloon_compaction.o vmacache.o \ | 19 | compaction.o balloon_compaction.o vmacache.o \ |
20 | interval_tree.o list_lru.o workingset.o \ | 20 | interval_tree.o list_lru.o workingset.o \ |
21 | iov_iter.o $(mmu-y) | 21 | iov_iter.o debug.o $(mmu-y) |
22 | 22 | ||
23 | obj-y += init-mm.o | 23 | obj-y += init-mm.o |
24 | 24 | ||
diff --git a/mm/debug.c b/mm/debug.c new file mode 100644 index 000000000000..697df9050193 --- /dev/null +++ b/mm/debug.c | |||
@@ -0,0 +1,162 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/mm.h> | ||
3 | #include <linux/ftrace_event.h> | ||
4 | #include <linux/memcontrol.h> | ||
5 | |||
6 | static const struct trace_print_flags pageflag_names[] = { | ||
7 | {1UL << PG_locked, "locked" }, | ||
8 | {1UL << PG_error, "error" }, | ||
9 | {1UL << PG_referenced, "referenced" }, | ||
10 | {1UL << PG_uptodate, "uptodate" }, | ||
11 | {1UL << PG_dirty, "dirty" }, | ||
12 | {1UL << PG_lru, "lru" }, | ||
13 | {1UL << PG_active, "active" }, | ||
14 | {1UL << PG_slab, "slab" }, | ||
15 | {1UL << PG_owner_priv_1, "owner_priv_1" }, | ||
16 | {1UL << PG_arch_1, "arch_1" }, | ||
17 | {1UL << PG_reserved, "reserved" }, | ||
18 | {1UL << PG_private, "private" }, | ||
19 | {1UL << PG_private_2, "private_2" }, | ||
20 | {1UL << PG_writeback, "writeback" }, | ||
21 | #ifdef CONFIG_PAGEFLAGS_EXTENDED | ||
22 | {1UL << PG_head, "head" }, | ||
23 | {1UL << PG_tail, "tail" }, | ||
24 | #else | ||
25 | {1UL << PG_compound, "compound" }, | ||
26 | #endif | ||
27 | {1UL << PG_swapcache, "swapcache" }, | ||
28 | {1UL << PG_mappedtodisk, "mappedtodisk" }, | ||
29 | {1UL << PG_reclaim, "reclaim" }, | ||
30 | {1UL << PG_swapbacked, "swapbacked" }, | ||
31 | {1UL << PG_unevictable, "unevictable" }, | ||
32 | #ifdef CONFIG_MMU | ||
33 | {1UL << PG_mlocked, "mlocked" }, | ||
34 | #endif | ||
35 | #ifdef CONFIG_ARCH_USES_PG_UNCACHED | ||
36 | {1UL << PG_uncached, "uncached" }, | ||
37 | #endif | ||
38 | #ifdef CONFIG_MEMORY_FAILURE | ||
39 | {1UL << PG_hwpoison, "hwpoison" }, | ||
40 | #endif | ||
41 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
42 | {1UL << PG_compound_lock, "compound_lock" }, | ||
43 | #endif | ||
44 | }; | ||
45 | |||
46 | static void dump_flags(unsigned long flags, | ||
47 | const struct trace_print_flags *names, int count) | ||
48 | { | ||
49 | const char *delim = ""; | ||
50 | unsigned long mask; | ||
51 | int i; | ||
52 | |||
53 | printk(KERN_ALERT "flags: %#lx(", flags); | ||
54 | |||
55 | /* remove zone id */ | ||
56 | flags &= (1UL << NR_PAGEFLAGS) - 1; | ||
57 | |||
58 | for (i = 0; i < count && flags; i++) { | ||
59 | |||
60 | mask = names[i].mask; | ||
61 | if ((flags & mask) != mask) | ||
62 | continue; | ||
63 | |||
64 | flags &= ~mask; | ||
65 | printk("%s%s", delim, names[i].name); | ||
66 | delim = "|"; | ||
67 | } | ||
68 | |||
69 | /* check for left over flags */ | ||
70 | if (flags) | ||
71 | printk("%s%#lx", delim, flags); | ||
72 | |||
73 | printk(")\n"); | ||
74 | } | ||
75 | |||
76 | void dump_page_badflags(struct page *page, const char *reason, | ||
77 | unsigned long badflags) | ||
78 | { | ||
79 | printk(KERN_ALERT | ||
80 | "page:%p count:%d mapcount:%d mapping:%p index:%#lx\n", | ||
81 | page, atomic_read(&page->_count), page_mapcount(page), | ||
82 | page->mapping, page->index); | ||
83 | BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS); | ||
84 | dump_flags(page->flags, pageflag_names, ARRAY_SIZE(pageflag_names)); | ||
85 | if (reason) | ||
86 | pr_alert("page dumped because: %s\n", reason); | ||
87 | if (page->flags & badflags) { | ||
88 | pr_alert("bad because of flags:\n"); | ||
89 | dump_flags(page->flags & badflags, | ||
90 | pageflag_names, ARRAY_SIZE(pageflag_names)); | ||
91 | } | ||
92 | mem_cgroup_print_bad_page(page); | ||
93 | } | ||
94 | |||
95 | void dump_page(struct page *page, const char *reason) | ||
96 | { | ||
97 | dump_page_badflags(page, reason, 0); | ||
98 | } | ||
99 | EXPORT_SYMBOL(dump_page); | ||
100 | |||
101 | #ifdef CONFIG_DEBUG_VM | ||
102 | |||
103 | static const struct trace_print_flags vmaflags_names[] = { | ||
104 | {VM_READ, "read" }, | ||
105 | {VM_WRITE, "write" }, | ||
106 | {VM_EXEC, "exec" }, | ||
107 | {VM_SHARED, "shared" }, | ||
108 | {VM_MAYREAD, "mayread" }, | ||
109 | {VM_MAYWRITE, "maywrite" }, | ||
110 | {VM_MAYEXEC, "mayexec" }, | ||
111 | {VM_MAYSHARE, "mayshare" }, | ||
112 | {VM_GROWSDOWN, "growsdown" }, | ||
113 | {VM_PFNMAP, "pfnmap" }, | ||
114 | {VM_DENYWRITE, "denywrite" }, | ||
115 | {VM_LOCKED, "locked" }, | ||
116 | {VM_IO, "io" }, | ||
117 | {VM_SEQ_READ, "seqread" }, | ||
118 | {VM_RAND_READ, "randread" }, | ||
119 | {VM_DONTCOPY, "dontcopy" }, | ||
120 | {VM_DONTEXPAND, "dontexpand" }, | ||
121 | {VM_ACCOUNT, "account" }, | ||
122 | {VM_NORESERVE, "noreserve" }, | ||
123 | {VM_HUGETLB, "hugetlb" }, | ||
124 | {VM_NONLINEAR, "nonlinear" }, | ||
125 | #if defined(CONFIG_X86) | ||
126 | {VM_PAT, "pat" }, | ||
127 | #elif defined(CONFIG_PPC) | ||
128 | {VM_SAO, "sao" }, | ||
129 | #elif defined(CONFIG_PARISC) || defined(CONFIG_METAG) || defined(CONFIG_IA64) | ||
130 | {VM_GROWSUP, "growsup" }, | ||
131 | #elif !defined(CONFIG_MMU) | ||
132 | {VM_MAPPED_COPY, "mappedcopy" }, | ||
133 | #else | ||
134 | {VM_ARCH_1, "arch_1" }, | ||
135 | #endif | ||
136 | {VM_DONTDUMP, "dontdump" }, | ||
137 | #ifdef CONFIG_MEM_SOFT_DIRTY | ||
138 | {VM_SOFTDIRTY, "softdirty" }, | ||
139 | #endif | ||
140 | {VM_MIXEDMAP, "mixedmap" }, | ||
141 | {VM_HUGEPAGE, "hugepage" }, | ||
142 | {VM_NOHUGEPAGE, "nohugepage" }, | ||
143 | {VM_MERGEABLE, "mergeable" }, | ||
144 | }; | ||
145 | |||
146 | void dump_vma(const struct vm_area_struct *vma) | ||
147 | { | ||
148 | printk(KERN_ALERT | ||
149 | "vma %p start %p end %p\n" | ||
150 | "next %p prev %p mm %p\n" | ||
151 | "prot %lx anon_vma %p vm_ops %p\n" | ||
152 | "pgoff %lx file %p private_data %p\n", | ||
153 | vma, (void *)vma->vm_start, (void *)vma->vm_end, vma->vm_next, | ||
154 | vma->vm_prev, vma->vm_mm, | ||
155 | (unsigned long)pgprot_val(vma->vm_page_prot), | ||
156 | vma->anon_vma, vma->vm_ops, vma->vm_pgoff, | ||
157 | vma->vm_file, vma->vm_private_data); | ||
158 | dump_flags(vma->vm_flags, vmaflags_names, ARRAY_SIZE(vmaflags_names)); | ||
159 | } | ||
160 | EXPORT_SYMBOL(dump_vma); | ||
161 | |||
162 | #endif /* CONFIG_DEBUG_VM */ | ||
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bfb73e025e02..c9710c9bbee2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -53,8 +53,6 @@ | |||
53 | #include <linux/kmemleak.h> | 53 | #include <linux/kmemleak.h> |
54 | #include <linux/compaction.h> | 54 | #include <linux/compaction.h> |
55 | #include <trace/events/kmem.h> | 55 | #include <trace/events/kmem.h> |
56 | #include <linux/ftrace_event.h> | ||
57 | #include <linux/memcontrol.h> | ||
58 | #include <linux/prefetch.h> | 56 | #include <linux/prefetch.h> |
59 | #include <linux/mm_inline.h> | 57 | #include <linux/mm_inline.h> |
60 | #include <linux/migrate.h> | 58 | #include <linux/migrate.h> |
@@ -6550,161 +6548,3 @@ bool is_free_buddy_page(struct page *page) | |||
6550 | return order < MAX_ORDER; | 6548 | return order < MAX_ORDER; |
6551 | } | 6549 | } |
6552 | #endif | 6550 | #endif |
6553 | |||
6554 | static const struct trace_print_flags pageflag_names[] = { | ||
6555 | {1UL << PG_locked, "locked" }, | ||
6556 | {1UL << PG_error, "error" }, | ||
6557 | {1UL << PG_referenced, "referenced" }, | ||
6558 | {1UL << PG_uptodate, "uptodate" }, | ||
6559 | {1UL << PG_dirty, "dirty" }, | ||
6560 | {1UL << PG_lru, "lru" }, | ||
6561 | {1UL << PG_active, "active" }, | ||
6562 | {1UL << PG_slab, "slab" }, | ||
6563 | {1UL << PG_owner_priv_1, "owner_priv_1" }, | ||
6564 | {1UL << PG_arch_1, "arch_1" }, | ||
6565 | {1UL << PG_reserved, "reserved" }, | ||
6566 | {1UL << PG_private, "private" }, | ||
6567 | {1UL << PG_private_2, "private_2" }, | ||
6568 | {1UL << PG_writeback, "writeback" }, | ||
6569 | #ifdef CONFIG_PAGEFLAGS_EXTENDED | ||
6570 | {1UL << PG_head, "head" }, | ||
6571 | {1UL << PG_tail, "tail" }, | ||
6572 | #else | ||
6573 | {1UL << PG_compound, "compound" }, | ||
6574 | #endif | ||
6575 | {1UL << PG_swapcache, "swapcache" }, | ||
6576 | {1UL << PG_mappedtodisk, "mappedtodisk" }, | ||
6577 | {1UL << PG_reclaim, "reclaim" }, | ||
6578 | {1UL << PG_swapbacked, "swapbacked" }, | ||
6579 | {1UL << PG_unevictable, "unevictable" }, | ||
6580 | #ifdef CONFIG_MMU | ||
6581 | {1UL << PG_mlocked, "mlocked" }, | ||
6582 | #endif | ||
6583 | #ifdef CONFIG_ARCH_USES_PG_UNCACHED | ||
6584 | {1UL << PG_uncached, "uncached" }, | ||
6585 | #endif | ||
6586 | #ifdef CONFIG_MEMORY_FAILURE | ||
6587 | {1UL << PG_hwpoison, "hwpoison" }, | ||
6588 | #endif | ||
6589 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
6590 | {1UL << PG_compound_lock, "compound_lock" }, | ||
6591 | #endif | ||
6592 | }; | ||
6593 | |||
6594 | static void dump_flags(unsigned long flags, | ||
6595 | const struct trace_print_flags *names, int count) | ||
6596 | { | ||
6597 | const char *delim = ""; | ||
6598 | unsigned long mask; | ||
6599 | int i; | ||
6600 | |||
6601 | printk(KERN_ALERT "flags: %#lx(", flags); | ||
6602 | |||
6603 | /* remove zone id */ | ||
6604 | flags &= (1UL << NR_PAGEFLAGS) - 1; | ||
6605 | |||
6606 | for (i = 0; i < count && flags; i++) { | ||
6607 | |||
6608 | mask = names[i].mask; | ||
6609 | if ((flags & mask) != mask) | ||
6610 | continue; | ||
6611 | |||
6612 | flags &= ~mask; | ||
6613 | printk("%s%s", delim, names[i].name); | ||
6614 | delim = "|"; | ||
6615 | } | ||
6616 | |||
6617 | /* check for left over flags */ | ||
6618 | if (flags) | ||
6619 | printk("%s%#lx", delim, flags); | ||
6620 | |||
6621 | printk(")\n"); | ||
6622 | } | ||
6623 | |||
6624 | void dump_page_badflags(struct page *page, const char *reason, | ||
6625 | unsigned long badflags) | ||
6626 | { | ||
6627 | printk(KERN_ALERT | ||
6628 | "page:%p count:%d mapcount:%d mapping:%p index:%#lx\n", | ||
6629 | page, atomic_read(&page->_count), page_mapcount(page), | ||
6630 | page->mapping, page->index); | ||
6631 | BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS); | ||
6632 | dump_flags(page->flags, pageflag_names, ARRAY_SIZE(pageflag_names)); | ||
6633 | if (reason) | ||
6634 | pr_alert("page dumped because: %s\n", reason); | ||
6635 | if (page->flags & badflags) { | ||
6636 | pr_alert("bad because of flags:\n"); | ||
6637 | dump_flags(page->flags & badflags, | ||
6638 | pageflag_names, ARRAY_SIZE(pageflag_names)); | ||
6639 | } | ||
6640 | mem_cgroup_print_bad_page(page); | ||
6641 | } | ||
6642 | |||
6643 | void dump_page(struct page *page, const char *reason) | ||
6644 | { | ||
6645 | dump_page_badflags(page, reason, 0); | ||
6646 | } | ||
6647 | EXPORT_SYMBOL(dump_page); | ||
6648 | |||
6649 | #ifdef CONFIG_DEBUG_VM | ||
6650 | |||
6651 | static const struct trace_print_flags vmaflags_names[] = { | ||
6652 | {VM_READ, "read" }, | ||
6653 | {VM_WRITE, "write" }, | ||
6654 | {VM_EXEC, "exec" }, | ||
6655 | {VM_SHARED, "shared" }, | ||
6656 | {VM_MAYREAD, "mayread" }, | ||
6657 | {VM_MAYWRITE, "maywrite" }, | ||
6658 | {VM_MAYEXEC, "mayexec" }, | ||
6659 | {VM_MAYSHARE, "mayshare" }, | ||
6660 | {VM_GROWSDOWN, "growsdown" }, | ||
6661 | {VM_PFNMAP, "pfnmap" }, | ||
6662 | {VM_DENYWRITE, "denywrite" }, | ||
6663 | {VM_LOCKED, "locked" }, | ||
6664 | {VM_IO, "io" }, | ||
6665 | {VM_SEQ_READ, "seqread" }, | ||
6666 | {VM_RAND_READ, "randread" }, | ||
6667 | {VM_DONTCOPY, "dontcopy" }, | ||
6668 | {VM_DONTEXPAND, "dontexpand" }, | ||
6669 | {VM_ACCOUNT, "account" }, | ||
6670 | {VM_NORESERVE, "noreserve" }, | ||
6671 | {VM_HUGETLB, "hugetlb" }, | ||
6672 | {VM_NONLINEAR, "nonlinear" }, | ||
6673 | #if defined(CONFIG_X86) | ||
6674 | {VM_PAT, "pat" }, | ||
6675 | #elif defined(CONFIG_PPC) | ||
6676 | {VM_SAO, "sao" }, | ||
6677 | #elif defined(CONFIG_PARISC) || defined(CONFIG_METAG) || defined(CONFIG_IA64) | ||
6678 | {VM_GROWSUP, "growsup" }, | ||
6679 | #elif !defined(CONFIG_MMU) | ||
6680 | {VM_MAPPED_COPY, "mappedcopy" }, | ||
6681 | #else | ||
6682 | {VM_ARCH_1, "arch_1" }, | ||
6683 | #endif | ||
6684 | {VM_DONTDUMP, "dontdump" }, | ||
6685 | #ifdef CONFIG_MEM_SOFT_DIRTY | ||
6686 | {VM_SOFTDIRTY, "softdirty" }, | ||
6687 | #endif | ||
6688 | {VM_MIXEDMAP, "mixedmap" }, | ||
6689 | {VM_HUGEPAGE, "hugepage" }, | ||
6690 | {VM_NOHUGEPAGE, "nohugepage" }, | ||
6691 | {VM_MERGEABLE, "mergeable" }, | ||
6692 | }; | ||
6693 | |||
6694 | void dump_vma(const struct vm_area_struct *vma) | ||
6695 | { | ||
6696 | printk(KERN_ALERT | ||
6697 | "vma %p start %p end %p\n" | ||
6698 | "next %p prev %p mm %p\n" | ||
6699 | "prot %lx anon_vma %p vm_ops %p\n" | ||
6700 | "pgoff %lx file %p private_data %p\n", | ||
6701 | vma, (void *)vma->vm_start, (void *)vma->vm_end, vma->vm_next, | ||
6702 | vma->vm_prev, vma->vm_mm, | ||
6703 | (unsigned long)pgprot_val(vma->vm_page_prot), | ||
6704 | vma->anon_vma, vma->vm_ops, vma->vm_pgoff, | ||
6705 | vma->vm_file, vma->vm_private_data); | ||
6706 | dump_flags(vma->vm_flags, vmaflags_names, ARRAY_SIZE(vmaflags_names)); | ||
6707 | } | ||
6708 | EXPORT_SYMBOL(dump_vma); | ||
6709 | |||
6710 | #endif /* CONFIG_DEBUG_VM */ | ||