selftests/mm: fix va_high_addr_switch.sh return value
Subsystems (3)
PATCH v2 1/5 selftests/mm: fix va_high_addr_switch.sh return value
Patch series "Fix va_high_addr_switch.sh test failure - again", v2.
The series address several issues exist for the va_high_addr_switch test:
1) the test return value is ignored in va_high_addr_switch.sh.
2) the va_high_addr_switch test requires 6 hugepages not 5.
3) the reurn value of the first test in va_high_addr_switch.c can be overridden by the second test.
4) the nr_hugepages setup in run_vmtests.sh for arm64 can be done in va_high_addr_switch.sh too.
5) update a comment for check_test_requirements.
Changes in v2:
- shorten the comment in for hugepages setup in v1
- add a new patch to fix the return value overridden issue in va_high_addr_switch.c
- fix a code comment for check_test_requirements.
- update the series summary in patch 1
- add reviewed-by from Luiz Capitulino on patch 1 and patch 3
This patch: (of 5)
The return value should be return value of va_high_addr_switch, otherwise a test failure would be silently ignored.
---
Chunyu Hu (5):
selftests/mm: fix va_high_addr_switch.sh return value selftests/mm: allocate 6 hugepages in va_high_addr_switch.sh selftests/mm: remove arm64 nr_hugepages setup for va_high_addr_switch
test
selftests/mm: va_high_addr_switch return fail when either test failed selftests/mm: fix comment for check_test_requirements
tools/testing/selftests/mm/run_vmtests.sh | 8 -------- tools/testing/selftests/mm/va_high_addr_switch.c | 10 +++++++--- tools/testing/selftests/mm/va_high_addr_switch.sh | 12 +++++++----- 3 files changed, 14 insertions(+), 16 deletions(-)
According to the doc below, I don't add the cover letter, not sure if cover letter is preferred, and if that's the case, the doc need an update.
https://www.ozlabs.org/~akpm/stuff/tpp.txt
--- tools/testing/selftests/mm/va_high_addr_switch.sh | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/mm/va_high_addr_switch.sh +2 -0
@@ -114,4 +114,6 @@ save_nr_hugepages # 4 keep_mapped pages, and one for tmp usage setup_nr_hugepages 5 ./va_high_addr_switch --run-hugetlb +retcode=$? restore_nr_hugepages +exit $retcode
Signature · 1 line
2.49.0
PATCH v2 2/5 selftests/mm: allocate 6 hugepages in va_high_addr_switch.sh
The va_high_addr_switch test requires 6 hugepages, not 5. If running the test directly by: ./va_high_addr_switch.sh, the test will hit a mmap 'FAIL' caused by not enough hugepages:
``` mmap(addr_switch_hint - hugepagesize, 2*hugepagesize, MAP_HUGETLB): 0x7f330f800000 - OK mmap(addr_switch_hint , 2*hugepagesize, MAP_FIXED | MAP_HUGETLB): 0xffffffffffffffff - FAILED ```
The failure can't be hit if run the tests by running 'run_vmtests.sh -t hugevm' because the nr_hugepages is set to 128 at the beginning of run_vmtests.sh and va_high_addr_switch.sh skip the setup of nr_hugepages because already enough.
--- tools/testing/selftests/mm/va_high_addr_switch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/mm/va_high_addr_switch.sh +2 -2
@@ -111,8 +111,8 @@ setup_nr_hugepages() check_test_requirements save_nr_hugepages -# 4 keep_mapped pages, and one for tmp usage -setup_nr_hugepages 5 +# The HugeTLB tests require 6 pages +setup_nr_hugepages 6 ./va_high_addr_switch --run-hugetlb retcode=$? restore_nr_hugepages
Signature · 1 line
2.49.0
PATCH v2 3/5 selftests/mm: remove arm64 nr_hugepages setup for va_high_addr_switch test
arm64 and x86_64 has the same nr_hugepages requriement for running the va_high_addr_switch test. Since commit d9d957bd7b61 ("selftests/mm: alloc hugepages in va_high_addr_switch test"), the setup can be done in va_high_addr_switch.sh. So remove the duplicated setup.
--- tools/testing/selftests/mm/run_vmtests.sh | 8 -------- 1 file changed, 8 deletions(-)
tools/testing/selftests/mm/run_vmtests.sh +0 -8
@@ -412,15 +412,7 @@ if [ $VADDR64 -ne 0 ]; then fi # va high address boundary switch test - ARCH_ARM64="arm64" - prev_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages) - if [ "$ARCH" == "$ARCH_ARM64" ]; then - echo 6 > /proc/sys/vm/nr_hugepages - fi CATEGORY="hugevm" run_test bash ./va_high_addr_switch.sh - if [ "$ARCH" == "$ARCH_ARM64" ]; then - echo $prev_nr_hugepages > /proc/sys/vm/nr_hugepages - fi fi # VADDR64 # vmalloc stability smoke test
Signature · 1 line
2.49.0
PATCH v2 4/5 selftests/mm: va_high_addr_switch return fail when either test failed
When the first test failed, and the hugetlb test passed, the result would be pass, but we expect a fail. Fix this issue by returning fail if either is not KSFT_PASS.
--- tools/testing/selftests/mm/va_high_addr_switch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
tools/testing/selftests/mm/va_high_addr_switch.c +7 -3
@@ -322,7 +322,7 @@ static int supported_arch(void)int main (int argc,char **argv) { -int ret; +int ret, hugetlb_ret =KSFT_PASS ;if (!supported_arch ())return KSFT_SKIP ;
@@ -331,6 +331,10 @@ int main(int argc, char **argv) ret =run_test (testcases, sz_testcases);if (argc ==2 && !strcmp (argv[1 ],"--run-hugetlb" )) - ret =run_test (hugetlb_testcases, sz_hugetlb_testcases); -return ret; + hugetlb_ret =run_test (hugetlb_testcases, sz_hugetlb_testcases); + +if (ret ==KSFT_PASS && hugetlb_ret ==KSFT_PASS ) +return KSFT_PASS ; +else +return KSFT_FAIL ; }
Signature · 1 line
2.49.0
PATCH v2 5/5 selftests/mm: fix comment for check_test_requirements
The test supports arm64 as well so the comment is incorrect. And there's a check for arm64 in va_high_addr_switch.c.
--- tools/testing/selftests/mm/va_high_addr_switch.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/mm/va_high_addr_switch.sh +3 -3
@@ -61,9 +61,9 @@ check_supported_ppc64() check_test_requirements() { - # The test supports x86_64 and powerpc64. We currently have no useful - # eligibility check for powerpc64, and the test itself will reject other - # architectures. + # The test supports x86_64, powerpc64 and arm64. There's check for arm64 + # in va_high_addr_switch.c. The test itself will reject other architectures. + case `uname -m` in "x86_64") check_supported_x86_64
Signature · 1 line
2.49.0
Re: [PATCH v2 5/5] selftests/mm: fix comment for check_test_requirements
Quoted 7 lines · Chunyu Hu
The test supports arm64 as well so the comment is incorrect. And there's a check for arm64 in
va_high_addr_switch.c.CC Luiz Capitulino <[email protected]>Fixes 983e760bcdb6 ("selftest/mm: va_high_addr_switch: add ppc64 support check")Fixes f556acc2facd ("selftests/mm: skip test for non-LPA2 and non-LVA systems")Signed-off-by Chunyu Hu <[email protected]>
Quoted 21 lines
--- tools/testing/selftests/mm/va_high_addr_switch.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)tools/testing/selftests/mm/va_high_addr_switch.sh +3
-3@@ -61,9 +61,9 @@ check_supported_ppc64() check_test_requirements() { - # The test supports x86_64 and powerpc64. We currently have no useful - # eligibility check for powerpc64, and the test itself will reject other - # architectures. + # The test supports x86_64, powerpc64 and arm64. There's check for arm64 + # in va_high_addr_switch.c. The test itself will reject other architectures. + case `uname -m` in "x86_64") check_supported_x86_64
Re: [PATCH v2 4/5] selftests/mm: va_high_addr_switch return fail when either test failed
In reply to Chunyu HuQuoted 24 lines · Chunyu Hu
When the first test failed, and the hugetlb test passed, the result would be pass, but we expect a fail. Fix this issue by returning fail if either is not
KSFT_PASS.CC Luiz Capitulino <[email protected]>Signed-off-by Chunyu Hu <[email protected]>--- tools/testing/selftests/mm/va_high_addr_switch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)tools/testing/selftests/mm/va_high_addr_switch.c +1
-1@@ -322,7 +322,7 @@ static int supported_arch(void)int main (int argc,char **argv) { -int ret; +int ret, hugetlb_ret =KSFT_PASS ;if (!supported_arch ())return KSFT_SKIP ;
tools/testing/selftests/mm/va_high_addr_switch.c int main(int argc, char **argv) · line 334
Quoted 4 lines
tools/testing/selftests/mm/va_high_addr_switch.c +0
-1@@ -331,6 +331,10 @@ int main(int argc, char **argv) ret =run_test (testcases, sz_testcases);if (argc ==2 && !strcmp (argv[1 ],"--run-hugetlb" )) - ret =run_test (hugetlb_testcases, sz_hugetlb_testcases);
Maybe you could just have used:
ret |= run_test(hugetlb_testcases, sz_hugetlb_testcases);
But anyways, as this is just testing code:
Quoted 8 lines
tools/testing/selftests/mm/va_high_addr_switch.c +6
-1-return ret; + hugetlb_ret =run_test (hugetlb_testcases, sz_hugetlb_testcases); + +if (ret ==KSFT_PASS && hugetlb_ret ==KSFT_PASS ) +return KSFT_PASS ; +else +return KSFT_FAIL ; }
Re: [PATCH v2 4/5] selftests/mm: va_high_addr_switch return fail when either test failed
Quoted 29 lines · Luiz Capitulino
Quoted 22 lines · Chunyu Hu
When the first test failed, and the hugetlb test passed, the result would be pass, but we expect a fail. Fix this issue by returning fail if either is not
KSFT_PASS.CC Luiz Capitulino <[email protected]>Signed-off-by Chunyu Hu <[email protected]>--- tools/testing/selftests/mm/va_high_addr_switch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)tools/testing/selftests/mm/va_high_addr_switch.c +1
-1@@ -322,7 +322,7 @@ static int supported_arch(void)int main (int argc,char **argv) { -int ret; +int ret, hugetlb_ret =KSFT_PASS ;if (!supported_arch ())return KSFT_SKIP ;tools/testing/selftests/mm/va_high_addr_switch.c int main(int argc, char **argv) · line 333
Quoted 3 lines
tools/testing/selftests/mm/va_high_addr_switch.c +0
-1@@ -331,6 +331,10 @@ int main(int argc, char **argv) ret =run_test (testcases, sz_testcases);if (argc ==2 && !strcmp (argv[1 ],"--run-hugetlb" )) - ret =run_test (hugetlb_testcases, sz_hugetlb_testcases);Maybe you could just have used:
Quoted 1 line
ret |= run_test(hugetlb_testcases, sz_hugetlb_testcases);
Good point. I thought the result code is not encoded by bit, but for KSFT_PASS and KSFT_FAIL, and KSFT_SKIP, they are per bit.
85 #define KSFT_PASS 0
86 #define KSFT_FAIL 1
87 #define KSFT_XFAIL 2
88 #define KSFT_XPASS 3
89 #define KSFT_SKIP 4
@Andrew, do you think I need to send a v3 for using the simpified way? if so, send the whole series or the single patch?
Quoted 14 lines
But anyways, as this is just testing code:
Reviewed-by Luiz Capitulino <[email protected]>Quoted 8 lines
tools/testing/selftests/mm/va_high_addr_switch.c +6
-1-return ret; + hugetlb_ret =run_test (hugetlb_testcases, sz_hugetlb_testcases); + +if (ret ==KSFT_PASS && hugetlb_ret ==KSFT_PASS ) +return KSFT_PASS ; +else +return KSFT_FAIL ; }
Andrew Morton
maintainerRe: [PATCH v2 4/5] selftests/mm: va_high_addr_switch return fail when either test failed
Quoted 18 lines · On Tue, 23 Dec 2025 10:46:18 +0800 Chunyu Hu <[email protected]> wrote:
Quoted 13 lines
tools/testing/selftests/mm/va_high_addr_switch.c int main(int argc, char **argv) · line 333
Quoted 10 lines
int main(int argc, char **argv) {tools/testing/selftests/mm/va_high_addr_switch.c +1
-2-int ret; +int ret, hugetlb_ret =KSFT_PASS ;if (!supported_arch ())return KSFT_SKIP ;@@ -331,6 +331,10 @@ int main(int argc, char **argv) ret =run_test (testcases, sz_testcases);if (argc ==2 && !strcmp (argv[1 ],"--run-hugetlb" )) - ret =run_test (hugetlb_testcases, sz_hugetlb_testcases);Maybe you could just have used:
Quoted 1 line
ret |= run_test(hugetlb_testcases, sz_hugetlb_testcases);Good point. I thought the result code is not encoded by bit, but for
KSFT_PASSandKSFT_FAIL, andKSFT_SKIP, they are per bit.
Quoted 8 lines
85 #define
KSFT_PASS0
86 #defineKSFT_FAIL1
87 #defineKSFT_XFAIL2
88 #defineKSFT_XPASS3
89 #defineKSFT_SKIP4@Andrew, do you think I need to send a v3 for using the simpified way? if so, send the whole series or the single patch?
Leave it as it is? This thing isn't a bitfield, so using |= happens to work thanks to good luck.
Re: [PATCH v2 4/5] selftests/mm: va_high_addr_switch return fail when either test failed
Quoted 26 lines · Andrew Morton
Quoted 24 lines · On Tue, 23 Dec 2025 10:46:18 +0800 Chunyu Hu <[email protected]> wrote:
Quoted 13 lines
tools/testing/selftests/mm/va_high_addr_switch.c int main(int argc, char **argv) · line 333
Quoted 10 lines
int main(int argc, char **argv) {tools/testing/selftests/mm/va_high_addr_switch.c +1
-2-int ret; +int ret, hugetlb_ret =KSFT_PASS ;if (!supported_arch ())return KSFT_SKIP ;@@ -331,6 +331,10 @@ int main(int argc, char **argv) ret =run_test (testcases, sz_testcases);if (argc ==2 && !strcmp (argv[1 ],"--run-hugetlb" )) - ret =run_test (hugetlb_testcases, sz_hugetlb_testcases);Maybe you could just have used:
Quoted 1 line
ret |= run_test(hugetlb_testcases, sz_hugetlb_testcases);Good point. I thought the result code is not encoded by bit, but for
KSFT_PASSandKSFT_FAIL, andKSFT_SKIP, they are per bit.85 #define
KSFT_PASS0
86 #defineKSFT_FAIL1
87 #defineKSFT_XFAIL2
88 #defineKSFT_XPASS3
89 #defineKSFT_SKIP4
Quoted 5 lines
Quoted 2 lines
@Andrew, do you think I need to send a v3 for using the simpified way? if so, send the whole series or the single patch?
Leave it as it is? This thing isn't a bitfield, so using |= happens to work thanks to good luck.
It works for me. Thanks.
Quoted 1 line
Re: [PATCH v2 2/5] selftests/mm: allocate 6 hugepages in va_high_addr_switch.sh
In reply to Chunyu HuQuoted 11 lines · Chunyu Hu
The
va_high_addr_switchtest requires 6 hugepages, not 5. If running the test directly by: ./va_high_addr_switch.sh, the test will hit a mmap 'FAIL' caused by not enough hugepages:``` mmap(addr_switch_hint - hugepagesize, 2*hugepagesize, MAP_HUGETLB): 0x7f330f800000 - OK mmap(addr_switch_hint , 2*hugepagesize, MAP_FIXED | MAP_HUGETLB): 0xffffffffffffffff - FAILED ```The failure can't be hit if run the tests by running '
run_vmtests.sh-t hugevm' because thenr_hugepagesis set to 128 at the beginning ofrun_vmtests.shandva_high_addr_switch.shskip the setup ofnr_hugepagesbecause already enough.
Quoted 23 lines
CC Luiz Capitulino <[email protected]>Fixes d9d957bd7b61 ("selftests/mm: alloc hugepages in va_high_addr_switch test")Signed-off-by Chunyu Hu <[email protected]>--- tools/testing/selftests/mm/va_high_addr_switch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/testing/selftests/mm/va_high_addr_switch.sh +2
-2@@ -111,8 +111,8 @@ setup_nr_hugepages() check_test_requirements save_nr_hugepages -# 4 keep_mapped pages, and one for tmp usage -setup_nr_hugepages 5 +# The HugeTLB tests require 6 pages +setup_nr_hugepages 6 ./va_high_addr_switch --run-hugetlb retcode=$? restore_nr_hugepages
Andrew Morton
maintainerQuoted 11 lines · On Sun, 21 Dec 2025 12:00:21 +0800 Chunyu Hu <[email protected]> wrote:
Patch series "Fix
va_high_addr_switch.shtest failure - again", v2.The series address several issues exist for the
va_high_addr_switchtest:
1) the test return value is ignored inva_high_addr_switch.sh.
2) theva_high_addr_switchtest requires 6 hugepages not 5.
3) the reurn value of the first test inva_high_addr_switch.ccan be overridden by the second test.
4) thenr_hugepagessetup inrun_vmtests.shfor arm64 can be done inva_high_addr_switch.shtoo.
5) update a comment forcheck_test_requirements.
Quoted 7 lines
Changes in v2:
- shorten the comment in for hugepages setup in v1
- add a new patch to fix the return value overridden issue inva_high_addr_switch.c
- fix a code comment forcheck_test_requirements.
- update the series summary in patch 1
- add reviewed-by from Luiz Capitulino on patch 1 and patch 3
The "Changes in v2" material is best placed below the "---" separator - I prefer not to capture such short-term development-time info within the permanent kernel record.
Quoted 10 lines
This patch: (of 5)
The return value should be return value of
va_high_addr_switch, otherwise a test failure would be silently ignored.Reviewed-by Luiz Capitulino <[email protected]>Fixes d9d957bd7b61 ("selftests/mm: alloc hugepages in va_high_addr_switch test")CC Luiz Capitulino <[email protected]>Signed-off-by Chunyu Hu <[email protected]>
Quoted 4 lines
...
According to the doc below, I don't add the cover letter, not sure if cover letter is preferred, and if that's the case, the doc need an update.
Funnily enough, your series was in the exact format which I use when committing patch series. Usually people put the cover letter in a separate [0/N] email and I move that into the [1/N] patch's changelog, as you've done here.
Quoted 1 line
God does that still exist? Pretty soon it will be able to legally drink in bars.
I think its content got absorbed into a Documentation/ file a long time ago!
Quoted 21 lines · Andrew Morton
Quoted 11 lines · On Sun, 21 Dec 2025 12:00:21 +0800 Chunyu Hu <[email protected]> wrote:
Patch series "Fix
va_high_addr_switch.shtest failure - again", v2.The series address several issues exist for the
va_high_addr_switchtest:
1) the test return value is ignored inva_high_addr_switch.sh.
2) theva_high_addr_switchtest requires 6 hugepages not 5.
3) the reurn value of the first test inva_high_addr_switch.ccan be overridden by the second test.
4) thenr_hugepagessetup inrun_vmtests.shfor arm64 can be done inva_high_addr_switch.shtoo.
5) update a comment forcheck_test_requirements.Quoted 7 lines
Changes in v2:
- shorten the comment in for hugepages setup in v1
- add a new patch to fix the return value overridden issue inva_high_addr_switch.c
- fix a code comment forcheck_test_requirements.
- update the series summary in patch 1
- add reviewed-by from Luiz Capitulino on patch 1 and patch 3
Quoted 3 lines
The "Changes in v2" material is best placed below the "---" separator - I prefer not to capture such short-term development-time info within the permanent kernel record.
That makes sense.
Quoted 13 lines
Quoted 13 lines
This patch: (of 5)
The return value should be return value of
va_high_addr_switch, otherwise a test failure would be silently ignored.Reviewed-by Luiz Capitulino <[email protected]>Fixes d9d957bd7b61 ("selftests/mm: alloc hugepages in va_high_addr_switch test")CC Luiz Capitulino <[email protected]>Signed-off-by Chunyu Hu <[email protected]>...
Quoted 7 lines
Quoted 2 lines
According to the doc below, I don't add the cover letter, not sure if cover letter is preferred, and if that's the case, the doc need an update.
Funnily enough, your series was in the exact format which I use when committing patch series. Usually people put the cover letter in a separate [0/N] email and I move that into the [1/N] patch's changelog, as you've done here.
yes, I see cover-letter is the actualy way people is using and looks like I did some of your work putting that cover letter into the first patch. I think I'll add cover-letter in the future.
Quoted 8 lines
Quoted 2 lines
God does that still exist? Pretty soon it will be able to legally drink in bars.
I think its content got absorbed into a
Documentation/file a long time ago!
I happened to open it before I submitting my patch, and wanted to know what would happen if I follow that. And it looks like cover letter has become the actual convention.
Quoted 2 lines
Quoted 2 lines · On Mon, 22 Dec 2025 12:32:16 +0800 Chunyu Hu <[email protected]> wrote:
Quoted 1 line · Andrew Morton
On Sun, 21 Dec 2025 12:00:21 +0800 Chunyu Hu <[email protected]> wrote:
[...]
Quoted 19 lines
Quoted 7 lines
Quoted 2 lines
According to the doc below, I don't add the cover letter, not sure if cover letter is preferred, and if that's the case, the doc need an update.
Funnily enough, your series was in the exact format which I use when committing patch series. Usually people put the cover letter in a separate [0/N] email and I move that into the [1/N] patch's changelog, as you've done here.
yes, I see cover-letter is the actualy way people is using and looks like I did some of your work putting that cover letter into the first patch. I think I'll add cover-letter in the future.
Quoted 6 lines
Quoted 2 lines
God does that still exist? Pretty soon it will be able to legally drink in bars.
Quoted 6 lines
Quoted 2 lines
I think its content got absorbed into a
Documentation/file a long time ago!I happened to open it before I submitting my patch, and wanted to know what would happen if I follow that. And it looks like cover letter has become the actual convention.
I think you could useDocumentation/process/submitting-patches.rst instead. The html version is also available at
https://origin.kernel.org/doc/html/latest/process/submitting-patches.html
Thanks,
SJ
[...]
Quoted 27 lines · SeongJae Park
Quoted 2 lines · On Mon, 22 Dec 2025 12:32:16 +0800 Chunyu Hu <[email protected]> wrote:
Quoted 1 line · Andrew Morton
On Sun, 21 Dec 2025 12:00:21 +0800 Chunyu Hu <[email protected]> wrote:
[...]
Quoted 22 lines
Quoted 7 lines
Quoted 2 lines
According to the doc below, I don't add the cover letter, not sure if cover letter is preferred, and if that's the case, the doc need an update.
Funnily enough, your series was in the exact format which I use when committing patch series. Usually people put the cover letter in a separate [0/N] email and I move that into the [1/N] patch's changelog, as you've done here.
yes, I see cover-letter is the actualy way people is using and looks like I did some of your work putting that cover letter into the first patch. I think I'll add cover-letter in the future.
Quoted 8 lines
Quoted 2 lines
God does that still exist? Pretty soon it will be able to legally drink in bars.
I think its content got absorbed into a
Documentation/file a long time ago!
Quoted 8 lines
Quoted 3 lines
I happened to open it before I submitting my patch, and wanted to know what would happen if I follow that. And it looks like cover letter has become the actual convention.
I think you could use
Documentation/process/submitting-patches.rstinstead. The html version is also available at
https://origin.kernel.org/doc/html/latest/process/submitting-patches.html
Thanks! Sure. I'll use that. I know this doc, it's where I find the tpp.txt in the 'References' section.
Quoted 7 lines
Thanks,
SJ[...]