Unshare KSM pages before setting max_page_sharing
PATCH 1/1 Unshare KSM pages before setting max_page_sharing
Setting max_page_sharing is possible only when there are no KSM shared pages in the system. Otherwise writing to max_page_sharing SysFS file will fail with EBUSY.
--- testcases/kernel/mem/lib/mem.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
testcases/kernel/mem/lib/mem.c +10 -7
@@ -482,8 +482,11 @@ void create_same_memory(int size, int num, int unit)stop_ksm_children (child, num);tst_res (TINFO ,"KSM merging..." ); -if (access (PATH_KSM "max_page_sharing" ,F_OK ) ==0 ) +if (access (PATH_KSM "max_page_sharing" ,F_OK ) ==0 ) { +SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" );SAFE_FILE_PRINTF (PATH_KSM "max_page_sharing" ,"%ld" , size * pages * num); + } +SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" );SAFE_FILE_PRINTF (PATH_KSM "pages_to_scan" ,"%ld" , size * pages * num);SAFE_FILE_PRINTF (PATH_KSM "sleep_millisecs" ,"0" );
@@ -571,16 +574,16 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages)SAFE_FILE_PRINTF (PATH_KSM "sleep_millisecs" ,"0" );SAFE_FILE_PRINTF (PATH_KSM "pages_to_scan" ,"%ld" , nr_pages * num_nodes); -if (access (PATH_KSM "max_page_sharing" ,F_OK ) ==0 ) -SAFE_FILE_PRINTF (PATH_KSM "max_page_sharing" , -"%ld" , nr_pages * num_nodes);/* -* merge_across_nodes setting can be changed only when there -* are no ksm shared pages in system, so set run 2 to unmerge -* pages first, then to 1 after changing merge_across_nodes, +* merge_across_nodes and max_page_sharing setting can be changed +* only when there are no ksm shared pages in system, so set run 2 +* to unmerge pages first, then to 1 after changing merge_across_nodes, * to remerge according to the new setting. */ SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" ); +if (access (PATH_KSM "max_page_sharing" ,F_OK ) ==0 ) +SAFE_FILE_PRINTF (PATH_KSM "max_page_sharing" , +"%ld" , nr_pages * num_nodes);tst_res (TINFO ,"Start to test KSM with merge_across_nodes=1" );SAFE_FILE_PRINTF (PATH_KSM "merge_across_nodes" ,"1" );SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" );
Signature · 1 line
2.24.0
PATCH 1/1 Unshare KSM pages before setting max_page_sharing
Quoted 6 lines · Martin Doucha
Setting
max_page_sharingis possible only when there are no KSM shared pages
in the system. Otherwise writing tomax_page_sharingSysFS file will fail with EBUSY.Signed-off-by Martin Doucha <[email protected]>
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20191129/5fd0585d/attachment.htm>
PATCH 1/1 Unshare KSM pages before setting max_page_sharing
In reply to Martin DouchaHi Martin,
Quoted 3 lines
Setting
max_page_sharingis possible only when there are no KSM shared pages in the system. Otherwise writing tomax_page_sharingSysFS file will fail with EBUSY.
Good catch!
BTW at least ksm01 will fail on VM host with running VMs, but that's another story not related to this patch.
mem.c:251: FAIL: pages_shared is not 1 but 3629. mem.c:251: FAIL: pages_sharing is not 98302 but 113789. mem.c:251: FAIL: pages_volatile is not 0 but 12. mem.c:251: FAIL: pages_unshared is not 1 but 48519.
Kind regards,
Petr
PATCH 1/1 Unshare KSM pages before setting max_page_sharing
Quoted 9 lines · Petr Vorel
Hi Martin,
Quoted 1 line
Setting
max_page_sharingis possible only when there are no KSM sharedpages
Quoted 2 lines
in the system. Otherwise writing to
max_page_sharingSysFS file will fail with EBUSY.Reviewed-by Petr Vorel <[email protected]>
Pushed.
Quoted 6 lines
Good catch!
BTW at least ksm01 will fail on VM host with running VMs, but that's another story not related to this patch.
AFAIK, KSM is mainly designed for VMs pages merging. It seems the LTP ksm test can't run in parallel too, they are suggested to be the only test without any other ksm-test running in the background. Because ksmd does not distinguish which process the pages belong to, it just does merging and counting work in total for the whole system.
If we run ./ksm01 & ./ksm01, it will also fail like below I think.
Quoted 6 lines
mem.c:251: FAIL:
pages_sharedis not 1 but 3629. mem.c:251: FAIL:pages_sharingis not 98302 but 113789. mem.c:251: FAIL:pages_volatileis not 0 but 12. mem.c:251: FAIL:pages_unsharedis not 1 but 48519.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20191202/8c711629/attachment.htm>
PATCH 1/1 Unshare KSM pages before setting max_page_sharing
In reply to Petr VorelQuoted 7 lines · Petr Vorel
BTW at least ksm01 will fail on VM host with running VMs, but that's another story not related to this patch.
mem.c:251: FAIL:
pages_sharedis not 1 but 3629. mem.c:251: FAIL:pages_sharingis not 98302 but 113789. mem.c:251: FAIL:pages_volatileis not 0 but 12. mem.c:251: FAIL:pages_unsharedis not 1 but 48519.
I'm aware of other KSM tests failing but the failures are rare and quite random so they'll be tricky to debug. The snippet you've sent looks like interference from another process running on the same VM but the failures I see in OpenQA look like some sort of race condition in kernel itself.
Signature · 7 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic
PATCH 1/1 Unshare KSM pages before setting max_page_sharing
Hi,
Quoted 8 lines
Quoted 7 lines
BTW at least ksm01 will fail on VM host with running VMs, but that's another story not related to this patch.
mem.c:251: FAIL:
pages_sharedis not 1 but 3629. mem.c:251: FAIL:pages_sharingis not 98302 but 113789. mem.c:251: FAIL:pages_volatileis not 0 but 12. mem.c:251: FAIL:pages_unsharedis not 1 but 48519.
Quoted 5 lines
I'm aware of other KSM tests failing but the failures are rare and quite random so they'll be tricky to debug. The snippet you've sent looks like interference from another process running on the same VM but the failures I see in OpenQA look like some sort of race condition in kernel itself.
Yep, my failures are for sure different. I run the test on my workstation (KVM host), after start of about 15 VMs. Before test was ok. I haven't tested, but it should be ok when running on KVM guests.
Kind regards,
Petr