selftests: arm64: vec-syscfg updates
cover selftests: arm64: vec-syscfg updates
This series fixes up a few issues introduced into vec-syscfg during refactoring in the review process, then adds a new test which ensures that the behaviour when we attempt to set a vector length which is not supported by the current system matches what is documented in the SVE ABI documentation.
Mark Brown (4):
selftests: arm64: Fix printf() format mismatch in vec-syscfg
selftests: arm64: Remove bogus error check on writing to files
selftests: arm64: Fix and enable test for setting current VL in
vec-syscfg
selftests: arm64: Verify that all possible vector lengths are handled
tools/testing/selftests/arm64/fp/vec-syscfg.c | 94 ++++++++++++++++--- 1 file changed, 81 insertions(+), 13 deletions(-)
base-commit: 6880fa6c56601bb8ed59df6c30fd390cc5f6dd8f
Signature · 1 line
2.20.1
PATCH 1/4 selftests: arm64: Fix printf() format mismatch in vec-syscfg
The format for this error message calls for the plain text version of the error but we weren't supply it.
--- tools/testing/selftests/arm64/fp/vec-syscfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/arm64/fp/vec-syscfg.c +1 -1
@@ -109,7 +109,7 @@ static int get_child_rdvl(struct vec_data *data)/* exec() a new binary which puts the VL on stdout */ ret =execl (data->rdvl_binary, data->rdvl_binary,NULL ); -fprintf (stderr,"execl(%s) failed: %d\n" , +fprintf (stderr,"execl(%s) failed: %d (%s)\n" , data->rdvl_binary, errno,strerror (errno));exit (EXIT_FAILURE );
Signature · 1 line
2.20.1
PATCH 2/4 selftests: arm64: Remove bogus error check on writing to files
In reply to Mark BrownDue to some refactoring with the error handling we ended up mangling things so we never actually set ret and therefore shouldn't be checking it.
--- tools/testing/selftests/arm64/fp/vec-syscfg.c | 6 ------ 1 file changed, 6 deletions(-)
tools/testing/selftests/arm64/fp/vec-syscfg.c +0 -6
@@ -180,7 +180,6 @@ static int file_read_integer(const char *name, int *val)static int file_write_integer (const char *name,int val) {FILE *f; -int ret; f =fopen (name,"w" );if (!f) {
@@ -192,11 +191,6 @@ static int file_write_integer(const char *name, int val)fprintf (f,"%d" , val);fclose (f); -if (ret <0 ) { -ksft_test_result_fail ("Error writing %d to %s\n" , - val, name); -return -1 ; - }return 0 ; }
Signature · 1 line
2.20.1
PATCH 3/4 selftests: arm64: Fix and enable test for setting current VL in vec-syscfg
In reply to Mark BrownWe had some test code for verifying that we can write the current VL via the prctl() interface but the condition for the test was inverted which wasn't noticed as it was never actually hooked up to the array of tests we execute. Fix this.
--- tools/testing/selftests/arm64/fp/vec-syscfg.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
tools/testing/selftests/arm64/fp/vec-syscfg.c +4 -6
@@ -329,12 +329,9 @@ static void prctl_set_same(struct vec_data *data)return ; } -if (cur_vl != data->rdvl ()) -ksft_test_result_pass ("%s current VL is %d\n" , - data->name, ret); -else -ksft_test_result_fail ("%s prctl() VL %d but RDVL is %d\n" , - data->name, ret, data->rdvl ()); +ksft_test_result (cur_vl == data->rdvl (), +"%s set VL %d and have VL %d\n" , + data->name, cur_vl, data->rdvl ()); }/* Can we set a new VL for this process? */
@@ -555,6 +552,7 @@ static const test_type tests[] = { proc_write_max, prctl_get, + prctl_set_same, prctl_set, prctl_set_no_child, prctl_set_for_child,
Signature · 1 line
2.20.1
PATCH 4/4 selftests: arm64: Verify that all possible vector lengths are handled
In reply to Mark BrownAs part of the enumeration interface for setting vector lengths it is valid to set vector lengths not supported in the system, these will be rounded to a supported vector length and returned from the prctl(). Add a test which exercises this for every valid vector length and makes sure that the return value is as expected and that this is reflected in the actual system state.
--- tools/testing/selftests/arm64/fp/vec-syscfg.c | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+)
tools/testing/selftests/arm64/fp/vec-syscfg.c +76 -0
@@ -540,6 +540,81 @@ static void prctl_set_onexec(struct vec_data *data)file_write_integer (data->default_vl_file, data->default_vl); } +/* For each VQ verify that setting via prctl() does the right thing */ +static void prctl_set_all_vqs (struct vec_data *data) +{ +int ret, vq, vl, new_vl; +int errors =0 ; + +for (vq =SVE_VQ_MIN ; vq <=SVE_VQ_MAX ; vq++) { + vl =sve_vl_from_vq (vq); + +/* Attempt to set the VL */ + ret =prctl (data->prctl_set, vl); +if (ret <0 ) { + errors++; +ksft_print_msg ("%s prctl set failed for %d: %d (%s)\n" , + data->name, vl, + errno,strerror (errno)); +continue ; + } + + new_vl = ret &PR_SVE_VL_LEN_MASK ; + +/* Check that we actually have the reported new VL */ +if (data->rdvl () != new_vl) { +ksft_print_msg ("Set %s VL %d but RDVL reports %d\n" , + data->name, new_vl, data->rdvl ()); + errors++; + } + +/* Was that the VL we asked for? */ +if (new_vl == vl) +continue ; + +/* Should round up to the minimum VL if below it */ +if (vl < data->min_vl) { +if (new_vl != data->min_vl) { +ksft_print_msg ("%s VL %d returned %d not minimum %d\n" , + data->name, vl, new_vl, + data->min_vl); + errors++; + } + +continue ; + } + +/* Should round down to maximum VL if above it */ +if (vl > data->max_vl) { +if (new_vl != data->max_vl) { +ksft_print_msg ("%s VL %d returned %d not maximum %d\n" , + data->name, vl, new_vl, + data->max_vl); + errors++; + } + +continue ; + } + +/* Otherwise we should've rounded down */ +if (!(new_vl < vl)) { +ksft_print_msg ("%s VL %d returned %d, did not round down\n" , + data->name, vl, new_vl); + errors++; + +continue ; + } + +/* We should've hit one of the other cases... */ +ksft_print_msg ("%s VL %d returned %d test logic failure\n" , + data->name, vl, new_vl); + errors++; + } + +ksft_test_result (errors ==0 ,"%s prctl() set all VLs, %d errors\n" , + data->name, errors); +} +typedef void (*test_type )(struct vec_data *);static const test_type tests[] = {
@@ -557,6 +632,7 @@ static const test_type tests[] = { prctl_set_no_child, prctl_set_for_child, prctl_set_onexec, + prctl_set_all_vqs, };int main (void )
Signature · 1 line
2.20.1
RE: [PATCH v1 4/4] selftests: arm64: Verify that all possible vector lengths are handled
Quoted 73 lines
As part of the enumeration interface for setting vector lengths it is valid to set vector lengths not supported in the system, these will be rounded to a supported vector length and returned from the
prctl(). Add a test which exercises this for every valid vector length and makes sure that the return value is as expected and that this is reflected in the actual system state.Signed-off-by Mark Brown <[email protected]>--- tools/testing/selftests/arm64/fp/vec-syscfg.c | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+)tools/testing/selftests/arm64/fp/vec-syscfg.c +48
-0@@ -540,6 +540,81 @@ static void prctl_set_onexec(struct vec_data *data)file_write_integer (data->default_vl_file, data->default_vl); } +/* For each VQ verify that setting via prctl() does the right thing */ +static void prctl_set_all_vqs (struct vec_data *data) +{ +int ret, vq, vl, new_vl; +int errors =0 ; + +for (vq =SVE_VQ_MIN ; vq <=SVE_VQ_MAX ; vq++) { + vl =sve_vl_from_vq (vq); + +/* Attempt to set the VL */ + ret =prctl (data->prctl_set, vl); +if (ret <0 ) { + errors++; +ksft_print_msg ("%s prctl set failed for %d: %d (%s)\n", + data->name, vl, + errno,strerror (errno)); +continue ; + } + + new_vl = ret &PR_SVE_VL_LEN_MASK ; + +/* Check that we actually have the reported new VL */ +if (data->rdvl () != new_vl) { + ksft_print_msg("Set %s VL %d but RDVL reports %d\n", + data->name, new_vl, data->rdvl()); + errors++; + } + +/* Was that the VL we asked for? */ +if (new_vl == vl) +continue ; + +/* Should round up to the minimum VL if below it */ +if (vl < data->min_vl) { +if (new_vl != data->min_vl) { + ksft_print_msg("%s VL %d returned %d not minimum %d\n", + data->name, vl, new_vl, + data->min_vl); + errors++; + } + +continue ; + } + +/* Should round down to maximum VL if above it */ +if (vl > data->max_vl) { +if (new_vl != data->max_vl) { + ksft_print_msg("%s VL %d returned %d notmaximum %d\n",
tools/testing/selftests/arm64/fp/vec-syscfg.c static void prctl_set_onexec(struct vec_data *data) · line 598
Quoted 8 lines
tools/testing/selftests/arm64/fp/vec-syscfg.c +8
-0+ data->name, vl, new_vl, + data->max_vl); + errors++; + } + +continue ; + } +
Hello,
Since (new_vl < vl) is expected here:
tools/testing/selftests/arm64/fp/vec-syscfg.c static void prctl_set_onexec(struct vec_data *data) · line 606
Quoted 9 lines
tools/testing/selftests/arm64/fp/vec-syscfg.c +3
-0+/* Otherwise we should've rounded down */ +if (!(new_vl < vl)) { + ksft_print_msg("%s VL %d returned %d, did not rounddown\n",
tools/testing/selftests/arm64/fp/vec-syscfg.c +5
-0+ data->name, vl, new_vl); + errors++; + +continue ; + }
I think following two lines should be removed:
tools/testing/selftests/arm64/fp/vec-syscfg.c static void prctl_set_onexec(struct vec_data *data) · line 611
Quoted 5 lines
tools/testing/selftests/arm64/fp/vec-syscfg.c +5
-0+ +/* We should've hit one of the other cases... */ +ksft_print_msg ("%s VL %d returned %d test logic failure\n" , + data->name, vl, new_vl); + errors++;
Actually I tried to run these sve tests update on A64FX and got the above error:
# # SVE VL 48 returned 32 test logic failure
but returning 32 is expected behavior as A64FX's supported VL lens are 16, 32, 64.
Thanks,
Misono
Quoted 21 lines
tools/testing/selftests/arm64/fp/vec-syscfg.c +7
-1+ } + +ksft_test_result (errors ==0 ,"%s prctl() set all VLs, %d errors\n" , + data->name, errors); +} +typedef void (*test_type )(struct vec_data *);static const test_type tests[] = {@@ -557,6 +632,7 @@ static const test_type tests[] = { prctl_set_no_child, prctl_set_for_child, prctl_set_onexec, + prctl_set_all_vqs, };int main (void ) --2.20.1
Quoted 4 lines
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v1 4/4] selftests: arm64: Verify that all possible vector lengths are handled
Quoted 5 lines · On Fri, Sep 17, 2021 at 09:27:04AM +0000, [email protected] wrote:
Actually I tried to run these sve tests update on A64FX and got the above error:
# # SVE VL 48 returned 32 test logic failure
but returning 32 is expected behavior as A64FX's supported VL lens are 16, 32, 64.
Right, I see. That's not triggering on the virtual platforms since they just support all the VLs. Your fix looks right, it was supposed to be an assert in case of logic failures but that doesn't actually work out.