Skip to contentSkip to conversation

move_pages12: Ignore ENOMEM from madvise(MADV_SOFT_OFFLINE)

PATCH In review Martin Doucha 2 participants 5 messages Mar 19, 2025 – Mar 24, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 move_pages12: Ignore ENOMEM from madvise(MADV_SOFT_OFFLINE)

The test dissolves hugepages which results in soft-offline madvise() call returning ENOMEM after a few iterations. This is expected behavior. However, trying to preallocate more hugepages to prevent the error will break the ability to reproduce the SIGBUS bug. Simply ignoring the ENOMEM error is good enough.

---
 testcases/kernel/syscalls/move_pages/move_pages12.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/move_pages/move_pages12.c +1 -1
index 879a89b6f..a5454b1ec 100644
@@ -100,7 +100,7 @@ static void *addr;
 static int do_soft_offline(int tpgs)
 {
 	if (madvise(addr, tpgs * hpsz, MADV_SOFT_OFFLINE) == -1) {
-		if (errno != EINVAL && errno != EBUSY)
+		if (errno != EINVAL && errno != EBUSY && errno != ENOMEM)
 			tst_res(TFAIL | TERRNO, "madvise failed");
 		return errno;
 	}
Signature · 5 lines
2.47.0


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

PATCH 2/2 move_pages12: Increase loop count to 10,000

Since the test doesn't print hundreds of ENOMEM error messages anymore after the previous change, it now runs too fast to reproduce the SIGBUS bug. Increase loop count to make the bug reproducible again.

---
 testcases/kernel/syscalls/move_pages/move_pages12.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/move_pages/move_pages12.c +1 -1
index a5454b1ec..440773a38 100644
@@ -74,7 +74,7 @@
 
 #ifdef HAVE_NUMA_V2
 
-#define LOOPS	1000
+#define LOOPS	10000
 #define PATH_MEMINFO	"/proc/meminfo"
 #define PATH_NR_HUGEPAGES	"/proc/sys/vm/nr_hugepages"
 #define PATH_HUGEPAGES	"/sys/kernel/mm/hugepages/"
Signature · 5 lines
2.47.0


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

Re: [LTP] [PATCH 2/2] move_pages12: Increase loop count to 10,000

Quoted 6 lines · Martin Doucha

Since the test doesn't print hundreds of ENOMEM error messages anymore after the previous change, it now runs too fast to reproduce the SIGBUS bug. Increase loop count to make the bug reproducible again.

---

Quoted 25 lines
 testcases/kernel/syscalls/move_pages/move_pages12.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/move_pages/move_pages12.c +1 -2
index a5454b1ec..440773a38 100644
@@ -74,7 +74,7 @@
 
 #ifdef HAVE_NUMA_V2
 
-#define LOOPS  1000
+#define LOOPS  10000
 #define PATH_MEMINFO   "/proc/meminfo"
 #define PATH_NR_HUGEPAGES      "/proc/sys/vm/nr_hugepages"
 #define PATH_HUGEPAGES "/sys/kernel/mm/hugepages/"
--

2.47.0

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by Li Wang on v1 1/2
#3 lore raw
In reply to Martin Doucha

Hi Martin,

I had ever added a compressed memory step to dis fragmental before doing hugepage allocations (in commit e97f41970582 ), but that didn't seem to solve the problem ideally.

Anyway, this patch looks good.

Quoted 34 lines · Martin Doucha

The test dissolves hugepages which results in soft-offline madvise() call returning ENOMEM after a few iterations. This is expected behavior. However,
trying to preallocate more hugepages to prevent the error will break the ability to reproduce the SIGBUS bug. Simply ignoring the ENOMEM error is good enough.

---
 testcases/kernel/syscalls/move_pages/move_pages12.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/move_pages/move_pages12.c +1 -2
index 879a89b6f..a5454b1ec 100644
@@ -100,7 +100,7 @@ static void *addr;
 static int do_soft_offline(int tpgs)
 {
        if (madvise(addr, tpgs * hpsz, MADV_SOFT_OFFLINE) == -1) {
-               if (errno != EINVAL && errno != EBUSY)
+               if (errno != EINVAL && errno != EBUSY && errno != ENOMEM)
                        tst_res(TFAIL | TERRNO, "madvise failed");
                return errno;
        }
--

2.47.0

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 5 lines
Regards,
Li Wang

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

Patchset merged, thanks!

Quoted 51 lines · Li Wang

Hi Martin,

I had ever added a compressed memory step to dis fragmental before doing hugepage allocations (in commit e97f41970582 ), but that didn't seem to solve the problem ideally.

Anyway, this patch looks good.

Quoted 30 lines · Martin Doucha

The test dissolves hugepages which results in soft-offline madvise() call returning ENOMEM after a few iterations. This is expected behavior. However,
trying to preallocate more hugepages to prevent the error will break the ability to reproduce the SIGBUS bug. Simply ignoring the ENOMEM error is good enough.

---
 testcases/kernel/syscalls/move_pages/move_pages12.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/move_pages/move_pages12.c +1 -2
index 879a89b6f..a5454b1ec 100644
@@ -100,7 +100,7 @@ static void *addr;
 static int do_soft_offline(int tpgs)
 {
        if (madvise(addr, tpgs * hpsz, MADV_SOFT_OFFLINE) == -1) {
-               if (errno != EINVAL && errno != EBUSY)
+               if (errno != EINVAL && errno != EBUSY && errno != ENOMEM)
                        tst_res(TFAIL | TERRNO, "madvise failed");
                return errno;
        }
--

2.47.0

Quoted 4 lines

--
Mailing list info: https://lists.linux.it/listinfo/ltp

--
Regards,
Li Wang

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp