Skip to content

Commit

Permalink
mm/khugepaged: add tracepoint to collapse_file()
Browse files Browse the repository at this point in the history
In mm/khugepaged.c, a TODO in the function collapse_file() asks to add
tracepoints.  Add the tracepoint named "mm_khugepaged_collapse_file".

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Gautam Menghani <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Masami Hiramatsu (Google) <[email protected]>
Cc: Steven Rostedt (Google) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Yang Shi <[email protected]>
Cc: Zach O'Keefe <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Gautam-Menghani authored and akpm00 committed Oct 25, 2022
1 parent 42b72a0 commit eae5270
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
38 changes: 38 additions & 0 deletions include/trace/events/huge_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,43 @@ TRACE_EVENT(mm_khugepaged_scan_file,
__print_symbolic(__entry->result, SCAN_STATUS))
);

TRACE_EVENT(mm_khugepaged_collapse_file,
TP_PROTO(struct mm_struct *mm, struct page *hpage, pgoff_t index,
bool is_shmem, unsigned long addr, struct file *file,
int nr, int result),
TP_ARGS(mm, hpage, index, is_shmem, addr, file, nr, result),
TP_STRUCT__entry(
__field(struct mm_struct *, mm)
__field(unsigned long, hpfn)
__field(pgoff_t, index)
__field(bool, is_shmem)
__field(unsigned long, addr)
__string(filename, file->f_path.dentry->d_iname)
__field(int, nr)
__field(int, result)
),

TP_fast_assign(
__entry->mm = mm;
__entry->hpfn = hpage ? page_to_pfn(hpage) : -1;
__entry->index = index;
__entry->is_shmem = is_shmem;
__entry->addr = addr;
__assign_str(filename, file->f_path.dentry->d_iname);
__entry->nr = nr;
__entry->result = result;
),

TP_printk("mm=%p, hpage_pfn=0x%lx, index=%ld, is_shmem=%d, addr=%ld, filename=%s, nr=%d, result=%s",
__entry->mm,
__entry->hpfn,
__entry->index,
__entry->is_shmem,
__entry->addr,
__get_str(filename),
__entry->nr,
__print_symbolic(__entry->result, SCAN_STATUS))
);

#endif /* __HUGE_MEMORY_H */
#include <trace/define_trace.h>
4 changes: 3 additions & 1 deletion mm/khugepaged.c
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,9 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
mem_cgroup_uncharge(page_folio(hpage));
put_page(hpage);
}
/* TODO: tracepoints */

trace_mm_khugepaged_collapse_file(mm, hpage, index, is_shmem,
addr, file, nr, result);
return result;
}

Expand Down

0 comments on commit eae5270

Please sign in to comment.