Skip to content

Commit eae5270

Browse files
Gautam-Menghaniakpm00
authored andcommitted
mm/khugepaged: add tracepoint to collapse_file()
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/20221024173559.332324-1-gautammenghani201@gmail.com Signed-off-by: Gautam Menghani <gautammenghani201@gmail.com> Cc: David Hildenbrand <david@redhat.com> Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org> Cc: Steven Rostedt (Google) <rostedt@goodmis.org> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Yang Shi <shy828301@gmail.com> Cc: Zach O'Keefe <zokeefe@google.com> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 42b72a0 commit eae5270

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

Diff for: include/trace/events/huge_memory.h

+38
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,43 @@ TRACE_EVENT(mm_khugepaged_scan_file,
203203
__print_symbolic(__entry->result, SCAN_STATUS))
204204
);
205205

206+
TRACE_EVENT(mm_khugepaged_collapse_file,
207+
TP_PROTO(struct mm_struct *mm, struct page *hpage, pgoff_t index,
208+
bool is_shmem, unsigned long addr, struct file *file,
209+
int nr, int result),
210+
TP_ARGS(mm, hpage, index, is_shmem, addr, file, nr, result),
211+
TP_STRUCT__entry(
212+
__field(struct mm_struct *, mm)
213+
__field(unsigned long, hpfn)
214+
__field(pgoff_t, index)
215+
__field(bool, is_shmem)
216+
__field(unsigned long, addr)
217+
__string(filename, file->f_path.dentry->d_iname)
218+
__field(int, nr)
219+
__field(int, result)
220+
),
221+
222+
TP_fast_assign(
223+
__entry->mm = mm;
224+
__entry->hpfn = hpage ? page_to_pfn(hpage) : -1;
225+
__entry->index = index;
226+
__entry->is_shmem = is_shmem;
227+
__entry->addr = addr;
228+
__assign_str(filename, file->f_path.dentry->d_iname);
229+
__entry->nr = nr;
230+
__entry->result = result;
231+
),
232+
233+
TP_printk("mm=%p, hpage_pfn=0x%lx, index=%ld, is_shmem=%d, addr=%ld, filename=%s, nr=%d, result=%s",
234+
__entry->mm,
235+
__entry->hpfn,
236+
__entry->index,
237+
__entry->is_shmem,
238+
__entry->addr,
239+
__get_str(filename),
240+
__entry->nr,
241+
__print_symbolic(__entry->result, SCAN_STATUS))
242+
);
243+
206244
#endif /* __HUGE_MEMORY_H */
207245
#include <trace/define_trace.h>

Diff for: mm/khugepaged.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,9 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
20592059
mem_cgroup_uncharge(page_folio(hpage));
20602060
put_page(hpage);
20612061
}
2062-
/* TODO: tracepoints */
2062+
2063+
trace_mm_khugepaged_collapse_file(mm, hpage, index, is_shmem,
2064+
addr, file, nr, result);
20632065
return result;
20642066
}
20652067

0 commit comments

Comments
 (0)