mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH -next v3 2/2] mm: vmscan: add new event to trace shrink lru
       [not found] ` <20231214013450.5734-3-cuibixuan@vivo.com>
@ 2023-12-14  3:05   ` Huan Yang
  2023-12-14  3:59   ` Yu Zhao
  1 sibling, 0 replies; 3+ messages in thread
From: Huan Yang @ 2023-12-14  3:05 UTC (permalink / raw)
  To: linux-kernel, akpm, mm-commits, rostedt, mhiramat, mathieu.desnoyers
  Cc: opensource.kernel, cuibixuan


在 2023/12/14 9:34, Bixuan Cui 写道:
> [Some people who received this message don't often get email from cuibixuan@vivo.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> From: cuibixuan <cuibixuan@vivo.com>
>
> Add a new event to calculate the shrink_inactive_list()/shrink_active_list()
> execution time.
>
> Example of output:
>           kswapd0-103     [007] .....  1098.353020: mm_vmscan_lru_shrink_active_start: nid=0
>           kswapd0-103     [007] .....  1098.353040: mm_vmscan_lru_shrink_active_end: nid=0 nr_taken=32 nr_active=0 nr_deactivated=32 nr_referenced=0 priority=6 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC
>           kswapd0-103     [007] .....  1098.353040: mm_vmscan_lru_shrink_inactive_start: nid=0
>           kswapd0-103     [007] .....  1098.353094: mm_vmscan_lru_shrink_inactive_end: nid=0 nr_scanned=32 nr_reclaimed=0 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=32 nr_unmap_fail=0 priority=6 flags=RECLAIM_WB_ANON|RECLAIM_WB_ASYNC
>           kswapd0-103     [007] .....  1098.353094: mm_vmscan_lru_shrink_inactive_start: nid=0
>           kswapd0-103     [007] .....  1098.353162: mm_vmscan_lru_shrink_inactive_end: nid=0 nr_scanned=32 nr_reclaimed=21 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=11 nr_unmap_fail=0 priority=6 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC
>
> Signed-off-by: Bixuan Cui <cuibixuan@vivo.com>
> ---
>   include/trace/events/vmscan.h | 38 +++++++++++++++++++++++++++++++++--
>   mm/vmscan.c                   | 11 +++++++---
>   2 files changed, 44 insertions(+), 5 deletions(-)
>
> diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
> index b99cd28c9815..02868bdc5999 100644
> --- a/include/trace/events/vmscan.h
> +++ b/include/trace/events/vmscan.h
> @@ -395,7 +395,24 @@ TRACE_EVENT(mm_vmscan_write_folio,
>                  show_reclaim_flags(__entry->reclaim_flags))
>   );
>
> -TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
> +TRACE_EVENT(mm_vmscan_lru_shrink_inactive_start,
> +
> +       TP_PROTO(int nid),
> +
> +       TP_ARGS(nid),
> +
> +       TP_STRUCT__entry(
> +               __field(int, nid)
> +       ),
> +
> +       TP_fast_assign(
> +               __entry->nid = nid;
> +       ),
> +
> +       TP_printk("nid=%d", __entry->nid)
> +);
> +
> +TRACE_EVENT(mm_vmscan_lru_shrink_inactive_end,
>
>          TP_PROTO(int nid,
>                  unsigned long nr_scanned, unsigned long nr_reclaimed,
> @@ -446,7 +463,24 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
>                  show_reclaim_flags(__entry->reclaim_flags))
>   );
>
> -TRACE_EVENT(mm_vmscan_lru_shrink_active,
> +TRACE_EVENT(mm_vmscan_lru_shrink_active_start,
> +
> +       TP_PROTO(int nid),
> +
> +       TP_ARGS(nid),
> +
> +       TP_STRUCT__entry(
> +               __field(int, nid)
> +       ),
> +
> +       TP_fast_assign(
> +               __entry->nid = nid;
> +       ),
> +
> +       TP_printk("nid=%d", __entry->nid)
> +);
> +
> +TRACE_EVENT(mm_vmscan_lru_shrink_active_end,
>
>          TP_PROTO(int nid, unsigned long nr_taken,
>                  unsigned long nr_active, unsigned long nr_deactivated,
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 4e3b835c6b4a..a44d9624d60f 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1906,6 +1906,8 @@ static unsigned long shrink_inactive_list(unsigned long nr_to_scan,
>          struct pglist_data *pgdat = lruvec_pgdat(lruvec);
>          bool stalled = false;
>
> +       trace_mm_vmscan_lru_shrink_inactive_start(pgdat->node_id);

Can here add memcg id into shrink trace?

If so, we can attach this trace and collect shrink info into both NODE 
and each MEMCG.

> +
>          while (unlikely(too_many_isolated(pgdat, file, sc))) {
>                  if (stalled)
>                          return 0;
> @@ -1990,7 +1992,7 @@ static unsigned long shrink_inactive_list(unsigned long nr_to_scan,
>          if (file)
>                  sc->nr.file_taken += nr_taken;
>
> -       trace_mm_vmscan_lru_shrink_inactive(pgdat->node_id,
> +       trace_mm_vmscan_lru_shrink_inactive_end(pgdat->node_id,
>                          nr_scanned, nr_reclaimed, &stat, sc->priority, file);
>          return nr_reclaimed;
>   }
> @@ -2028,6 +2030,8 @@ static void shrink_active_list(unsigned long nr_to_scan,
>          int file = is_file_lru(lru);
>          struct pglist_data *pgdat = lruvec_pgdat(lruvec);
>
> +       trace_mm_vmscan_lru_shrink_active_start(pgdat->node_id);
> +
>          lru_add_drain();
>
>          spin_lock_irq(&lruvec->lru_lock);
> @@ -2107,7 +2111,7 @@ static void shrink_active_list(unsigned long nr_to_scan,
>                  lru_note_cost(lruvec, file, 0, nr_rotated);
>          mem_cgroup_uncharge_list(&l_active);
>          free_unref_page_list(&l_active);
> -       trace_mm_vmscan_lru_shrink_active(pgdat->node_id, nr_taken, nr_activate,
> +       trace_mm_vmscan_lru_shrink_active_end(pgdat->node_id, nr_taken, nr_activate,
>                          nr_deactivate, nr_rotated, sc->priority, file);
>   }
>
> @@ -4524,9 +4528,10 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap
>          if (list_empty(&list))
>                  return scanned;
>   retry:
> +       trace_mm_vmscan_lru_shrink_inactive_start(pgdat->node_id);
>          reclaimed = shrink_folio_list(&list, pgdat, sc, &stat, false);
>          sc->nr_reclaimed += reclaimed;
> -       trace_mm_vmscan_lru_shrink_inactive(pgdat->node_id,
> +       trace_mm_vmscan_lru_shrink_inactive_end(pgdat->node_id,
>                          scanned, reclaimed, &stat, sc->priority,
>                          type ? LRU_INACTIVE_FILE : LRU_INACTIVE_ANON);
>
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next v3 2/2] mm: vmscan: add new event to trace shrink lru
       [not found] ` <20231214013450.5734-3-cuibixuan@vivo.com>
  2023-12-14  3:05   ` [PATCH -next v3 2/2] mm: vmscan: add new event to trace shrink lru Huan Yang
@ 2023-12-14  3:59   ` Yu Zhao
  2023-12-15  1:06     ` Bixuan Cui
  1 sibling, 1 reply; 3+ messages in thread
From: Yu Zhao @ 2023-12-14  3:59 UTC (permalink / raw)
  To: cuibixuan
  Cc: akpm, mm-commits, rostedt, mhiramat, mathieu.desnoyers,
	opensource.kernel, Linux-MM, linux-kernel

On Wed, Dec 13, 2023 at 6:35 PM Bixuan Cui <cuibixuan@vivo.com> wrote:
>
> From: cuibixuan <cuibixuan@vivo.com>
>
> Add a new event to calculate the shrink_inactive_list()/shrink_active_list()
> execution time.
>
> Example of output:
>          kswapd0-103     [007] .....  1098.353020: mm_vmscan_lru_shrink_active_start: nid=0
>          kswapd0-103     [007] .....  1098.353040: mm_vmscan_lru_shrink_active_end: nid=0 nr_taken=32 nr_active=0 nr_deactivated=32 nr_referenced=0 priority=6 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC
>          kswapd0-103     [007] .....  1098.353040: mm_vmscan_lru_shrink_inactive_start: nid=0
>          kswapd0-103     [007] .....  1098.353094: mm_vmscan_lru_shrink_inactive_end: nid=0 nr_scanned=32 nr_reclaimed=0 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=32 nr_unmap_fail=0 priority=6 flags=RECLAIM_WB_ANON|RECLAIM_WB_ASYNC
>          kswapd0-103     [007] .....  1098.353094: mm_vmscan_lru_shrink_inactive_start: nid=0
>          kswapd0-103     [007] .....  1098.353162: mm_vmscan_lru_shrink_inactive_end: nid=0 nr_scanned=32 nr_reclaimed=21 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=11 nr_unmap_fail=0 priority=6 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC
>
> Signed-off-by: Bixuan Cui <cuibixuan@vivo.com>

NAK.

A _start should always be paired with an _end unless there is a good
reason not to.

mm-commits@ is the wrong mailing list to submit MM patches.

Is the build error Andrew pointed out earlier fixed? If so, where is
it credited to him?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next v3 2/2] mm: vmscan: add new event to trace shrink lru
  2023-12-14  3:59   ` Yu Zhao
