All of lore.kernel.org
 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

* [LTP] [PATCH] syscalls/migrate_pages03: skip migratition of shared pages
  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
  1 sibling, 0 replies; 4+ messages in thread
From: Li Wang @ 2018-12-03  8:41 UTC (permalink / raw)
  To: ltp

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

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

* [LTP] [PATCH] syscalls/migrate_pages03: skip migratition of shared pages
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2019-02-26 15:40 UTC (permalink / raw)
  To: ltp

Hi!
Looks good to me, acked.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH] syscalls/migrate_pages03: skip migratition of shared pages
  2019-02-26 15:40 ` Cyril Hrubis
@ 2019-02-26 16:15   ` Jan Stancek
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Stancek @ 2019-02-26 16:15 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> Hi!
> Looks good to me, acked.

Pushed.

Regards,
Jan

^ permalink raw reply	[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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.