Skip to contentSkip to conversation

madvise11: Allow test to skip if MADV_SOFT_OFFLINE is not supported

PATCH Superseded Edward Liaw via ltp 3 participants 6 messages Nov 2, 2023 – Nov 3, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 madvise11: Allow test to skip if MADV_SOFT_OFFLINE is not supported

madvise11 will exit with TFAIL if CONFIG_MEMORY_FAILURE is not configured. Skip the TFAIL if EINVAL is returned by madvise.

---
 testcases/kernel/syscalls/madvise/madvise11.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/madvise/madvise11.c +4 -3
index 3cde85ef5..0793319d2 100644
@@ -162,7 +162,7 @@ static void *alloc_mem(void *threadnum)
 	err = allocate_offline(tnum);
 	tst_res(TINFO,
 		"Thread [%d] returned %d, %s.", tnum, err, (err ? "failed" : "succeeded"));
-	return (void *)(uintptr_t) (err ? -1 : 0);
+	return (void *)(uintptr_t) err;
 }
 
 static void stress_alloc_offl(void)
@@ -188,8 +188,9 @@ static void stress_alloc_offl(void)
 
 		SAFE_PTHREAD_JOIN(thread_ids[thread_index], &status);
 		if ((intptr_t)status != 0) {
-			tst_res(TFAIL, "thread [%d] - exited with errors",
-				thread_index);
+			if ((intptr_t)status != EINVAL)
+				tst_res(TFAIL, "thread [%d] - exited with errors",
+					thread_index);
 			thread_failure++;
 		}
 	}
Signature · 5 lines
2.42.0.869.gea05f2083d-goog


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 1/1 madvise11: Replace /etc/mtab with /proc/mounts

Android does not have the /etc/mtab symlink, so trying to open it fails with TBROK. Replace it with /proc/mounts.

---
 testcases/kernel/syscalls/madvise/madvise11.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/madvise/madvise11.c +2 -2
index 0793319d2..55556f530 100644
@@ -308,9 +308,9 @@ static int open_unpoison_pfn(void)
 		SAFE_CMD(cmd_modprobe, NULL, NULL);
 
 	/* debugfs mount point */
-	mntf = setmntent("/etc/mtab", "r");
+	mntf = setmntent("/proc/mounts", "r");
 	if (!mntf) {
-		tst_brk(TBROK | TERRNO, "Can't open /etc/mtab");
+		tst_brk(TBROK | TERRNO, "Can't open /proc/mounts");
 		return -1;
 	}
 	while ((mnt = getmntent(mntf)) != NULL) {
Signature · 5 lines
2.42.0.869.gea05f2083d-goog


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#2 lore raw

Re: [LTP] [PATCH] madvise11: Replace /etc/mtab with /proc/mounts

Hi Edward,

Quoted 2 lines

Android does not have the /etc/mtab symlink, so trying to open it fails with TBROK. Replace it with /proc/mounts.

Thanks!

BTW there are other tests which mention /etc/mtab, but only as tst_resm(TINFO, ) message.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Applied
#3 lore raw

Re: [LTP] [PATCH] madvise11: Replace /etc/mtab with /proc/mounts

Hi Edward,

merged, thanks!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw
In reply to Edward Liaw via ltp

Hi!

Quoted 2 lines

madvise11 will exit with TFAIL if CONFIG_MEMORY_FAILURE is not configured. Skip the TFAIL if EINVAL is returned by madvise.

Does it make sense to keep the test running if the config option is not present? As far as I can tell we are trying to reproduce a race there that depends on the madvise being able to soft offline the pages.

What about this then?

testcases/kernel/syscalls/madvise/madvise11.c +4 -0
index 74caadc44..50ab935c9 100644
@@ -426,6 +426,10 @@ static struct tst_test test = {
                "rmmod",
                NULL
        },
+       .needs_kconfigs = (const char *[]) {
+                "CONFIG_MEMORY_FAILURE=y",
+                NULL
+        },
        .max_runtime = 30,
        .needs_checkpoints = 1,
        .setup = setup,
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Hi Cyril,

Quoted 19 lines · Cyril Hrubis

Hi!

Quoted 2 lines

madvise11 will exit with TFAIL if CONFIG_MEMORY_FAILURE is not configured. Skip the TFAIL if EINVAL is returned by madvise.

Does it make sense to keep the test running if the config option is not present? As far as I can tell we are trying to reproduce a race there that depends on the madvise being able to soft offline the pages.

What about this then?

testcases/kernel/syscalls/madvise/madvise11.c +0 -0
index 74caadc44..50ab935c9 100644
@@ -426,6 +426,10 @@ static struct tst_test test = {
                "rmmod",
                NULL
        },

testcases/kernel/syscalls/madvise/madvise11.c static struct tst_test test = {

Quoted 10 lines
testcases/kernel/syscalls/madvise/madvise11.c +4 -1
+       .needs_kconfigs = (const char *[]) {
+                "CONFIG_MEMORY_FAILURE=y",
+                NULL
+        },
        .max_runtime = 30,
        .needs_checkpoints = 1,
        .setup = setup,
 
 
--

Yeah, that makes more sense to me.

Quoted 2 lines

Cyril Hrubis
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp