]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/proc/task_mmu.c
procfs: add VmFlags field in smaps output
[karo-tx-linux.git] / fs / proc / task_mmu.c
index 90c63f9392a595318c5d1e03e1d69305bf9413fa..1b1777a5fb54398c4951640101b55ce39edf87c2 100644 (file)
@@ -526,6 +526,56 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
        return 0;
 }
 
+static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
+{
+       /*
+        * Don't forget to update Documentation/ on changes.
+        */
+       static const char mnemonics[BITS_PER_LONG][2] = {
+               /*
+                * In case if we meet a flag we don't know about.
+                */
+               [0 ... (BITS_PER_LONG-1)] = { "??" },
+
+               [ilog2(VM_READ)]        = "rd",
+               [ilog2(VM_WRITE)]       = "wr",
+               [ilog2(VM_EXEC)]        = "ex",
+               [ilog2(VM_SHARED)]      = "sh",
+               [ilog2(VM_MAYREAD)]     = "mr",
+               [ilog2(VM_MAYWRITE)]    = "mw",
+               [ilog2(VM_MAYEXEC)]     = "me",
+               [ilog2(VM_MAYSHARE)]    = "ms",
+               [ilog2(VM_GROWSDOWN)]   = "gd",
+               [ilog2(VM_PFNMAP)]      = "pf",
+               [ilog2(VM_DENYWRITE)]   = "dw",
+               [ilog2(VM_LOCKED)]      = "lo",
+               [ilog2(VM_IO)]          = "io",
+               [ilog2(VM_SEQ_READ)]    = "sr",
+               [ilog2(VM_RAND_READ)]   = "rr",
+               [ilog2(VM_DONTCOPY)]    = "dc",
+               [ilog2(VM_DONTEXPAND)]  = "de",
+               [ilog2(VM_ACCOUNT)]     = "ac",
+               [ilog2(VM_NORESERVE)]   = "nr",
+               [ilog2(VM_HUGETLB)]     = "ht",
+               [ilog2(VM_NONLINEAR)]   = "nl",
+               [ilog2(VM_ARCH_1)]      = "ar",
+               [ilog2(VM_DONTDUMP)]    = "dd",
+               [ilog2(VM_MIXEDMAP)]    = "mm",
+               [ilog2(VM_HUGEPAGE)]    = "hg",
+               [ilog2(VM_NOHUGEPAGE)]  = "nh",
+               [ilog2(VM_MERGEABLE)]   = "mg",
+       };
+       size_t i;
+
+       seq_puts(m, "VmFlags: ");
+       for_each_set_bit(i, &vma->vm_flags, BITS_PER_LONG) {
+               seq_printf(m, "%c%c ",
+                          mnemonics[i][0],
+                          mnemonics[i][1]);
+       }
+       seq_putc(m, '\n');
+}
+
 static int show_smap(struct seq_file *m, void *v, int is_pid)
 {
        struct proc_maps_private *priv = m->private;
@@ -581,6 +631,8 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
                seq_printf(m, "Nonlinear:      %8lu kB\n",
                                mss.nonlinear >> 10);
 
+       show_smap_vma_flags(m, vma);
+
        if (m->count < m->size)  /* vma is copied successfully */
                m->version = (vma != get_gate_vma(task->mm))
                        ? vma->vm_start : 0;
@@ -643,7 +695,7 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,
        spinlock_t *ptl;
        struct page *page;
 
-       split_huge_page_pmd(walk->mm, pmd);
+       split_huge_page_pmd(vma, addr, pmd);
        if (pmd_trans_unstable(pmd))
                return 0;