selftests/mm: skip several tests when thp is not available
Subsystems (4)
v6 cover selftests/mm: skip several tests when thp is not available
There are several tests requires transprarent hugepages, when run on thp disabled kernel such as realtime kernel, there will be false negative. Mark those tests as skip when thp is not available.
Chagnes in v6:
- patch 3 add reviewed-by from Lorenzo
- patch 4 handle the errno before and after close(), suggested by AI
Changes in v5:
- patch 1, patch 3 updated reviwed-by and acked-by
- patch 4 adds new patch for robust write_file()
Changes in v4:
- patch 1 update to use thp_available instead of thp_is_enabled, suggested by ai review
- removed reviewed-by and acked-by
Changes in v3:
- patch 1 update commit message to show the log snippet with where the fail happens, change the 'false positive' to 'false negative'. Update reviwed by
- patch 2 update reviewed-by
- patch 3 make write_file to void return
- patch 4 and patch 5 updated reviewed-by/acked-by
Changes in v2:
- replace 'false postive' with 'false negative' in cover letter
- patch 1 and patch 2 add reviewed-by/acked-by
- new patch 3 to add write_file() in vm_util as a common helper
- patch 4 removed the {} in if block, removed the write_file helper rename chunk in v1. Add reviewed-by
- patch 5 move the exit chunk to the front of ksft_print_headers() as suggested by David. Add review by.
Chunyu Hu (6):
selftests/mm/guard-regions: skip collapse test when thp not enabled selftests/mm: soft-dirty: skip two tests when thp is not available selftests/mm: move write_file helper to vm_util selftests/mm/vm_util: robust write_file()
selftests/mm: split_huge_page_test: skip the test when thp is not
available
selftests/mm: transhuge_stress: skip the test when thp not available
tools/testing/selftests/mm/guard-regions.c | 4 +++ tools/testing/selftests/mm/soft-dirty.c | 4 ++- .../selftests/mm/split_huge_page_test.c | 19 +++------- tools/testing/selftests/mm/thp_settings.c | 35 ++----------------- tools/testing/selftests/mm/thp_settings.h | 1 - tools/testing/selftests/mm/transhuge-stress.c | 4 +++ tools/testing/selftests/mm/vm_util.c | 23 ++++++++++++ tools/testing/selftests/mm/vm_util.h | 2 ++ 8 files changed, 43 insertions(+), 49 deletions(-)
base-commit: c369299895a591d96745d6492d4888259b004a9e
Signature · 1 line
2.53.0
PATCH v6 1/6 selftests/mm/guard-regions: skip collapse test when thp not enabled
When thp is not available, just skip the collape tests to avoid the false negative.
Without the change, run with a thp disabled kernel:
./run_vmtests.sh -t madv_guard -n 1
<snip/>
# RUN guard_regions.anon.collapse ...
# guard-regions.c:2217:collapse:Expected madvise(ptr, size, MADV_NOHUGEPAGE) (-1) == 0 (0) # collapse: Test terminated by assertion
# FAIL guard_regions.anon.collapse
not ok 2 guard_regions.anon.collapse
<snip/>
# RUN guard_regions.shmem.collapse ...
# guard-regions.c:2217:collapse:Expected madvise(ptr, size, MADV_NOHUGEPAGE) (-1) == 0 (0) # collapse: Test terminated by assertion
# FAIL guard_regions.shmem.collapse
not ok 32 guard_regions.shmem.collapse
<snip/>
# RUN guard_regions.file.collapse ...
# guard-regions.c:2217:collapse:Expected madvise(ptr, size, MADV_NOHUGEPAGE) (-1) == 0 (0) # collapse: Test terminated by assertion
# FAIL guard_regions.file.collapse
not ok 62 guard_regions.file.collapse
<snip/>
# FAILED: 87 / 90 tests passed.
# 17 skipped test(s) detected. Consider enabling relevant config options to improve coverage. # Totals: pass:70 fail:3 xfail:0 xpass:0 skip:17 error:0
With this change, run with thp disabled kernel:
./run_vmtests.sh -t madv_guard -n 1
<snip/>
# RUN guard_regions.anon.collapse ... # SKIP Transparent Hugepages not available # OK guard_regions.anon.collapse ok 2 guard_regions.anon.collapse # SKIP Transparent Hugepages not available <snip/> # RUN guard_regions.file.collapse ... # SKIP Transparent Hugepages not available # OK guard_regions.file.collapse ok 62 guard_regions.file.collapse # SKIP Transparent Hugepages not available <snip/> # RUN guard_regions.shmem.collapse ... # SKIP Transparent Hugepages not available # OK guard_regions.shmem.collapse
ok 32 guard_regions.shmem.collapse # SKIP Transparent Hugepages not available <snip/>
# PASSED: 90 / 90 tests passed.
# 20 skipped test(s) detected. Consider enabling relevant config options to improve coverage. # Totals: pass:70 fail:0 xfail:0 xpass:0 skip:20 error:0
---
Changes in v5:
- updated reviewed-by and acked-by
Changes in v4:
- use thp_available instead of thp_is_enabled() as when thp is set to never, madvise(MADV_COLLAPSE) will still succeed by design. So a failure in madvise(MADV_COLLAPSE) on guard region will verify guard region denies it. This is suggested from AI.
- removed the 'Reviewed-by' and 'Acked-by' as the code changes. Sorry for that but it seems the changes is a little huge? (1 out of 2 lines)..
Changes in v3:
- commit message: update the log snippet with where the fail happens and add the '-n1' to the command.
- fix the 'false positive' to 'false negative'
- add reviwed by from Mike
Changes in v2:
- add reviewed by from Zi and Lorenzo
- add acked-by from David
--- tools/testing/selftests/mm/guard-regions.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/mm/guard-regions.c +4 -0
@@ -21,6 +21,7 @@#include <sys/uio.h> #include <unistd.h> #include "vm_util.h" +#include "thp_settings.h" #include "../pidfd/pidfd.h"
@@ -2195,6 +2196,9 @@ TEST_F(guard_regions, collapse)char *ptr;int i; +if (!thp_available ()) +SKIP (return,"Transparent Hugepages not available\n" ); +/* Need file to be correct size for tests for non-anon. */ if (variant->backing !=ANON_BACKED )ASSERT_EQ (ftruncate (self->fd, size),0 );
Signature · 1 line
2.53.0
Re: [PATCH v6 1/6] selftests/mm/guard-regions: skip collapse test when thp not enabled
Quoted 50 lines · Chunyu Hu
When thp is not available, just skip the collape tests to avoid the false negative.
Without the change, run with a thp disabled kernel:
./run_vmtests.sh -tmadv_guard-n 1
<snip/>
# RUN guard_regions.anon.collapse ...
# guard-regions.c:2217:collapse:Expectedmadvise(ptr, size, MADV_NOHUGEPAGE)(-1) == 0 (0) # collapse: Test terminated by assertion
# FAIL guard_regions.anon.collapse
not ok 2 guard_regions.anon.collapse
<snip/>
# RUN guard_regions.shmem.collapse ...
# guard-regions.c:2217:collapse:Expectedmadvise(ptr, size, MADV_NOHUGEPAGE)(-1) == 0 (0) # collapse: Test terminated by assertion
# FAIL guard_regions.shmem.collapse
not ok 32 guard_regions.shmem.collapse
<snip/>
# RUN guard_regions.file.collapse ...
# guard-regions.c:2217:collapse:Expectedmadvise(ptr, size, MADV_NOHUGEPAGE)(-1) == 0 (0) # collapse: Test terminated by assertion
# FAIL guard_regions.file.collapse
not ok 62 guard_regions.file.collapse
<snip/>
# FAILED: 87 / 90 tests passed.
# 17 skipped test(s) detected. Consider enabling relevant config options to improve coverage. # Totals: pass:70 fail:3 xfail:0 xpass:0 skip:17 error:0With this change, run with thp disabled kernel:
./run_vmtests.sh -tmadv_guard-n 1
<snip/># RUN guard_regions.anon.collapse ... # SKIP Transparent Hugepages not available # OK guard_regions.anon.collapse ok 2 guard_regions.anon.collapse # SKIP Transparent Hugepages not available <snip/> # RUN guard_regions.file.collapse ... # SKIP Transparent Hugepages not available # OK guard_regions.file.collapse ok 62 guard_regions.file.collapse # SKIP Transparent Hugepages not available <snip/> # RUN guard_regions.shmem.collapse ... # SKIP Transparent Hugepages not available # OK guard_regions.shmem.collapseok 32 guard_regions.shmem.collapse # SKIP Transparent Hugepages not available <snip/>
# PASSED: 90 / 90 tests passed.
# 20 skipped test(s) detected. Consider enabling relevant config options to improve coverage. # Totals: pass:70 fail:0 xfail:0 xpass:0 skip:20 error:0
Quoted 5 lines
Reviewed-by Zi Yan <[email protected]>CC Li Wang <[email protected]>Signed-off-by Chunyu Hu <[email protected]>
Pretty sure I reviewed this already (but hey I forget to propagate tags myself sometimes so meh :P), anyway:
Cheers, Lorenzo
Quoted 47 lines
---
Changes in v5:
- updated reviewed-by and acked-by
Changes in v4:
- usethp_availableinstead ofthp_is_enabled()as when thp is set to never,madvise(MADV_COLLAPSE)will still succeed by design. So a failure inmadvise(MADV_COLLAPSE)on guard region will verify guard region denies it. This is suggested from AI.
- removed the 'Reviewed-by' and 'Acked-by' as the code changes. Sorry for that but it seems the changes is a little huge? (1 out of 2 lines)..
Changes in v3:
- commit message: update the log snippet with where the fail happens and add the '-n1' to the command.
- fix the 'false positive' to 'false negative'
- add reviwed by from Mike
Changes in v2:
- add reviewed by from Zi and Lorenzo
- add acked-by from David--- tools/testing/selftests/mm/guard-regions.c | 4 ++++ 1 file changed, 4 insertions(+)tools/testing/selftests/mm/guard-regions.c +4
-1@@ -21,6 +21,7 @@#include <sys/uio.h> #include <unistd.h> #include "vm_util.h" +#include "thp_settings.h" #include "../pidfd/pidfd.h" @@ -2195,6 +2196,9 @@ TEST_F(guard_regions, collapse)char *ptr;int i; +if (!thp_available ()) +SKIP (return,"Transparent Hugepages not available\n" ); +/* Need file to be correct size for tests for non-anon. */ if (variant->backing !=ANON_BACKED )ASSERT_EQ (ftruncate (self->fd, size),0 ); --2.53.0
Re: [PATCH v6 1/6] selftests/mm/guard-regions: skip collapse test when thp not enabled
Quoted 57 lines · Lorenzo Stoakes (Oracle)
Quoted 50 lines · Chunyu Hu
When thp is not available, just skip the collape tests to avoid the false negative.
Without the change, run with a thp disabled kernel:
./run_vmtests.sh -tmadv_guard-n 1
<snip/>
# RUN guard_regions.anon.collapse ...
# guard-regions.c:2217:collapse:Expectedmadvise(ptr, size, MADV_NOHUGEPAGE)(-1) == 0 (0) # collapse: Test terminated by assertion
# FAIL guard_regions.anon.collapse
not ok 2 guard_regions.anon.collapse
<snip/>
# RUN guard_regions.shmem.collapse ...
# guard-regions.c:2217:collapse:Expectedmadvise(ptr, size, MADV_NOHUGEPAGE)(-1) == 0 (0) # collapse: Test terminated by assertion
# FAIL guard_regions.shmem.collapse
not ok 32 guard_regions.shmem.collapse
<snip/>
# RUN guard_regions.file.collapse ...
# guard-regions.c:2217:collapse:Expectedmadvise(ptr, size, MADV_NOHUGEPAGE)(-1) == 0 (0) # collapse: Test terminated by assertion
# FAIL guard_regions.file.collapse
not ok 62 guard_regions.file.collapse
<snip/>
# FAILED: 87 / 90 tests passed.
# 17 skipped test(s) detected. Consider enabling relevant config options to improve coverage. # Totals: pass:70 fail:3 xfail:0 xpass:0 skip:17 error:0With this change, run with thp disabled kernel:
./run_vmtests.sh -tmadv_guard-n 1
<snip/># RUN guard_regions.anon.collapse ... # SKIP Transparent Hugepages not available # OK guard_regions.anon.collapse ok 2 guard_regions.anon.collapse # SKIP Transparent Hugepages not available <snip/> # RUN guard_regions.file.collapse ... # SKIP Transparent Hugepages not available # OK guard_regions.file.collapse ok 62 guard_regions.file.collapse # SKIP Transparent Hugepages not available <snip/> # RUN guard_regions.shmem.collapse ... # SKIP Transparent Hugepages not available # OK guard_regions.shmem.collapseok 32 guard_regions.shmem.collapse # SKIP Transparent Hugepages not available <snip/>
# PASSED: 90 / 90 tests passed.
# 20 skipped test(s) detected. Consider enabling relevant config options to improve coverage. # Totals: pass:70 fail:0 xfail:0 xpass:0 skip:20 error:0Quoted 5 lines
Reviewed-by Zi Yan <[email protected]>CC Li Wang <[email protected]>Signed-off-by Chunyu Hu <[email protected]>
Quoted 4 lines
Pretty sure I reviewed this already (but hey I forget to propagate tags myself sometimes so meh :P), anyway:
Reviewed-by Lorenzo Stoakes (Oracle) <[email protected]>
Thanks for the review. Will add in next version.
Quoted 51 lines
Cheers, Lorenzo
Quoted 47 lines
---
Changes in v5:
- updated reviewed-by and acked-by
Changes in v4:
- usethp_availableinstead ofthp_is_enabled()as when thp is set to never,madvise(MADV_COLLAPSE)will still succeed by design. So a failure inmadvise(MADV_COLLAPSE)on guard region will verify guard region denies it. This is suggested from AI.
- removed the 'Reviewed-by' and 'Acked-by' as the code changes. Sorry for that but it seems the changes is a little huge? (1 out of 2 lines)..
Changes in v3:
- commit message: update the log snippet with where the fail happens and add the '-n1' to the command.
- fix the 'false positive' to 'false negative'
- add reviwed by from Mike
Changes in v2:
- add reviewed by from Zi and Lorenzo
- add acked-by from David--- tools/testing/selftests/mm/guard-regions.c | 4 ++++ 1 file changed, 4 insertions(+)tools/testing/selftests/mm/guard-regions.c +4
-1@@ -21,6 +21,7 @@#include <sys/uio.h> #include <unistd.h> #include "vm_util.h" +#include "thp_settings.h" #include "../pidfd/pidfd.h" @@ -2195,6 +2196,9 @@ TEST_F(guard_regions, collapse)char *ptr;int i; +if (!thp_available ()) +SKIP (return,"Transparent Hugepages not available\n" ); +/* Need file to be correct size for tests for non-anon. */ if (variant->backing !=ANON_BACKED )ASSERT_EQ (ftruncate (self->fd, size),0 ); --2.53.0
PATCH v6 2/6 selftests/mm: soft-dirty: skip two tests when thp is not available
In reply to Chunyu HuThe test_hugepage test contain two sub tests. If just reporting one skip when thp not available, there will be error in the log because the test count don't match the test plan. Change to skip two tests by running the ksft_test_result_skip twice in this case.
Without the fix (run test on thp disabled kernel):
./run_vmtests.sh -t soft_dirty
# --------------------
# running ./soft-dirty # -------------------- # TAP version 13 # 1..19 # ok 1 Test test_simple # ok 2 Test test_vma_reuse dirty bit of allocated page # ok 3 Test test_vma_reuse dirty bit of reused address page # ok 4 # SKIP Transparent Hugepages not available # ok 5 Test test_mprotect-anon dirty bit of new written page # ok 6 Test test_mprotect-anon soft-dirty clear after clear_refs # ok 7 Test test_mprotect-anon soft-dirty clear after marking RO # ok 8 Test test_mprotect-anon soft-dirty clear after marking RW # ok 9 Test test_mprotect-anon soft-dirty after rewritten # ok 10 Test test_mprotect-file dirty bit of new written page # ok 11 Test test_mprotect-file soft-dirty clear after clear_refs # ok 12 Test test_mprotect-file soft-dirty clear after marking RO # ok 13 Test test_mprotect-file soft-dirty clear after marking RW # ok 14 Test test_mprotect-file soft-dirty after rewritten # ok 15 Test test_merge-anon soft-dirty after remap merge 1st pg # ok 16 Test test_merge-anon soft-dirty after remap merge 2nd pg # ok 17 Test test_merge-anon soft-dirty after mprotect merge 1st pg # ok 18 Test test_merge-anon soft-dirty after mprotect merge 2nd pg # # 1 skipped test(s) detected. Consider enabling relevant config options to improve coverage. # # Planned tests != run tests (19 != 18) # # Totals: pass:17 fail:0 xfail:0 xpass:0 skip:1 error:0 # [FAIL] not ok 52 soft-dirty # exit=1
With the fix (run test on thp disabled kernel):
./run_vmtests.sh -t soft_dirty
# --------------------
# running ./soft-dirty # TAP version 13 # -------------------- # running ./soft-dirty # -------------------- # TAP version 13 # 1..19 # ok 1 Test test_simple # ok 2 Test test_vma_reuse dirty bit of allocated page # ok 3 Test test_vma_reuse dirty bit of reused address page # # Transparent Hugepages not available # ok 4 # SKIP Test test_hugepage huge page allocation # ok 5 # SKIP Test test_hugepage huge page dirty bit # ok 6 Test test_mprotect-anon dirty bit of new written page # ok 7 Test test_mprotect-anon soft-dirty clear after clear_refs # ok 8 Test test_mprotect-anon soft-dirty clear after marking RO # ok 9 Test test_mprotect-anon soft-dirty clear after marking RW # ok 10 Test test_mprotect-anon soft-dirty after rewritten # ok 11 Test test_mprotect-file dirty bit of new written page # ok 12 Test test_mprotect-file soft-dirty clear after clear_refs # ok 13 Test test_mprotect-file soft-dirty clear after marking RO # ok 14 Test test_mprotect-file soft-dirty clear after marking RW # ok 15 Test test_mprotect-file soft-dirty after rewritten # ok 16 Test test_merge-anon soft-dirty after remap merge 1st pg # ok 17 Test test_merge-anon soft-dirty after remap merge 2nd pg # ok 18 Test test_merge-anon soft-dirty after mprotect merge 1st pg # ok 19 Test test_merge-anon soft-dirty after mprotect merge 2nd pg # # 2 skipped test(s) detected. Consider enabling relevant config options to improve coverage. # # Totals: pass:17 fail:0 xfail:0 xpass:0 skip:2 error:0 # [PASS] ok 1 soft-dirty hwpoison_inject # SUMMARY: PASS=1 SKIP=0 FAIL=0 1..1
---
Changes in v3:
- Add reviewed by from Mike
Changes in v2:
- add reviewed by from Lorenzo and Zi
- add acked-by from David
--- tools/testing/selftests/mm/soft-dirty.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/mm/soft-dirty.c +3 -1
@@ -82,7 +82,9 @@ static void test_hugepage(int pagemap_fd, int pagesize)int i, ret;if (!thp_is_enabled ()) { -ksft_test_result_skip ("Transparent Hugepages not available\n" ); +ksft_print_msg ("Transparent Hugepages not available\n" ); +ksft_test_result_skip ("Test %s huge page allocation\n" , __func__); +ksft_test_result_skip ("Test %s huge page dirty bit\n" , __func__);return ; }
Signature · 1 line
2.53.0
PATCH v6 3/6 selftests/mm: move write_file helper to vm_util
In reply to Chunyu Huthp_settings provides write_file() helper for safely writing to a file and exit when write failure happens. It's a very low level helper and many sub tests need such a helper, not only thp tests.
split_huge_page_test also defines a write_file locally. The two have minior differences in return type and used exit api. And there would be conflicts if split_huge_page_test wanted to include thp_settings.h because of different prototype, making it less convenient.
It's possisble to merge the two, although some tests don't use the kselftest infrastrucutre for testing. It would also work when using the ksft_exit_msg() to exit in my test, as the counters are all zero. Output will be like:
TAP version 13
1..62
Bail out! /proc/sys/vm/drop_caches1 open failed: No such file or directory # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
So here we just keep the version in split_huge_page_test, and move it into the vm_util. This makes it easy to maitain and user could just include one vm_util.h when they don't need thp setting helpers. Keep the prototype of void return as the function will exit on any error, return value is not necessary, and will simply the callers like write_num() and write_string().
---
Changes in v6:
- add reviewed-by from Lorenzo
Changes in v5:
- updated acked-by and reviewed-by
Changes in v3:
- make the write_file void return
Changes in v2:
new patch from v2
--- .../selftests/mm/split_huge_page_test.c | 15 -------- tools/testing/selftests/mm/thp_settings.c | 35 ++----------------- tools/testing/selftests/mm/thp_settings.h | 1 - tools/testing/selftests/mm/vm_util.c | 15 ++++++++ tools/testing/selftests/mm/vm_util.h | 2 ++ 5 files changed, 20 insertions(+), 48 deletions(-)
tools/testing/selftests/mm/split_huge_page_test.c +0 -15
@@ -255,21 +255,6 @@ static int check_after_split_folio_orders(char *vaddr_start, size_t len,return status; } -static void write_file (const char *path,const char *buf,size_t buflen) -{ -int fd; -ssize_t numwritten; - - fd =open (path,O_WRONLY ); -if (fd ==-1 ) -ksft_exit_fail_msg ("%s open failed: %s\n" , path,strerror (errno)); - - numwritten =write (fd, buf, buflen -1 ); -close (fd); -if (numwritten <1 ) -ksft_exit_fail_msg ("Write failed\n" ); -} -static void write_debugfs (const char *fmt, ...) {char input[INPUT_MAX ];
tools/testing/selftests/mm/thp_settings.c +3 -32
@@ -6,6 +6,7 @@#include <string.h> #include <unistd.h> +#include "vm_util.h" #include "thp_settings.h" #define THP_SYSFS "/sys/kernel/mm/transparent_hugepage/"
@@ -64,29 +65,6 @@ int read_file(const char *path, char *buf, size_t buflen)return (unsigned int ) numread; } -int write_file (const char *path,const char *buf,size_t buflen) -{ -int fd; -ssize_t numwritten; - - fd =open (path,O_WRONLY ); -if (fd ==-1 ) { -printf ("open(%s)\n" , path); -exit (EXIT_FAILURE ); -return 0 ; - } - - numwritten =write (fd, buf, buflen -1 ); -close (fd); -if (numwritten <1 ) { -printf ("write(%s)\n" , buf); -exit (EXIT_FAILURE ); -return 0 ; - } - -return (unsigned int ) numwritten; -} -unsigned long read_num (const char *path) {char buf[21 ];
@@ -104,10 +82,7 @@ void write_num(const char *path, unsigned long num)char buf[21 ];sprintf (buf,"%ld" , num); -if (!write_file (path, buf,strlen (buf) +1 )) { -perror (path); -exit (EXIT_FAILURE ); - } +write_file (path, buf,strlen (buf) +1 ); }int thp_read_string (const char *name,const char *const strings[])
@@ -165,11 +140,7 @@ void thp_write_string(const char *name, const char *val)printf ("%s: Pathname is too long\n" , __func__);exit (EXIT_FAILURE ); } - -if (!write_file (path, val,strlen (val) +1 )) { -perror (path); -exit (EXIT_FAILURE ); - } +write_file (path, val,strlen (val) +1 ); }unsigned long thp_read_num (const char *name)
tools/testing/selftests/mm/thp_settings.h +0 -1
@@ -63,7 +63,6 @@ struct thp_settings { };int read_file (const char *path,char *buf,size_t buflen); -int write_file (const char *path,const char *buf,size_t buflen);unsigned long read_num (const char *path);void write_num (const char *path,unsigned long num);
tools/testing/selftests/mm/vm_util.c +15 -0
@@ -764,3 +764,18 @@ int unpoison_memory(unsigned long pfn)return ret >0 ?0 : -errno; } + +void write_file (const char *path,const char *buf,size_t buflen) +{ +int fd; +ssize_t numwritten; + + fd =open (path,O_WRONLY ); +if (fd ==-1 ) +ksft_exit_fail_msg ("%s open failed: %s\n" , path,strerror (errno)); + + numwritten =write (fd, buf, buflen -1 ); +close (fd); +if (numwritten <1 ) +ksft_exit_fail_msg ("Write failed\n" ); +}
tools/testing/selftests/mm/vm_util.h +2 -0
@@ -166,3 +166,5 @@ int unpoison_memory(unsigned long pfn);#define PAGEMAP_PRESENT (ent) (((ent) & (1ull << 63)) != 0)#define PAGEMAP_PFN (ent) ((ent) & ((1ull << 55) - 1)) + +void write_file (const char *path,const char *buf,size_t buflen);
Signature · 1 line
2.53.0
PATCH v6 4/6 selftests/mm/vm_util: robust write_file()
In reply to Chunyu HuAdd two more checks for buflen and numwritten. The buflen should be at least one, otherwise the 'buflen - 1' could underflow and cause trouble. The numwritten should be equal to 'buflen - 1'. The test will exit if any of these conditions aren't met.
Additionally, add more print information when a write failure occurs or a truncated write happens, providing clearer diagnostics.
---
Changes in v6:
- save/restore errno before and after the close(), so the log could show the correct error info on failure. Suggested by AI.
Chagnes in v5:
- new patch for making improve on write_file. Add more safety checks and diagnostics info in log
--- tools/testing/selftests/mm/vm_util.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
tools/testing/selftests/mm/vm_util.c +10 -2
@@ -767,15 +767,23 @@ int unpoison_memory(unsigned long pfn)void write_file (const char *path,const char *buf,size_t buflen) { -int fd; +int fd, saved_errno;ssize_t numwritten; +if (buflen <1 ) +ksft_exit_fail_msg ("Incorrect buffer len: %zu\n" , buflen); fd =open (path,O_WRONLY );if (fd ==-1 )ksft_exit_fail_msg ("%s open failed: %s\n" , path,strerror (errno)); numwritten =write (fd, buf, buflen -1 ); + saved_errno = errno;close (fd); + errno = saved_errno;if (numwritten <1 ) -ksft_exit_fail_msg ("Write failed\n" ); +ksft_exit_fail_msg ("%s write(%s) failed: %s\n" , path, buf, +strerror (errno)); +if (numwritten != buflen -1 ) +ksft_exit_fail_msg ("%s write(%s) is truncated, expected %zu bytes, got %zd bytes\n" , + path, buf, buflen -1 , numwritten); }
Signature · 1 line
2.53.0
Andrew Morton
maintainerRe: [PATCH v6 4/6] selftests/mm/vm_util: robust write_file()
Quoted 7 lines · On Tue, 24 Mar 2026 09:33:14 +0800 Chunyu Hu <[email protected]> wrote:
Add two more checks for buflen and numwritten. The buflen should be at least one, otherwise the 'buflen - 1' could underflow and cause trouble. The numwritten should be equal to 'buflen - 1'. The test will exit if any of these conditions aren't met.
Additionally, add more print information when a write failure occurs or a truncated write happens, providing clearer diagnostics.
This one has no review and AI review did identify a kinda-bug. Maybe nobody calls write_file() with buflen==1, but still worth addressing I think.
https://sashiko.dev/#/patchset/20260324013316.2590422-1-chuhu%40redhat.com
Chunyu, could you please take a look?
Thanks.
Re: [PATCH v6 4/6] selftests/mm/vm_util: robust write_file()
Quoted 10 lines · Andrew Morton
Quoted 7 lines · On Tue, 24 Mar 2026 09:33:14 +0800 Chunyu Hu <[email protected]> wrote:
Add two more checks for buflen and numwritten. The buflen should be at least one, otherwise the 'buflen - 1' could underflow and cause trouble. The numwritten should be equal to 'buflen - 1'. The test will exit if any of these conditions aren't met.
Additionally, add more print information when a write failure occurs or a truncated write happens, providing clearer diagnostics.
Quoted 7 lines
This one has no review and AI review did identify a kinda-bug. Maybe nobody calls
write_file()with buflen==1, but still worth addressing I think.https://sashiko.dev/#/patchset/20260324013316.2590422-1-chuhu%40redhat.com
Chunyu, could you please take a look?
Andrew,
By limiting the buflen at least 2, it will avoid such an issue, this is also suggested by Lorenzo. I'll fix this in next version.
AI question about that we need to handle error path and trucate path (numwritten < 0) and (numwritten < buflen -1) seperately. That makes sense. I'll handle that in next version.
"""
tools/testing/selftests/mm/vm_util.c int unpoison_memory(unsigned long pfn) · line 789
Quoted 4 lines
tools/testing/selftests/mm/vm_util.c +3
-0+if (numwritten != buflen -1 ) +ksft_exit_fail_msg ("%s write(%s) is truncated, expected %zu bytes, got %zd bytes\n" , + path, buf, buflen -1 , numwritten); }
This isn't a bug, but the new error messages here and above use %s to format buf. Since the API requires an explicit buflen parameter and writes buflen - 1 bytes, does using %s risk out-of-bounds reads if a caller passes a buffer that is not null-terminated?
Would it be safer to use a precision specifier like %.*s and pass (int)(buflen - 1) as the length to safely print the exact contents intended to be written?
"""
That makes sense, I'll use %.*s instead for the buf print in next version.
Quoted 3 lines
Thanks.
Lorenzo Stoakes (Oracle)
reviewerRe: [PATCH v6 4/6] selftests/mm/vm_util: robust write_file()
In reply to Chunyu HuQuoted 25 lines · Chunyu Hu
Add two more checks for buflen and numwritten. The buflen should be at least one, otherwise the 'buflen - 1' could underflow and cause trouble. The numwritten should be equal to 'buflen - 1'. The test will exit if any of these conditions aren't met.
Additionally, add more print information when a write failure occurs or a truncated write happens, providing clearer diagnostics.
Signed-off-by Chunyu Hu <[email protected]>---
Changes in v6:
- save/restore errno before and after theclose(), so the log could show the correct error info on failure. Suggested by AI.
Chagnes in v5:
- new patch for making improve onwrite_file. Add more safety checks and diagnostics info in log--- tools/testing/selftests/mm/vm_util.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)tools/testing/selftests/mm/vm_util.c +0
-0
tools/testing/selftests/mm/vm_util.c int unpoison_memory(unsigned long pfn) · line 772
Quoted 7 lines
tools/testing/selftests/mm/vm_util.c +2
-1@@ -767,15 +767,23 @@ int unpoison_memory(unsigned long pfn)void write_file (const char *path,const char *buf,size_t buflen) { -int fd; +int fd, saved_errno;ssize_t numwritten; +if (buflen <1 )
As per Sashiko (presumably didn't look :P), let's make this < 2 since we write buflen - 1 bytes below which we don't ever want to be 0.
Quoted 21 lines
tools/testing/selftests/mm/vm_util.c +8
-2+ksft_exit_fail_msg ("Incorrect buffer len: %zu\n" , buflen); fd =open (path,O_WRONLY );if (fd ==-1 )ksft_exit_fail_msg ("%s open failed: %s\n" , path,strerror (errno)); numwritten =write (fd, buf, buflen -1 ); + saved_errno = errno;close (fd); + errno = saved_errno;if (numwritten <1 ) -ksft_exit_fail_msg ("Write failed\n" ); +ksft_exit_fail_msg ("%s write(%s) failed: %s\n" , path, buf, +strerror (errno)); +if (numwritten != buflen -1 ) +ksft_exit_fail_msg ("%s write(%s) is truncated, expected %zu bytes, got %zd bytes\n" , + path, buf, buflen -1 , numwritten); } --2.53.0
Re: [PATCH v6 4/6] selftests/mm/vm_util: robust write_file()
Quoted 27 lines · Lorenzo Stoakes (Oracle)
Quoted 26 lines · Chunyu Hu
Add two more checks for buflen and numwritten. The buflen should be at least one, otherwise the 'buflen - 1' could underflow and cause trouble. The numwritten should be equal to 'buflen - 1'. The test will exit if any of these conditions aren't met.
Additionally, add more print information when a write failure occurs or a truncated write happens, providing clearer diagnostics.
Signed-off-by Chunyu Hu <[email protected]>---
Changes in v6:
- save/restore errno before and after theclose(), so the log could show the correct error info on failure. Suggested by AI.
Chagnes in v5:
- new patch for making improve onwrite_file. Add more safety checks and diagnostics info in log--- tools/testing/selftests/mm/vm_util.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)tools/testing/selftests/mm/vm_util.c +0
-0@@ -767,15 +767,23 @@ int unpoison_memory(unsigned long pfn)
Quoted 9 lines
tools/testing/selftests/mm/vm_util.c int unpoison_memory(unsigned long pfn) · line 772
Quoted 6 lines
tools/testing/selftests/mm/vm_util.c +2
-1void write_file (const char *path,const char *buf,size_t buflen) { -int fd; +int fd, saved_errno;ssize_t numwritten; +if (buflen <1 )As per Sashiko (presumably didn't look :P), let's make this < 2 since we write buflen - 1 bytes below which we don't ever want to be 0.
That makes sense. Let me change to 2 in next version. Thanks!
Quoted 23 lines
Quoted 22 lines
tools/testing/selftests/mm/vm_util.c +8
-2+ksft_exit_fail_msg ("Incorrect buffer len: %zu\n" , buflen); fd =open (path,O_WRONLY );if (fd ==-1 )ksft_exit_fail_msg ("%s open failed: %s\n" , path,strerror (errno)); numwritten =write (fd, buf, buflen -1 ); + saved_errno = errno;close (fd); + errno = saved_errno;if (numwritten <1 ) -ksft_exit_fail_msg ("Write failed\n" ); +ksft_exit_fail_msg ("%s write(%s) failed: %s\n" , path, buf, +strerror (errno)); +if (numwritten != buflen -1 ) +ksft_exit_fail_msg ("%s write(%s) is truncated, expected %zu bytes, got %zd bytes\n" , + path, buf, buflen -1 , numwritten); } --2.53.0
Mike Rapoport
reviewerRe: [PATCH v6 4/6] selftests/mm/vm_util: robust write_file()
In reply to Chunyu HuQuoted 27 lines · Chunyu Hu
Add two more checks for buflen and numwritten. The buflen should be at least one, otherwise the 'buflen - 1' could underflow and cause trouble. The numwritten should be equal to 'buflen - 1'. The test will exit if any of these conditions aren't met.
Additionally, add more print information when a write failure occurs or a truncated write happens, providing clearer diagnostics.
Signed-off-by Chunyu Hu <[email protected]>---
Changes in v6:
- save/restore errno before and after theclose(), so the log could show the correct error info on failure. Suggested by AI.
Chagnes in v5:
- new patch for making improve onwrite_file. Add more safety checks and diagnostics info in log--- tools/testing/selftests/mm/vm_util.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)tools/testing/selftests/mm/vm_util.c +0
-0@@ -767,15 +767,23 @@ int unpoison_memory(unsigned long pfn)void write_file (const char *path,const char *buf,size_t buflen)
tools/testing/selftests/mm/vm_util.c int unpoison_memory(unsigned long pfn) · line 777
Quoted 10 lines
tools/testing/selftests/mm/vm_util.c +3
-1{ -int fd; +int fd, saved_errno;ssize_t numwritten; +if (buflen <1 ) +ksft_exit_fail_msg ("Incorrect buffer len: %zu\n" , buflen); fd =open (path,O_WRONLY );if (fd ==-1 )ksft_exit_fail_msg ("%s open failed: %s\n" , path,strerror (errno));
We have ksft_exit_fail_perror(), fits great here
tools/testing/selftests/mm/vm_util.c int unpoison_memory(unsigned long pfn) · line 785
Quoted 9 lines
tools/testing/selftests/mm/vm_util.c +4
-1numwritten =write (fd, buf, buflen -1 ); + saved_errno = errno;close (fd); + errno = saved_errno;if (numwritten <1 ) -ksft_exit_fail_msg ("Write failed\n" ); +ksft_exit_fail_msg ("%s write(%s) failed: %s\n" , path, buf, +strerror (errno));
and here.
Quoted 7 lines
tools/testing/selftests/mm/vm_util.c +3
-0+if (numwritten != buflen -1 ) +ksft_exit_fail_msg ("%s write(%s) is truncated, expected %zu bytes, got %zd bytes\n" , + path, buf, buflen -1 , numwritten); }Signature · 1 line
2.53.0
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v6 4/6] selftests/mm/vm_util: robust write_file()
Quoted 35 lines · Mike Rapoport
Quoted 34 lines · Chunyu Hu
Add two more checks for buflen and numwritten. The buflen should be at least one, otherwise the 'buflen - 1' could underflow and cause trouble. The numwritten should be equal to 'buflen - 1'. The test will exit if any of these conditions aren't met.
Additionally, add more print information when a write failure occurs or a truncated write happens, providing clearer diagnostics.
Signed-off-by Chunyu Hu <[email protected]>---
Changes in v6:
- save/restore errno before and after theclose(), so the log could show the correct error info on failure. Suggested by AI.
Chagnes in v5:
- new patch for making improve onwrite_file. Add more safety checks and diagnostics info in log--- tools/testing/selftests/mm/vm_util.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)tools/testing/selftests/mm/vm_util.c +3
-1@@ -767,15 +767,23 @@ int unpoison_memory(unsigned long pfn)void write_file (const char *path,const char *buf,size_t buflen) { -int fd; +int fd, saved_errno;ssize_t numwritten; +if (buflen <1 ) +ksft_exit_fail_msg ("Incorrect buffer len: %zu\n" , buflen);
Quoted 5 lines
tools/testing/selftests/mm/vm_util.c int unpoison_memory(unsigned long pfn) · line 777
Quoted 3 lines
tools/testing/selftests/mm/vm_util.c +0
-0fd =open (path,O_WRONLY );if (fd ==-1 )ksft_exit_fail_msg ("%s open failed: %s\n" , path,strerror (errno));We have
ksft_exit_fail_perror(), fits great here
the ksft_exit_fail_perror() don't accept the fmt string, it only accept a single string as parameter.
``` static inline __noreturn void ksft_exit_fail_perror(const char *msg) ```
But we can change it also support va_list arg like ksft_exit_fail_msg(msg, ...) does:
static inline __noreturn void ksft_exit_fail_perror(msg, ...)
I can have a try in next version.
Quoted 12 lines
tools/testing/selftests/mm/vm_util.c int unpoison_memory(unsigned long pfn) · line 785
Quoted 10 lines
tools/testing/selftests/mm/vm_util.c +4
-1numwritten =write (fd, buf, buflen -1 ); + saved_errno = errno;close (fd); + errno = saved_errno;if (numwritten <1 ) -ksft_exit_fail_msg ("Write failed\n" ); +ksft_exit_fail_msg ("%s write(%s) failed: %s\n" , path, buf, +strerror (errno));and here.
Same answer with above coment.
Quoted 13 lines
Quoted 8 lines
tools/testing/selftests/mm/vm_util.c +3
-0+if (numwritten != buflen -1 ) +ksft_exit_fail_msg ("%s write(%s) is truncated, expected %zu bytes, got %zd bytes\n" , + path, buf, buflen -1 , numwritten); }Signature · 1 line
2.53.0Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v6 4/6] selftests/mm/vm_util: robust write_file()
Quoted 50 lines · Chunyu Hu
Quoted 35 lines · Mike Rapoport
Quoted 34 lines · Chunyu Hu
Add two more checks for buflen and numwritten. The buflen should be at least one, otherwise the 'buflen - 1' could underflow and cause trouble. The numwritten should be equal to 'buflen - 1'. The test will exit if any of these conditions aren't met.
Additionally, add more print information when a write failure occurs or a truncated write happens, providing clearer diagnostics.
Signed-off-by Chunyu Hu <[email protected]>---
Changes in v6:
- save/restore errno before and after theclose(), so the log could show the correct error info on failure. Suggested by AI.
Chagnes in v5:
- new patch for making improve onwrite_file. Add more safety checks and diagnostics info in log--- tools/testing/selftests/mm/vm_util.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)tools/testing/selftests/mm/vm_util.c +3
-1@@ -767,15 +767,23 @@ int unpoison_memory(unsigned long pfn)void write_file (const char *path,const char *buf,size_t buflen) { -int fd; +int fd, saved_errno;ssize_t numwritten; +if (buflen <1 ) +ksft_exit_fail_msg ("Incorrect buffer len: %zu\n" , buflen);Quoted 5 lines
tools/testing/selftests/mm/vm_util.c int unpoison_memory(unsigned long pfn) · line 777
Quoted 3 lines
tools/testing/selftests/mm/vm_util.c +0
-0fd =open (path,O_WRONLY );if (fd ==-1 )ksft_exit_fail_msg ("%s open failed: %s\n" , path,strerror (errno));We have
ksft_exit_fail_perror(), fits great herethe
ksft_exit_fail_perror()don't accept the fmt string, it only accept a single string as parameter.``` static inline __noreturn void ksft_exit_fail_perror(const char *msg) ```
Quoted 6 lines
But we can change it also support
va_listarg likeksft_exit_fail_msg(msg, ...)does:static inline
__noreturnvoidksft_exit_fail_perror(msg, ...)I can have a try in next version.
Tried in v7.
In v7, I tried to change ksft_exit_fail_perror to support va_list args, and I used vasrpintf() to print the message to the buf and then pass it to ksft_exit_fail_msg(). But it requires _GNU_SOURCE can cause a build issue in mm-unstable tree from the kernel test robot report.
The vasprintf, the static buf[] (will trucate long message), or make a copy of body of the ksft_exit_fail_msg and append a perror string, none of these ways is clean, using ksft_exit_fail_msg may be still a better way.
What do you think, Mike?
Quoted 30 lines
Quoted 13 lines
tools/testing/selftests/mm/vm_util.c int unpoison_memory(unsigned long pfn) · line 785
Quoted 11 lines
tools/testing/selftests/mm/vm_util.c +4
-1numwritten =write (fd, buf, buflen -1 ); + saved_errno = errno;close (fd); + errno = saved_errno;if (numwritten <1 ) -ksft_exit_fail_msg ("Write failed\n" ); +ksft_exit_fail_msg ("%s write(%s) failed: %s\n" , path, buf, +strerror (errno));and here.
Same answer with above coment.
Quoted 13 lines
Quoted 8 lines
tools/testing/selftests/mm/vm_util.c +3
-0+if (numwritten != buflen -1 ) +ksft_exit_fail_msg ("%s write(%s) is truncated, expected %zu bytes, got %zd bytes\n" , + path, buf, buflen -1 , numwritten); }Signature · 1 line
2.53.0Signature · 2 lines
Sincerely yours, Mike.
PATCH v6 5/6 selftests/mm: split_huge_page_test: skip the test when thp is not available
In reply to Chunyu HuWhen thp is not enabled on some kernel config such as realtime kernel, the test will report failure. Fix the false positive by skipping the test directly when thp is not enabled.
Tested with thp disabled kernel:
Before The fix:
# --------------------------------------------------
# running ./split_huge_page_test /tmp/xfs_dir_Ywup9p # -------------------------------------------------- # TAP version 13 # Bail out! Reading PMD pagesize failed # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0 # [FAIL] not ok 61 split_huge_page_test /tmp/xfs_dir_Ywup9p # exit=1
After the fix:
# --------------------------------------------------
# running ./split_huge_page_test /tmp/xfs_dir_YHPUPl # -------------------------------------------------- # TAP version 13 # 1..0 # SKIP Transparent Hugepages not available # [SKIP] ok 6 split_huge_page_test /tmp/xfs_dir_YHPUPl # SKIP
---
V3 chagnes:
- add acked-by from David
- add reviewed by from Mike
V2 changes:
- removed the {} in if block
- removed the write_file helper rename chunk, as there's a new patch 3 to resolve the conflict with thp_settings.h by moving it to vm_util.
- Add reviewed by from Zi and Lorenzo
--- tools/testing/selftests/mm/split_huge_page_test.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/mm/split_huge_page_test.c +4 -0
@@ -21,6 +21,7 @@#include <time.h> #include "vm_util.h" #include "kselftest.h" +#include "thp_settings.h" uint64_t pagesize;unsigned int pageshift;
@@ -757,6 +758,9 @@ int main(int argc, char **argv)ksft_finished (); } +if (!thp_is_enabled ()) +ksft_exit_skip ("Transparent Hugepages not available\n" ); +if (argc >1 ) optional_xfs_path = argv[1 ];
Signature · 1 line
2.53.0
PATCH v6 6/6 selftests/mm: transhuge_stress: skip the test when thp not available
In reply to Chunyu HuThe test requires thp, skip the test when thp is not available to avoid false positive.
Tested with thp disabled kernel.
Before the fix:
# --------------------------------
# running ./transhuge-stress -d 20 # -------------------------------- # TAP version 13 # 1..1 # transhuge-stress: allocate 1453 transhuge pages, using 2907 MiB virtual memory and 11 MiB of ram # Bail out! MADV_HUGEPAGE# Planned tests != run tests (1 != 0) # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0 # [FAIL] not ok 60 transhuge-stress -d 20 # exit=1
After the fix:
# --------------------------------
# running ./transhuge-stress -d 20 # -------------------------------- # TAP version 13 # 1..0 # SKIP Transparent Hugepages not available # [SKIP] ok 5 transhuge-stress -d 20 # SKIP
---
V3 changes:
- Add review by from Mike
- Add acked-by from David
V2 changes:
- Move the exit chunk to the front of ksft_print_headers() as suggested by David.
- Add reviewed by from Zi and Lorenzo
--- tools/testing/selftests/mm/transhuge-stress.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/mm/transhuge-stress.c +4 -0
@@ -17,6 +17,7 @@#include <sys/mman.h> #include "vm_util.h" #include "kselftest.h" +#include "thp_settings.h" int backing_fd =-1 ;int mmap_flags =MAP_ANONYMOUS |MAP_NORESERVE |MAP_PRIVATE ;
@@ -37,6 +38,9 @@ int main(int argc, char **argv)ksft_print_header (); +if (!thp_is_enabled ()) +ksft_exit_skip ("Transparent Hugepages not available\n" ); + ram =sysconf (_SC_PHYS_PAGES);if (ram >SIZE_MAX /psize () /4 ) ram =SIZE_MAX /4 ;
Signature · 1 line
2.53.0
Andrew Morton
maintainerQuoted 3 lines · On Tue, 24 Mar 2026 09:33:10 +0800 Chunyu Hu <[email protected]> wrote:
There are several tests requires transprarent hugepages, when run on thp disabled kernel such as realtime kernel, there will be false negative. Mark those tests as skip when thp is not available.
Thanks, I updated mm.git's mm-unstable branch to this version.
Quoted 3 lines
Chagnes in v6:
- patch 3 add reviewed-by from Lorenzo
- patch 4 handle the errno before and afterclose(), suggested by AI
Here's how v6 altered mm.git:
tools/testing/selftests/mm/vm_util.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
tools/testing/selftests/mm/vm_util.c renamed from tools/testing/selftests/mm/vm_util.c~b +10 -2
@@ -785,15 +785,23 @@ int unpoison_memory(unsigned long pfn)void write_file (const char *path,const char *buf,size_t buflen) { -int fd; +int fd, saved_errno;ssize_t numwritten; +if (buflen <1 ) +ksft_exit_fail_msg ("Incorrect buffer len: %zu\n" , buflen); fd =open (path,O_WRONLY );if (fd ==-1 )ksft_exit_fail_msg ("%s open failed: %s\n" , path,strerror (errno)); numwritten =write (fd, buf, buflen -1 ); + saved_errno = errno;close (fd); + errno = saved_errno;if (numwritten <1 ) -ksft_exit_fail_msg ("Write failed\n" ); +ksft_exit_fail_msg ("%s write(%s) failed: %s\n" , path, buf, +strerror (errno)); +if (numwritten != buflen -1 ) +ksft_exit_fail_msg ("%s write(%s) is truncated, expected %zu bytes, got %zd bytes\n" , + path, buf, buflen -1 , numwritten); }
_
David Hildenbrand (Arm)
maintainerQuoted 21 lines · Andrew Morton
Quoted 3 lines · On Tue, 24 Mar 2026 09:33:10 +0800 Chunyu Hu <[email protected]> wrote:
There are several tests requires transprarent hugepages, when run on thp disabled kernel such as realtime kernel, there will be false negative. Mark those tests as skip when thp is not available.
Thanks, I updated mm.git's mm-unstable branch to this version.
Quoted 3 lines
Chagnes in v6:
- patch 3 add reviewed-by from Lorenzo
- patch 4 handle the errno before and afterclose(), suggested by AIHere's how v6 altered mm.git:
tools/testing/selftests/mm/vm_util.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
tools/testing/selftests/mm/vm_util.c int unpoison_memory(unsigned long pfn) · line 789
Quoted 6 lines
tools/testing/selftests/mm/vm_util.c renamed from tools/testing/selftests/mm/vm_util.c~b +1
-1@@ -785,15 +785,23 @@ int unpoison_memory(unsigned long pfn)void write_file (const char *path,const char *buf,size_t buflen) { -int fd; +int fd, saved_errno;ssize_t numwritten;
Empty line? :)
Quoted 2 lines
tools/testing/selftests/mm/vm_util.c renamed from tools/testing/selftests/mm/vm_util.c~b +2
-0+if (buflen <1 ) +ksft_exit_fail_msg ("Incorrect buffer len: %zu\n" , buflen);
Signature · 3 lines
Cheers, David
Quoted 23 lines · David Hildenbrand (Arm)
Quoted 22 lines · Andrew Morton
Quoted 3 lines · On Tue, 24 Mar 2026 09:33:10 +0800 Chunyu Hu <[email protected]> wrote:
There are several tests requires transprarent hugepages, when run on thp disabled kernel such as realtime kernel, there will be false negative. Mark those tests as skip when thp is not available.
Thanks, I updated mm.git's mm-unstable branch to this version.
Quoted 3 lines
Chagnes in v6:
- patch 3 add reviewed-by from Lorenzo
- patch 4 handle the errno before and afterclose(), suggested by AIHere's how v6 altered mm.git:
tools/testing/selftests/mm/vm_util.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)tools/testing/selftests/mm/vm_util.c renamed from tools/testing/selftests/mm/vm_util.c~b +0
-0@@ -785,15 +785,23 @@ int unpoison_memory(unsigned long pfn)
Quoted 7 lines
tools/testing/selftests/mm/vm_util.c int unpoison_memory(unsigned long pfn) · line 789
Quoted 5 lines
tools/testing/selftests/mm/vm_util.c renamed from tools/testing/selftests/mm/vm_util.c~b +1
-1void write_file (const char *path,const char *buf,size_t buflen) { -int fd; +int fd, saved_errno;ssize_t numwritten;Empty line? :)
Good catch. I will add one empty line in the next version. Thanks!
Quoted 9 lines
Quoted 3 lines
tools/testing/selftests/mm/vm_util.c renamed from tools/testing/selftests/mm/vm_util.c~b +2
-0+if (buflen <1 ) +ksft_exit_fail_msg ("Incorrect buffer len: %zu\n" , buflen);Signature · 3 lines
Cheers, David