~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/mm/debug.c

Version: ~ [ linux-5.18 ] ~ [ linux-5.17.9 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.41 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.117 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.195 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.244 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.280 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.315 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * mm/debug.c
  3  *
  4  * mm/ specific debug routines.
  5  *
  6  */
  7 
  8 #include <linux/kernel.h>
  9 #include <linux/mm.h>
 10 #include <linux/trace_events.h>
 11 #include <linux/memcontrol.h>
 12 
 13 static const struct trace_print_flags pageflag_names[] = {
 14         {1UL << PG_locked,              "locked"        },
 15         {1UL << PG_error,               "error"         },
 16         {1UL << PG_referenced,          "referenced"    },
 17         {1UL << PG_uptodate,            "uptodate"      },
 18         {1UL << PG_dirty,               "dirty"         },
 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 };
 48 
 49 static void dump_flags(unsigned long flags,
 50                         const struct trace_print_flags *names, int count)
 51 {
 52         const char *delim = "";
 53         unsigned long mask;
 54         int i;
 55 
 56         pr_emerg("flags: %#lx(", flags);
 57 
 58         /* remove zone id */
 59         flags &= (1UL << NR_PAGEFLAGS) - 1;
 60 
 61         for (i = 0; i < count && flags; i++) {
 62 
 63                 mask = names[i].mask;
 64                 if ((flags & mask) != mask)
 65                         continue;
 66 
 67                 flags &= ~mask;
 68                 pr_cont("%s%s", delim, names[i].name);
 69                 delim = "|";
 70         }
 71 
 72         /* check for left over flags */
 73         if (flags)
 74                 pr_cont("%s%#lx", delim, flags);
 75 
 76         pr_cont(")\n");
 77 }
 78 
 79 void dump_page_badflags(struct page *page, const char *reason,
 80                 unsigned long badflags)
 81 {
 82         pr_emerg("page:%p count:%d mapcount:%d mapping:%p index:%#lx",
 83                   page, atomic_read(&page->_count), page_mapcount(page),
 84                   page->mapping, page->index);
 85         if (PageCompound(page))
 86                 pr_cont(" compound_mapcount: %d", compound_mapcount(page));
 87         pr_cont("\n");
 88         BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS);
 89         dump_flags(page->flags, pageflag_names, ARRAY_SIZE(pageflag_names));
 90         if (reason)
 91                 pr_alert("page dumped because: %s\n", reason);
 92         if (page->flags & badflags) {
 93                 pr_alert("bad because of flags:\n");
 94                 dump_flags(page->flags & badflags,
 95                                 pageflag_names, ARRAY_SIZE(pageflag_names));
 96         }
 97 #ifdef CONFIG_MEMCG
 98         if (page->mem_cgroup)
 99                 pr_alert("page->mem_cgroup:%p\n", page->mem_cgroup);
100 #endif
101 }
102 
103 void dump_page(struct page *page, const char *reason)
104 {
105         dump_page_badflags(page, reason, 0);
106 }
107 EXPORT_SYMBOL(dump_page);
108 
109 #ifdef CONFIG_DEBUG_VM
110 
111 static const struct trace_print_flags vmaflags_names[] = {
112         {VM_READ,                       "read"          },
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 };
153 
154 void dump_vma(const struct vm_area_struct *vma)
155 {
156         pr_emerg("vma %p start %p end %p\n"
157                 "next %p prev %p mm %p\n"
158                 "prot %lx anon_vma %p vm_ops %p\n"
159                 "pgoff %lx file %p private_data %p\n",
160                 vma, (void *)vma->vm_start, (void *)vma->vm_end, vma->vm_next,
161                 vma->vm_prev, vma->vm_mm,
162                 (unsigned long)pgprot_val(vma->vm_page_prot),
163                 vma->anon_vma, vma->vm_ops, vma->vm_pgoff,
164                 vma->vm_file, vma->vm_private_data);
165         dump_flags(vma->vm_flags, vmaflags_names, ARRAY_SIZE(vmaflags_names));
166 }
167 EXPORT_SYMBOL(dump_vma);
168 
169 void dump_mm(const struct mm_struct *mm)
170 {
171         pr_emerg("mm %p mmap %p seqnum %d task_size %lu\n"
172 #ifdef CONFIG_MMU
173                 "get_unmapped_area %p\n"
174 #endif
175                 "mmap_base %lu mmap_legacy_base %lu highest_vm_end %lu\n"
176                 "pgd %p mm_users %d mm_count %d nr_ptes %lu nr_pmds %lu map_count %d\n"
177                 "hiwater_rss %lx hiwater_vm %lx total_vm %lx locked_vm %lx\n"
178                 "pinned_vm %lx data_vm %lx exec_vm %lx stack_vm %lx\n"
179                 "start_code %lx end_code %lx start_data %lx end_data %lx\n"
180                 "start_brk %lx brk %lx start_stack %lx\n"
181                 "arg_start %lx arg_end %lx env_start %lx env_end %lx\n"
182                 "binfmt %p flags %lx core_state %p\n"
183 #ifdef CONFIG_AIO
184                 "ioctx_table %p\n"
185 #endif
186 #ifdef CONFIG_MEMCG
187                 "owner %p "
188 #endif
189                 "exe_file %p\n"
190 #ifdef CONFIG_MMU_NOTIFIER
191                 "mmu_notifier_mm %p\n"
192 #endif
193 #ifdef CONFIG_NUMA_BALANCING
194                 "numa_next_scan %lu numa_scan_offset %lu numa_scan_seq %d\n"
195 #endif
196 #if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION)
197                 "tlb_flush_pending %d\n"
198 #endif
199                 "%s",   /* This is here to hold the comma */
200 
201                 mm, mm->mmap, mm->vmacache_seqnum, mm->task_size,
202 #ifdef CONFIG_MMU
203                 mm->get_unmapped_area,
204 #endif
205                 mm->mmap_base, mm->mmap_legacy_base, mm->highest_vm_end,
206                 mm->pgd, atomic_read(&mm->mm_users),
207                 atomic_read(&mm->mm_count),
208                 atomic_long_read((atomic_long_t *)&mm->nr_ptes),
209                 mm_nr_pmds((struct mm_struct *)mm),
210                 mm->map_count,
211                 mm->hiwater_rss, mm->hiwater_vm, mm->total_vm, mm->locked_vm,
212                 mm->pinned_vm, mm->data_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 
240 #endif          /* CONFIG_DEBUG_VM */
241 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp