Message ID | 20191128163147.4377-1-mdoucha@suse.cz |
---|---|
State | Accepted |
Delegated to: | Petr Vorel |
Headers | show |
Series | Unshare KSM pages before setting max_page_sharing | expand |
On Fri, Nov 29, 2019 at 12:32 AM Martin Doucha <mdoucha@suse.cz> wrote: > 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. > > Signed-off-by: Martin Doucha <mdoucha@suse.cz> Acked-by: Li Wang <liwang@redhat.com>
Hi Martin, > 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. Reviewed-by: Petr Vorel <pvorel@suse.cz> 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
On Mon, Dec 2, 2019 at 11:29 AM Petr Vorel <pvorel@suse.cz> wrote: > Hi Martin, > > > 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. > > Reviewed-by: Petr Vorel <pvorel@suse.cz> > Pushed. > > 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. > > 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. >
On 12/2/19 4:29 AM, Petr Vorel wrote: > 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. 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.
Hi, > > 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. > 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
diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index a0c1b9b00..456259792 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -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");
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. Signed-off-by: Martin Doucha <mdoucha@suse.cz> --- testcases/kernel/mem/lib/mem.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)