public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/migrate_pages03: skip migratition of shared pages
@ 2018-11-29 16:29 Jan Stancek
  2018-12-03  8:41 ` Li Wang
  2019-02-26 15:40 ` Cyril Hrubis
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Stancek @ 2018-11-29 16:29 UTC (permalink / raw)
  To: ltp

Fixes: #431

Migrating shared pages (as root) includes also executable pages
(glibc, etc.) Kernel might need to invalidate icache, which can
be an expensive operation on some architectures (arm64).

This test is repeating migration thousands of times, and because
migration (and icache flush) runs for each page, it all stacks
up and test is hitting a timeout.

It's enough for this reproducer to migrate pages it allocates
and merges (via KSM), so do the migration as unprivileged user
and we can avoid the overhead of migrating everything. Such
scenario is already covered by migrate_pages02.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/migrate_pages/migrate_pages03.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/testcases/kernel/syscalls/migrate_pages/migrate_pages03.c b/testcases/kernel/syscalls/migrate_pages/migrate_pages03.c
index ecfc55288691..7317b11283d8 100644
--- a/testcases/kernel/syscalls/migrate_pages/migrate_pages03.c
+++ b/testcases/kernel/syscalls/migrate_pages/migrate_pages03.c
@@ -33,6 +33,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <pwd.h>
 
 #include "tst_test.h"
 #include "lapi/syscalls.h"
@@ -52,6 +53,8 @@ static void *test_pages[N_PAGES];
 static int num_nodes, max_node;
 static int *nodes;
 static unsigned long *new_nodes[2];
+static const char nobody_uid[] = "nobody";
+static struct passwd *ltpuser;
 
 static void setup(void)
 {
@@ -69,6 +72,8 @@ static void setup(void)
 			TEST_NODES);
 	}
 
+	ltpuser = SAFE_GETPWNAM(nobody_uid);
+
 	max_node = LTP_ALIGN(get_max_node(), sizeof(unsigned long) * 8);
 	nodemask_size = max_node / 8;
 	new_nodes[0] = SAFE_MALLOC(nodemask_size);
@@ -125,6 +130,7 @@ static void migrate_test(void)
 {
 	int loop, i, ret;
 
+	SAFE_SETEUID(ltpuser->pw_uid);
 	for (loop = 0; loop < N_LOOPS; loop++) {
 		i = loop % 2;
 		ret = tst_syscall(__NR_migrate_pages, 0, max_node,
@@ -134,6 +140,7 @@ static void migrate_test(void)
 			return;
 		}
 	}
+	SAFE_SETEUID(0);
 
 	tst_res(TPASS, "migrate_pages() passed");
 }
-- 
1.8.3.1


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

end of thread, other threads:[~2019-02-26 16:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-29 16:29 [LTP] [PATCH] syscalls/migrate_pages03: skip migratition of shared pages Jan Stancek
2018-12-03  8:41 ` Li Wang
2019-02-26 15:40 ` Cyril Hrubis
2019-02-26 16:15   ` Jan Stancek

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