The patch titled Subject: mm/vmstat: add event for ksm swapping in copy has been added to the -mm tree. Its filename is mm-vmstat-add-event-for-ksm-swapping-in-copy.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-vmstat-add-event-for-ksm-swapping-in-copy.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-vmstat-add-event-for-ksm-swapping-in-copy.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Yang Yang <yang.yang29@xxxxxxxxxx> Subject: mm/vmstat: add event for ksm swapping in copy When faults in from swap what used to be a KSM page and that page had been swapped in before, system has to make a copy, and leaves remerging the pages to a later pass of ksmd. That is not good for performace, we'd better to reduce this kind of copy. There are some ways to reduce it, for example lessen swappiness or madvise(, , MADV_MERGEABLE) range. So add this event to support doing this tuning. Just like this patch: "mm, THP, swap: add THP swapping out fallback counting". Link: https://lkml.kernel.org/r/20220113023839.758845-1-yang.yang29@xxxxxxxxxx Signed-off-by: Yang Yang <yang.yang29@xxxxxxxxxx> Reviewed-by: Ran Xiaokai <ran.xiaokai@xxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Yang Shi <yang.shi@xxxxxxxxxxxxxxxxx> Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> Cc: Saravanan D <saravanand@xxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/vm_event_item.h | 3 +++ mm/ksm.c | 3 +++ mm/vmstat.c | 3 +++ 3 files changed, 9 insertions(+) --- a/include/linux/vm_event_item.h~mm-vmstat-add-event-for-ksm-swapping-in-copy +++ a/include/linux/vm_event_item.h @@ -129,6 +129,9 @@ enum vm_event_item { PGPGIN, PGPGOUT, PS #ifdef CONFIG_SWAP SWAP_RA, SWAP_RA_HIT, +#ifdef CONFIG_KSM + KSM_SWPIN_COPY, +#endif #endif #ifdef CONFIG_X86 DIRECT_MAP_LEVEL2_SPLIT, --- a/mm/ksm.c~mm-vmstat-add-event-for-ksm-swapping-in-copy +++ a/mm/ksm.c @@ -2595,6 +2595,9 @@ struct page *ksm_might_need_to_copy(stru SetPageDirty(new_page); __SetPageUptodate(new_page); __SetPageLocked(new_page); +#ifdef CONFIG_SWAP + count_vm_event(KSM_SWPIN_COPY); +#endif } return new_page; --- a/mm/vmstat.c~mm-vmstat-add-event-for-ksm-swapping-in-copy +++ a/mm/vmstat.c @@ -1385,6 +1385,9 @@ const char * const vmstat_text[] = { #ifdef CONFIG_SWAP "swap_ra", "swap_ra_hit", +#ifdef CONFIG_KSM + "ksm_swpin_copy", +#endif #endif #ifdef CONFIG_X86 "direct_map_level2_splits", _ Patches currently in -mm which might be from yang.yang29@xxxxxxxxxx are mm-vmstat-add-event-for-ksm-swapping-in-copy.patch