diff mbox series

[mm-unstable,v3,04/10] mm/khugepaged: add tracepoint to hpage_collapse_scan_file()

Message ID 20220907144521.3115321-5-zokeefe@google.com (mailing list archive)
State New
Headers show
Series mm: add file/shmem support to MADV_COLLAPSE | expand

Commit Message

Zach O'Keefe Sept. 7, 2022, 2:45 p.m. UTC
Add huge_memory:trace_mm_khugepaged_scan_file tracepoint to
hpage_collapse_scan_file() analogously to hpage_collapse_scan_pmd().
While this change is targeted at debugging MADV_COLLAPSE pathway, the
"mm_khugepaged" prefix is retained for symmetry with
huge_memory:trace_mm_khugepaged_scan_pmd, which retains it's legacy name
to prevent changing kernel ABI as much as possible.

Signed-off-by: Zach O'Keefe <zokeefe@google.com>
---
 include/trace/events/huge_memory.h | 34 ++++++++++++++++++++++++++++++
 mm/khugepaged.c                    |  3 ++-
 2 files changed, 36 insertions(+), 1 deletion(-)

Comments

Yang Shi Sept. 16, 2022, 8:41 p.m. UTC | #1
On Wed, Sep 7, 2022 at 7:45 AM Zach O'Keefe <zokeefe@google.com> wrote:
>
> Add huge_memory:trace_mm_khugepaged_scan_file tracepoint to
> hpage_collapse_scan_file() analogously to hpage_collapse_scan_pmd().
> While this change is targeted at debugging MADV_COLLAPSE pathway, the
> "mm_khugepaged" prefix is retained for symmetry with
> huge_memory:trace_mm_khugepaged_scan_pmd, which retains it's legacy name
> to prevent changing kernel ABI as much as possible.
>
> Signed-off-by: Zach O'Keefe <zokeefe@google.com>

Reviewed-by: Yang Shi <shy828301@gmail.com>

> ---
>  include/trace/events/huge_memory.h | 34 ++++++++++++++++++++++++++++++
>  mm/khugepaged.c                    |  3 ++-
>  2 files changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/include/trace/events/huge_memory.h b/include/trace/events/huge_memory.h
> index df33453b70fc..935af4947917 100644
> --- a/include/trace/events/huge_memory.h
> +++ b/include/trace/events/huge_memory.h
> @@ -169,5 +169,39 @@ TRACE_EVENT(mm_collapse_huge_page_swapin,
>                 __entry->ret)
>  );
>
> +TRACE_EVENT(mm_khugepaged_scan_file,
> +
> +       TP_PROTO(struct mm_struct *mm, struct page *page, const char *filename,
> +                int present, int swap, int result),
> +
> +       TP_ARGS(mm, page, filename, present, swap, result),
> +
> +       TP_STRUCT__entry(
> +               __field(struct mm_struct *, mm)
> +               __field(unsigned long, pfn)
> +               __string(filename, filename)
> +               __field(int, present)
> +               __field(int, swap)
> +               __field(int, result)
> +       ),
> +
> +       TP_fast_assign(
> +               __entry->mm = mm;
> +               __entry->pfn = page ? page_to_pfn(page) : -1;
> +               __assign_str(filename, filename);
> +               __entry->present = present;
> +               __entry->swap = swap;
> +               __entry->result = result;
> +       ),
> +
> +       TP_printk("mm=%p, scan_pfn=0x%lx, filename=%s, present=%d, swap=%d, result=%s",
> +               __entry->mm,
> +               __entry->pfn,
> +               __get_str(filename),
> +               __entry->present,
> +               __entry->swap,
> +               __print_symbolic(__entry->result, SCAN_STATUS))
> +);
> +
>  #endif /* __HUGE_MEMORY_H */
>  #include <trace/define_trace.h>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 66457a06b4e7..9325aec25abc 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2152,7 +2152,8 @@ static int hpage_collapse_scan_file(struct mm_struct *mm, unsigned long addr,
>                 }
>         }
>
> -       /* TODO: tracepoints */
> +       trace_mm_khugepaged_scan_file(mm, page, file->f_path.dentry->d_iname,
> +                                     present, swap, result);
>         return result;
>  }
>  #else
> --
> 2.37.2.789.g6183377224-goog
>
Zach O'Keefe Sept. 16, 2022, 11:05 p.m. UTC | #2
On Sep 16 13:41, Yang Shi wrote:
> On Wed, Sep 7, 2022 at 7:45 AM Zach O'Keefe <zokeefe@google.com> wrote:
> >
> > Add huge_memory:trace_mm_khugepaged_scan_file tracepoint to
> > hpage_collapse_scan_file() analogously to hpage_collapse_scan_pmd().
> > While this change is targeted at debugging MADV_COLLAPSE pathway, the
> > "mm_khugepaged" prefix is retained for symmetry with
> > huge_memory:trace_mm_khugepaged_scan_pmd, which retains it's legacy name
> > to prevent changing kernel ABI as much as possible.
> >
> > Signed-off-by: Zach O'Keefe <zokeefe@google.com>
> 
> Reviewed-by: Yang Shi <shy828301@gmail.com>
> 

