diff mbox series

syscalls/migrate_pages03: skip migratition of shared pages

Message ID 12d3ccf40055c225b97a4a94ed1c6a46d4fd2048.1543508512.git.jstancek@redhat.com
State Accepted, archived
Headers show
Series syscalls/migrate_pages03: skip migratition of shared pages | expand

Commit Message

Jan Stancek Nov. 29, 2018, 4:29 p.m. UTC
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(+)

Comments

Li Wang Dec. 3, 2018, 8:41 a.m. UTC | #1
On Fri, Nov 30, 2018 at 12:29 AM Jan Stancek <jstancek@redhat.com> wrote:
>
> 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.

I'm OK to drop privileges before calling migrate_pages() in this
testcase, but if we can start a new topic in LKML for more discussion
that would be better?

>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>

Reviewed-by: Li Wang <liwang@redhat.com>

--
Regards,
Li Wang
Cyril Hrubis Feb. 26, 2019, 3:40 p.m. UTC | #2
Hi!
Looks good to me, acked.
Jan Stancek Feb. 26, 2019, 4:15 p.m. UTC | #3
----- Original Message -----
> Hi!
> Looks good to me, acked.

Pushed.

Regards,
Jan
diff mbox series

Patch

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");
 }