]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mmap: Move maple tree logging to tracepoints
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 7 May 2020 21:59:51 +0000 (17:59 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:04:45 +0000 (15:04 -0400)
Able to toggle at runtime? Count me in.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
include/trace/events/mm.h [new file with mode: 0644]
mm/mmap.c

diff --git a/include/trace/events/mm.h b/include/trace/events/mm.h
new file mode 100644 (file)
index 0000000..739b714
--- /dev/null
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM mm
+
+#if !defined(_TRACE_MM_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_MM_H
+
+
+#include <linux/tracepoint.h>
+
+struct mm_struct;
+struct vm_area_struct;
+
+TRACE_EVENT(__vma_mt_erase,
+       TP_PROTO(struct mm_struct *mm, struct vm_area_struct *vma),
+
+       TP_ARGS(mm, vma),
+
+       TP_STRUCT__entry(
+                       __field( struct mm_struct, mm)
+                       __field( struct vma_area_struct vma)
+       ),
+
+       TP_fast_assign(
+                       __entry->mm             = mm;
+                       __entry->vma            = vma;
+                       __entry->vm_start       = vma->vm_start;
+                       __entry->vm_end         = vma->vm_end;
+       ),
+
+       TP_printk("mt_mod %p, (%p), ERASE, %lu, %lu\n",
+                 __entry->mm, __entry->vma,
+                 (unsigned long) __entry->vm_start,
+                 (unsigned long) __entry->vm_end - 1
+       )
+);
+
+TRACE_EVENT(__vma_mt_szero,
+       TP_PROTO(struct mm_struct *mm, struct vm_area_struct *vma),
+
+       TP_ARGS(mm, vma),
+
+       TP_STRUCT__entry(
+                       __field( struct mm_struct, mm)
+                       __field( struct vma_area_struct vma)
+       ),
+
+       TP_fast_assign(
+                       __entry->mm             = mm;
+                       __entry->vma            = vma;
+                       __entry->vm_start       = vma->vm_start;
+                       __entry->vm_end         = vma->vm_end;
+       ),
+
+       TP_printk("mt_mod %p, (%p), SNULL, %lu, %lu\n",
+                 __entry->mm, __entry->vma,
+                 (unsigned long) __entry->vm_start,
+                 (unsigned long) __entry->vm_end
+       )
+);
+
+TRACE_EVENT(__vma_mt_store,
+       TP_PROTO(struct mm_struct *mm, struct vm_area_struct *vma),
+
+       TP_ARGS(mm, vma),
+
+       TP_STRUCT__entry(
+                       __field( struct mm_struct, mm)
+                       __field( struct vma_area_struct vma)
+       ),
+
+       TP_fast_assign(
+                       __entry->mm             = mm;
+                       __entry->vma            = vma;
+                       __entry->vm_start       = vma->vm_start;
+                       __entry->vm_end         = vma->vm_end;
+       ),
+
+       TP_printk("mt_mod %p, (%p), STORE, %lu, %lu\n",
+                 __entry->mm, __entry->vma,
+                 (unsigned long) __entry->vm_start,
+                 (unsigned long) __entry->vm_end - 1
+       )
+);
+
+
+TRACE_EVENT(exit_mmap,
+       TP_PROTO(struct mm_struct *mm),
+
+       TP_ARGS(mm),
+
+       TP_STRUCT__entry(
+                       __field( struct mm_struct, mm)
+       ),
+
+       TP_fast_assign(
+                       __entry->mm             = mm;
+       ),
+
+       TP_printk("mt_mod %p, DESTROY\n",
+                 __entry->mm
+       )
+);
+
+#endif /* _TRACE_MM_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
index 942b9b12a29a4259e2818185ba2b27e0fee1b242..cf15423b1f4cf9e88ef6e53d2395995e43b1aa75 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -57,6 +57,7 @@
 #include <trace/events/mmap.h>
 
 #include "internal.h"
+#include <trace/events/mm.h>
 #define CONFIG_DEBUG_MAPLE_TREE
 #define CONFIG_DEBUG_VM_RB 1
 extern void mt_validate(struct maple_tree *mt);
@@ -413,7 +414,6 @@ static void validate_mm_mt(struct mm_struct *mm,
 {
        struct maple_tree *mt = &mm->mm_mt;
        struct vm_area_struct *vma_mt, *vma = mm->mmap;
-       unsigned long count = 0;
 
        MA_STATE(mas, mt, 0, 0);
        rcu_read_lock();
@@ -820,31 +820,18 @@ static void __vma_link_file(struct vm_area_struct *vma)
                flush_dcache_mmap_unlock(mapping);
        }
 }
-#define MT_DEBUG 0
 static void __vma_mt_erase(struct mm_struct *mm, struct vm_area_struct *vma)
 {
-#if MT_DEBUG
-       printk("%s: mt_mod %px (%px): ERASE, %lu, %lu,\n", __func__, mm, vma,
-                       vma->vm_start, vma->vm_end - 1);
-#endif
        mtree_erase(&mm->mm_mt, vma->vm_start);
        mt_validate(&mm->mm_mt);
 }
 static void __vma_mt_szero(struct mm_struct *mm, unsigned long start,
                unsigned long end)
 {
-#if MT_DEBUG
-       printk("%s: mt_mod %px (%px): SNULL, %lu, %lu,\n", __func__, mm, NULL,
-                       start, end - 1);
-#endif
        mtree_store_range(&mm->mm_mt, start, end - 1, NULL, GFP_KERNEL);
 }
 static void __vma_mt_store(struct mm_struct *mm, struct vm_area_struct *vma)
 {
-#if MT_DEBUG
-       printk("%s: mt_mod %px (%px): STORE, %lu, %lu,\n", __func__, mm, vma,
-                       vma->vm_start, vma->vm_end - 1);
-#endif
        mtree_store_range(&mm->mm_mt, vma->vm_start, vma->vm_end - 1, vma,
                GFP_KERNEL);
        mt_validate(&mm->mm_mt);
@@ -2263,7 +2250,7 @@ found:
 static unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
 {
        struct mm_struct *mm = current->mm;
-       struct vm_area_struct *vma;
+       struct vm_area_struct *vma = NULL;
        unsigned long length, low_limit, high_limit, gap_start, gap_end;
        unsigned long gap;
        MA_STATE(mas, &mm->mm_mt, 0, 0);
@@ -3593,9 +3580,6 @@ void exit_mmap(struct mm_struct *mm)
                vma = remove_vma(vma);
                cond_resched();
        }
-#if MT_DEBUG
-       printk("mt_mod: %px DESTROY\n", mm);
-#endif
        mtree_destroy(&mm->mm_mt);
        vm_unacct_memory(nr_accounted);
 }