@ 2023-12-15  1:06     ` Bixuan Cui
  0 siblings, 0 replies; 3+ messages in thread
From: Bixuan Cui @ 2023-12-15  1:06 UTC (permalink / raw)
  To: Yu Zhao
  Cc: akpm, mm-commits, rostedt, mhiramat, mathieu.desnoyers,
	opensource.kernel, Linux-MM, linux-kernel



在 2023/12/14 11:59, Yu Zhao 写道:
>> Example of output:
>>           kswapd0-103     [007] .....  1098.353020: mm_vmscan_lru_shrink_active_start: nid=0
>>           kswapd0-103     [007] .....  1098.353040: mm_vmscan_lru_shrink_active_end: nid=0 nr_taken=32 nr_active=0 nr_deactivated=32 nr_referenced=0 priority=6 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC
>>           kswapd0-103     [007] .....  1098.353040: mm_vmscan_lru_shrink_inactive_start: nid=0
>>           kswapd0-103     [007] .....  1098.353094: mm_vmscan_lru_shrink_inactive_end: nid=0 nr_scanned=32 nr_reclaimed=0 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=32 nr_unmap_fail=0 priority=6 flags=RECLAIM_WB_ANON|RECLAIM_WB_ASYNC
>>           kswapd0-103     [007] .....  1098.353094: mm_vmscan_lru_shrink_inactive_start: nid=0
>>           kswapd0-103     [007] .....  1098.353162: mm_vmscan_lru_shrink_inactive_end: nid=0 nr_scanned=32 nr_reclaimed=21 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=11 nr_unmap_fail=0 priority=6 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC
>>
>> Signed-off-by: Bixuan Cui<cuibixuan@vivo.com>
> NAK.
> 
> A _start should always be paired with an _end unless there is a good
> reason not to.
Yes, I want to get the duration of shrink lru and slab (including 
shrink_active_list()/shrink_inactive_list()/shrinker->count_objects()/shrinker->scan_objects()),and 
then calculate the memory recycling rate.

> 
> mm-commits@ is the wrong mailing list to submit MM patches.
Thanks for reminding.

> 
> Is the build error Andrew pointed out earlier fixed? If so, where is
> it credited to him?
Build error has been fixed in v2 patch, changes log:
v3: Swap the positions of 'nid' and 'freeable' to prevent the hole in 
the trace event.
v2: Modify trace_mm_vmscan_lru_shrink_inactive() in evict_folios() at 
the same time.

Thanks
Bixuan Cui



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-15  1:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20231214013450.5734-1-cuibixuan@vivo.com>
     [not found] ` <20231214013450.5734-3-cuibixuan@vivo.com>
2023-12-14  3:05   ` [PATCH -next v3 2/2] mm: vmscan: add new event to trace shrink lru Huan Yang
2023-12-14  3:59   ` Yu Zhao
2023-12-15  1:06     ` Bixuan Cui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®