aboutsummaryrefslogtreecommitdiffstats
path: root/mm/debug.c
diff options
context:
space:
mode:
authorVlastimil Babka <vbabka@suse.cz>2016-03-15 17:55:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-15 19:55:16 -0400
commit420adbe9fc1a45187cfa74df9dbfd72272c4e2fa (patch)
tree5d8907a9a6b87441c65252da969575cd5cb21b8d /mm/debug.c
parent14e0a214d62d284ff40b1fd7d687cb66fca9fc67 (diff)
mm, tracing: unify mm flags handling in tracepoints and printk
In tracepoints, it's possible to print gfp flags in a human-friendly format through a macro show_gfp_flags(), which defines a translation array and passes is to __print_flags(). Since the following patch will introduce support for gfp flags printing in printk(), it would be nice to reuse the array. This is not straightforward, since __print_flags() can't simply reference an array defined in a .c file such as mm/debug.c - it has to be a macro to allow the macro magic to communicate the format to userspace tools such as trace-cmd. The solution is to create a macro __def_gfpflag_names which is used both in show_gfp_flags(), and to define the gfpflag_names[] array in mm/debug.c. On the other hand, mm/debug.c also defines translation tables for page flags and vma flags, and desire was expressed (but not implemented in this series) to use these also from tracepoints. Thus, this patch also renames the events/gfpflags.h file to events/mmflags.h and moves the table definitions there, using the same macro approach as for gfpflags. This allows translating all three kinds of mm-specific flags both in tracepoints and printk. Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Reviewed-by: Michal Hocko <mhocko@suse.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Sasha Levin <sasha.levin@oracle.com> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Mel Gorman <mgorman@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/debug.c')
-rw-r--r--mm/debug.c88
1 files changed, 11 insertions, 77 deletions
diff --git a/mm/debug.c b/mm/debug.c
index f05b2d5d6481..410af904a7d5 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -9,41 +9,14 @@
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/trace_events.h> 10#include <linux/trace_events.h>
11#include <linux/memcontrol.h> 11#include <linux/memcontrol.h>
12#include <trace/events/mmflags.h>
12 13
13static const struct trace_print_flags pageflag_names[] = { 14static const struct trace_print_flags pageflag_names[] = {
14 {1UL << PG_locked, "locked" }, 15 __def_pageflag_names
15 {1UL << PG_error, "error" }, 16};
16 {1UL << PG_referenced, "referenced" }, 17
17 {1UL << PG_uptodate, "uptodate" }, 18static const struct trace_print_flags gfpflag_names[] = {
18 {1UL << PG_dirty, "dirty" }, 19 __def_gfpflag_names
19 {1UL << PG_lru, "lru" },
20 {1UL << PG_active, "active" },
21 {1UL << PG_slab, "slab" },
22 {1UL << PG_owner_priv_1, "owner_priv_1" },
23 {1UL << PG_arch_1, "arch_1" },
24 {1UL << PG_reserved, "reserved" },
25 {1UL << PG_private, "private" },
26 {1UL << PG_private_2, "private_2" },
27 {1UL << PG_writeback, "writeback" },
28 {1UL << PG_head, "head" },
29 {1UL << PG_swapcache, "swapcache" },
30 {1UL << PG_mappedtodisk, "mappedtodisk" },
31 {1UL << PG_reclaim, "reclaim" },
32 {1UL << PG_swapbacked, "swapbacked" },
33 {1UL << PG_unevictable, "unevictable" },
34#ifdef CONFIG_MMU
35 {1UL << PG_mlocked, "mlocked" },
36#endif
37#ifdef CONFIG_ARCH_USES_PG_UNCACHED
38 {1UL << PG_uncached, "uncached" },
39#endif
40#ifdef CONFIG_MEMORY_FAILURE
41 {1UL << PG_hwpoison, "hwpoison" },
42#endif
43#if defined(CONFIG_IDLE_PAGE_TRACKING) && defined(CONFIG_64BIT)
44 {1UL << PG_young, "young" },
45 {1UL << PG_idle, "idle" },
46#endif
47}; 20};
48 21
49static void dump_flags(unsigned long flags, 22static void dump_flags(unsigned long flags,
@@ -108,47 +81,8 @@ EXPORT_SYMBOL(dump_page);
108 81
109#ifdef CONFIG_DEBUG_VM 82#ifdef CONFIG_DEBUG_VM
110 83
111static const struct trace_print_flags vmaflags_names[] = { 84static const struct trace_print_flags vmaflag_names[] = {
112 {VM_READ, "read" }, 85 __def_vmaflag_names
113 {VM_WRITE, "write" },
114 {VM_EXEC, "exec" },
115 {VM_SHARED, "shared" },
116 {VM_MAYREAD, "mayread" },
117 {VM_MAYWRITE, "maywrite" },
118 {VM_MAYEXEC, "mayexec" },
119 {VM_MAYSHARE, "mayshare" },
120 {VM_GROWSDOWN, "growsdown" },
121 {VM_PFNMAP, "pfnmap" },
122 {VM_DENYWRITE, "denywrite" },
123 {VM_LOCKONFAULT, "lockonfault" },
124 {VM_LOCKED, "locked" },
125 {VM_IO, "io" },
126 {VM_SEQ_READ, "seqread" },
127 {VM_RAND_READ, "randread" },
128 {VM_DONTCOPY, "dontcopy" },
129 {VM_DONTEXPAND, "dontexpand" },
130 {VM_ACCOUNT, "account" },
131 {VM_NORESERVE, "noreserve" },
132 {VM_HUGETLB, "hugetlb" },
133#if defined(CONFIG_X86)
134 {VM_PAT, "pat" },
135#elif defined(CONFIG_PPC)
136 {VM_SAO, "sao" },
137#elif defined(CONFIG_PARISC) || defined(CONFIG_METAG) || defined(CONFIG_IA64)
138 {VM_GROWSUP, "growsup" },
139#elif !defined(CONFIG_MMU)
140 {VM_MAPPED_COPY, "mappedcopy" },
141#else
142 {VM_ARCH_1, "arch_1" },
143#endif
144 {VM_DONTDUMP, "dontdump" },
145#ifdef CONFIG_MEM_SOFT_DIRTY
146 {VM_SOFTDIRTY, "softdirty" },
147#endif
148 {VM_MIXEDMAP, "mixedmap" },
149 {VM_HUGEPAGE, "hugepage" },
150 {VM_NOHUGEPAGE, "nohugepage" },
151 {VM_MERGEABLE, "mergeable" },
152}; 86};
153 87
154void dump_vma(const struct vm_area_struct *vma) 88void dump_vma(const struct vm_area_struct *vma)
@@ -162,7 +96,7 @@ void dump_vma(const struct vm_area_struct *vma)
162 (unsigned long)pgprot_val(vma->vm_page_prot), 96 (unsigned long)pgprot_val(vma->vm_page_prot),
163 vma->anon_vma, vma->vm_ops, vma->vm_pgoff, 97 vma->anon_vma, vma->vm_ops, vma->vm_pgoff,
164 vma->vm_file, vma->vm_private_data); 98 vma->vm_file, vma->vm_private_data);
165 dump_flags(vma->vm_flags, vmaflags_names, ARRAY_SIZE(vmaflags_names)); 99 dump_flags(vma->vm_flags, vmaflag_names, ARRAY_SIZE(vmaflag_names));
166} 100}
167EXPORT_SYMBOL(dump_vma); 101EXPORT_SYMBOL(dump_vma);
168 102
@@ -233,8 +167,8 @@ void dump_mm(const struct mm_struct *mm)
233 "" /* This is here to not have a comma! */ 167 "" /* This is here to not have a comma! */
234 ); 168 );
235 169
236 dump_flags(mm->def_flags, vmaflags_names, 170 dump_flags(mm->def_flags, vmaflag_names,
237 ARRAY_SIZE(vmaflags_names)); 171 ARRAY_SIZE(vmaflag_names));
238} 172}
239 173
240#endif /* CONFIG_DEBUG_VM */ 174#endif /* CONFIG_DEBUG_VM */