Thanks, as always!

> > ---
> >  include/trace/events/huge_memory.h | 34 ++++++++++++++++++++++++++++++
> >  mm/khugepaged.c                    |  3 ++-
> >  2 files changed, 36 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/trace/events/huge_memory.h b/include/trace/events/huge_memory.h
> > index df33453b70fc..935af4947917 100644
> > --- a/include/trace/events/huge_memory.h
> > +++ b/include/trace/events/huge_memory.h
> > @@ -169,5 +169,39 @@ TRACE_EVENT(mm_collapse_huge_page_swapin,
> >                 __entry->ret)
> >  );
> >
> > +TRACE_EVENT(mm_khugepaged_scan_file,
> > +
> > +       TP_PROTO(struct mm_struct *mm, struct page *page, const char *filename,
> > +                int present, int swap, int result),
> > +
> > +       TP_ARGS(mm, page, filename, present, swap, result),
> > +
> > +       TP_STRUCT__entry(
> > +               __field(struct mm_struct *, mm)
> > +               __field(unsigned long, pfn)
> > +               __string(filename, filename)
> > +               __field(int, present)
> > +               __field(int, swap)
> > +               __field(int, result)
> > +       ),
> > +
> > +       TP_fast_assign(
> > +               __entry->mm = mm;
> > +               __entry->pfn = page ? page_to_pfn(page) : -1;
> > +               __assign_str(filename, filename);
> > +               __entry->present = present;
> > +               __entry->swap = swap;
> > +               __entry->result = result;
> > +       ),
> > +
> > +       TP_printk("mm=%p, scan_pfn=0x%lx, filename=%s, present=%d, swap=%d, result=%s",
> > +               __entry->mm,
> > +               __entry->pfn,
> > +               __get_str(filename),
> > +               __entry->present,
> > +               __entry->swap,
> > +               __print_symbolic(__entry->result, SCAN_STATUS))
> > +);
> > +
> >  #endif /* __HUGE_MEMORY_H */
> >  #include <trace/define_trace.h>
> > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> > index 66457a06b4e7..9325aec25abc 100644
> > --- a/mm/khugepaged.c
> > +++ b/mm/khugepaged.c
> > @@ -2152,7 +2152,8 @@ static int hpage_collapse_scan_file(struct mm_struct *mm, unsigned long addr,
> >                 }
> >         }
> >
> > -       /* TODO: tracepoints */
> > +       trace_mm_khugepaged_scan_file(mm, page, file->f_path.dentry->d_iname,
> > +                                     present, swap, result);
> >         return result;
> >  }
> >  #else
> > --
> > 2.37.2.789.g6183377224-goog
> >
diff mbox series

Patch

diff --git a/include/trace/events/huge_memory.h b/include/trace/events/huge_memory.h
index df33453b70fc..935af4947917 100644
--- a/include/trace/events/huge_memory.h
+++ b/include/trace/events/huge_memory.h
@@ -169,5 +169,39 @@  TRACE_EVENT(mm_collapse_huge_page_swapin,
 		__entry->ret)
 );
 
+TRACE_EVENT(mm_khugepaged_scan_file,
+
+	TP_PROTO(struct mm_struct *mm, struct page *page, const char *filename,
+		 int present, int swap, int result),
+
+	TP_ARGS(mm, page, filename, present, swap, result),
+
+	TP_STRUCT__entry(
+		__field(struct mm_struct *, mm)
+		__field(unsigned long, pfn)
+		__string(filename, filename)
+		__field(int, present)
+		__field(int, swap)
+		__field(int, result)
+	),
+
+	TP_fast_assign(
+		__entry->mm = mm;
+		__entry->pfn = page ? page_to_pfn(page) : -1;
+		__assign_str(filename, filename);
+		__entry->present = present;
+		__entry->swap = swap;
+		__entry->result = result;
+	),
+
+	TP_printk("mm=%p, scan_pfn=0x%lx, filename=%s, present=%d, swap=%d, result=%s",
+		__entry->mm,
+		__entry->pfn,
+		__get_str(filename),
+		__entry->present,
+		__entry->swap,
+		__print_symbolic(__entry->result, SCAN_STATUS))
+);
+
 #endif /* __HUGE_MEMORY_H */
 #include <trace/define_trace.h>
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 66457a06b4e7..9325aec25abc 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2152,7 +2152,8 @@  static int hpage_collapse_scan_file(struct mm_struct *mm, unsigned long addr,
 		}
 	}
 
-	/* TODO: tracepoints */
+	trace_mm_khugepaged_scan_file(mm, page, file->f_path.dentry->d_iname,
+				      present, swap, result);
 	return result;
 }
 #else