* [PATCH] mm/vmstat: add event for ksm swapping in copy
@ 2022-01-12 11:51 cgel.zte
2022-01-12 15:58 ` kernel test robot
0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-01-12 11:51 UTC (permalink / raw)
To: akpm, yang.shi, ying.huang
Cc: dave.hansen, yang.yang29, saravanand, minchan, linux-kernel,
linux-mm, Ran Xiaokai
From: Yang Yang <yang.yang29@zte.com.cn>
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".
Signed-off-by: Yang Yang <yang.yang29@zte.com.cn>
Reviewed-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
---
include/linux/vm_event_item.h | 3 +++
mm/ksm.c | 1 +
mm/vmstat.c | 3 +++
3 files changed, 7 insertions(+)
diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index 7b2363388bfa..16a0a4fd000b 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -129,6 +129,9 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
#ifdef CONFIG_SWAP
SWAP_RA,
SWAP_RA_HIT,
+#ifdef CONFIG_KSM
+ KSM_SWPIN_COPY,
+#endif
#endif
#ifdef CONFIG_X86
DIRECT_MAP_LEVEL2_SPLIT,
diff --git a/mm/ksm.c b/mm/ksm.c
index c20bd4d9a0d9..b6b382fde3d4 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -2595,6 +2595,7 @@ struct page *ksm_might_need_to_copy(struct page *page,
SetPageDirty(new_page);
__SetPageUptodate(new_page);
__SetPageLocked(new_page);
+ count_vm_event(KSM_SWPIN_COPY);
}
return new_page;
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 4057372745d0..d2b9f27eb1c4 100644
--- a/mm/vmstat.c
+++ b/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",
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/vmstat: add event for ksm swapping in copy
2022-01-12 11:51 [PATCH] mm/vmstat: add event for ksm swapping in copy cgel.zte
@ 2022-01-12 15:58 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2022-01-12 15:58 UTC (permalink / raw)
To: cgel.zte, akpm, yang.shi, ying.huang
Cc: kbuild-all, dave.hansen, yang.yang29, saravanand, minchan,
linux-kernel, linux-mm, Ran Xiaokai
Hi,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on hnaz-mm/master]
url: https://github.com/0day-ci/linux/commits/cgel-zte-gmail-com/mm-vmstat-add-event-for-ksm-swapping-in-copy/20220112-195303
base: https://github.com/hnaz/linux-mm master
config: alpha-buildonly-randconfig-r004-20220112 (https://download.01.org/0day-ci/archive/20220112/202201122306.EC6LSwot-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/56a4520e557228d8383f27b6aef54b2f931a0588
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review cgel-zte-gmail-com/mm-vmstat-add-event-for-ksm-swapping-in-copy/20220112-195303
git checkout 56a4520e557228d8383f27b6aef54b2f931a0588
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
mm/ksm.c: In function 'ksm_might_need_to_copy':
>> mm/ksm.c:2597:32: error: 'KSM_SWPIN_COPY' undeclared (first use in this function)
2597 | count_vm_event(KSM_SWPIN_COPY);
| ^~~~~~~~~~~~~~
mm/ksm.c:2597:32: note: each undeclared identifier is reported only once for each function it appears in
vim +/KSM_SWPIN_COPY +2597 mm/ksm.c
2565
2566 struct page *ksm_might_need_to_copy(struct page *page,
2567 struct vm_area_struct *vma, unsigned long address)
2568 {
2569 struct anon_vma *anon_vma = page_anon_vma(page);
2570 struct page *new_page;
2571
2572 if (PageKsm(page)) {
2573 if (page_stable_node(page) &&
2574 !(ksm_run & KSM_RUN_UNMERGE))
2575 return page; /* no need to copy it */
2576 } else if (!anon_vma) {
2577 return page; /* no need to copy it */
2578 } else if (anon_vma->root == vma->anon_vma->root &&
2579 page->index == linear_page_index(vma, address)) {
2580 return page; /* still no need to copy it */
2581 }
2582 if (!PageUptodate(page))
2583 return page; /* let do_swap_page report the error */
2584
2585 new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);
2586 if (new_page &&
2587 mem_cgroup_charge(page_folio(new_page), vma->vm_mm, GFP_KERNEL)) {
2588 put_page(new_page);
2589 new_page = NULL;
2590 }
2591 if (new_page) {
2592 copy_user_highpage(new_page, page, address, vma);
2593
2594 SetPageDirty(new_page);
2595 __SetPageUptodate(new_page);
2596 __SetPageLocked(new_page);
> 2597 count_vm_event(KSM_SWPIN_COPY);
2598 }
2599
2600 return new_page;
2601 }
2602
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-12 15:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 11:51 [PATCH] mm/vmstat: add event for ksm swapping in copy cgel.zte
2022-01-12 15:58 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).