From 8399d91bc1726000b3f3c6a0a46dcbb18809f5dc Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Thu, 7 May 2020 17:59:51 -0400 Subject: [PATCH] mm/mmap: Move maple tree logging to tracepoints Able to toggle at runtime? Count me in. Signed-off-by: Liam R. Howlett --- include/trace/events/mm.h | 108 ++++++++++++++++++++++++++++++++++++++ mm/mmap.c | 20 +------ 2 files changed, 110 insertions(+), 18 deletions(-) create mode 100644 include/trace/events/mm.h diff --git a/include/trace/events/mm.h b/include/trace/events/mm.h new file mode 100644 index 000000000000..739b71471797 --- /dev/null +++ b/include/trace/events/mm.h @@ -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 + +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 diff --git a/mm/mmap.c b/mm/mmap.c index 91d742bf154f..00938d556e83 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -57,6 +57,7 @@ #include #include "internal.h" +#include #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); @@ -2261,7 +2248,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); @@ -3591,9 +3578,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); } -- 2.50.1