lib: add .min_cpus in tst_test struct
PATCH 1/3 lib: add .min_cpus in tst_test struct
As the name implies, this new field is mainly to set minimum numbers of CPU for LTP testcase. If system online CPUs are less than .min_cpus, test will be exit with TCONF.
Note: I wouldn't add more description in test-writing-guidelines.txt, because it is easy to understand the usage from the name.
--- include/tst_test.h | 3 +++ lib/tst_test.c | 3 +++ 2 files changed, 6 insertions(+)
include/tst_test.h +3 -0
@@ -157,6 +157,9 @@ struct tst_test {*/ int all_filesystems:1; +/* Minimal numbers of CPU online required by the test */ +unsigned long min_cpus; +/* * If set non-zero number of request_hugepages, test will try to reserve the * expected number of hugepage for testing in setup phase. If system does not
lib/tst_test.c +3 -0
@@ -918,6 +918,9 @@ static void do_setup(int argc, char *argv[])if (tst_test->all_filesystems) tst_test->needs_device =1 ; +if (tst_test->min_cpus >tst_ncpus ()) +tst_brk (TCONF ,"Test needs %lu CPUs online" , tst_test->min_cpus); +if (tst_test->request_hugepages)tst_request_hugepages (tst_test->request_hugepages);
Signature · 1 line
2.21.3
PATCH 2/3 syscalls: take use of .min_cpus
To set the minimal numbers of online CPU for test.
[From Martin Doucha]af_alg07 requires 2 CPUs, otherwise it'll report false positives. The test will pass only if fchownat() hits a half-closed socket and returns error. But IIRC the half-closed socket will be destroyed during reschedule which means there's no race window to hit anymore. But it would be better to put the TCONF condition into the test itself.
getcwd04: as itself requirements.
--- testcases/kernel/crypto/af_alg07.c | 1 + testcases/kernel/syscalls/getcwd/getcwd04.c | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-)
testcases/kernel/crypto/af_alg07.c +1 -0
@@ -110,6 +110,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .min_kver = "4.10.0", + .min_cpus = 2, .taint_check = TST_TAINT_W | TST_TAINT_D, .tags = (const struct tst_tag []) { {"linux-git" ,"9060cb719e61" },
testcases/kernel/syscalls/getcwd/getcwd04.c +2 -4
@@ -68,9 +68,6 @@ static void verify_getcwd(void)static void setup (void ) { -if (tst_ncpus () ==1 ) -tst_brk (TCONF ,"This test needs two cpus at least" ); -SAFE_SIGNAL (SIGALRM , sigproc);alarm (TIMEOUT );
@@ -101,5 +98,6 @@ static struct tst_test test = { .setup = setup, .test_all = verify_getcwd, .needs_tmpdir = 1, - .forks_child = 1 + .forks_child = 1, + .min_cpus = 2 };
Signature · 1 line
2.21.3
PATCH 3/3 af_alg07: add dynamic bias for ARM
In reply to Li WangWe observed that af_alg07 sporadically failed on hpe-moonshot(aarch64) with fixed kernel, but after trying manually we can NOT reproduce it again, one possibility is that the FAIL is caused by an unaligned race window between two threads, so here add dynamic bias adjustment to see if it helps.
Point of view from Martin Doucha:
1) fchownat() returns 0 => fchownat() was called too early or the kernel is vulnerable
2) fchwonat() fails with ENOENT => kernel is fixed, print TPASS and exit
3) fchownat() fails with EBADF => fchownat() was called too late
--- testcases/kernel/crypto/af_alg07.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
testcases/kernel/crypto/af_alg07.c +10 -0
@@ -76,6 +76,16 @@ static void run(void)return ; } +if (TST_RET ==0 ) { +tst_fzsync_pair_add_bias (&fzsync_pair,-1 ); +continue ; + } + +if (TST_RET ==-1 &&TST_ERR ==EBADF ) { +tst_fzsync_pair_add_bias (&fzsync_pair,1 ); +continue ; + } +if (TST_RET ==-1 &&TST_ERR ==ENOENT ) {tst_res (TPASS |TTERRNO ,"fchownat() failed successfully" );
Signature · 1 line
2.21.3
PATCH 3/3 af_alg07: add dynamic bias for ARM
Hello,
Quoted 9 lines · Li Wang
We observed that
af_alg07sporadically failed on hpe-moonshot(aarch64) with fixed kernel, but after trying manually we can NOT reproduce it again, one possibility is that the FAIL is caused by an unaligned race window between two threads, so here add dynamic bias adjustment to see if it helps.Point of view from Martin Doucha:
1)fchownat()returns 0 =>fchownat()was called too early or the kernel is vulnerable
2)fchwonat()fails with ENOENT => kernel is fixed, print TPASS and exit
3)fchownat()fails with EBADF =>fchownat()was called too late
Just FYI, what really prevents fzsync from working is if the temporal behaviour (time to execute) of a syscall changes dramatically depending on the outcome of a race[1].
For example if fchownat returns very quickly after EBADF, but takes a long time otherwise, then the delay will be too small. I guess most syscalls will check the FD very early so this is likely to be the problem.
Quoted 16 lines
Signed-off-by Li Wang <[email protected]>CC Richard Palethorpe <[email protected]>CC Martin Doucha <[email protected]>CC Joerg Vehlow <[email protected]>CC Chunyu Hu <[email protected]>CC Cyril Hrubis <[email protected]>--- testcases/kernel/crypto/af_alg07.c | 10 ++++++++++ 1 file changed, 10 insertions(+)testcases/kernel/crypto/af_alg07.c +0
-0
testcases/kernel/crypto/af_alg07.c static void run(void) · line 82
Quoted 7 lines
testcases/kernel/crypto/af_alg07.c +4
-0@@ -76,6 +76,16 @@ static void run(void)return ; } +if (TST_RET ==0 ) { +tst_fzsync_pair_add_bias (&fzsync_pair,-1 ); +continue ; + }
It may actually be better to remove this and only increase the delay if EBADF?
testcases/kernel/crypto/af_alg07.c static void run(void) · line 91
Quoted 9 lines
testcases/kernel/crypto/af_alg07.c +6
-0+ +if (TST_RET ==-1 &&TST_ERR ==EBADF ) { +tst_fzsync_pair_add_bias (&fzsync_pair,1 ); +continue ; + } +if (TST_RET ==-1 &&TST_ERR ==ENOENT ) {tst_res (TPASS |TTERRNO ,"fchownat() failed successfully" );
[1] Not necessarily the race which causes the bug.
Signature · 2 lines
Thank you, Richard.
PATCH 3/3 af_alg07: add dynamic bias for ARM
Quoted 42 lines · Richard Palethorpe
Hello,
Quoted 9 lines · Li Wang
We observed that
af_alg07sporadically failed on hpe-moonshot(aarch64) with fixed kernel, but after trying manually we can NOT reproduce it again, one possibility is that the FAIL is caused by an unaligned race window between two threads, so here add dynamic bias adjustment to see if it helps.Point of view from Martin Doucha:
1)fchownat()returns 0 =>fchownat()was called too early or the kernel is vulnerable
2)fchwonat()fails with ENOENT => kernel is fixed, print TPASS and exit
3)fchownat()fails with EBADF =>fchownat()was called too lateJust FYI, what really prevents fzsync from working is if the temporal behaviour (time to execute) of a syscall changes dramatically depending on the outcome of a race[1].
For example if fchownat returns very quickly after EBADF, but takes a long time otherwise, then the delay will be too small. I guess most syscalls will check the FD very early so this is likely to be the problem.
Quoted 19 lines
Signed-off-by Li Wang <[email protected]>CC Richard Palethorpe <[email protected]>CC Martin Doucha <[email protected]>CC Joerg Vehlow <[email protected]>CC Chunyu Hu <[email protected]>CC Cyril Hrubis <[email protected]>--- testcases/kernel/crypto/af_alg07.c | 10 ++++++++++ 1 file changed, 10 insertions(+)testcases/kernel/crypto/af_alg07.c +0
-0@@ -76,6 +76,16 @@ static void run(void)return ; }
Quoted 7 lines
testcases/kernel/crypto/af_alg07.c static void run(void) · line 82
Quoted 4 lines
testcases/kernel/crypto/af_alg07.c +4
-0+if (TST_RET ==0 ) { +tst_fzsync_pair_add_bias (&fzsync_pair,-1 ); +continue ; + }It may actually be better to remove this and only increase the delay if EBADF?
Agreed. Adjusting delay in both directions would be acceptable if the test takes too much time or doesn't work at all without it. Otherwise it's preferable to adjust delay only when syscalls return an error state that clearly falls outside the race window.
Signature · 7 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic
PATCH 1/3 lib: add .min_cpus in tst_test struct
In reply to Li WangHello li,
Only some minor nits.
Quoted 18 lines · Li Wang
As the name implies, this new field is mainly to set minimum numbers of CPU for LTP testcase. If system online CPUs are less than .min_cpus, test will be exit with TCONF.
Note: I wouldn't add more description in test-writing-guidelines.txt, because it is easy to understand the usage from the name.
Signed-off-by Li Wang <[email protected]>--- include/tst_test.h | 3 +++ lib/tst_test.c | 3 +++ 2 files changed, 6 insertions(+)include/tst_test.h +0
-0
include/tst_test.h struct tst_test { · line 160
Quoted 4 lines
include/tst_test.h +1
-0@@ -157,6 +157,9 @@ struct tst_test {*/ int all_filesystems:1; +/* Minimal numbers of CPU online required by the test */
*Mininum number of online CPUs required by the test*
Quoted 10 lines
include/tst_test.h +2
-0+unsigned long min_cpus; +/* * If set non-zero number of request_hugepages, test will try to reserve the * expected number of hugepage for testing in setup phase. If system does not lib/tst_test.c +0
-0
lib/tst_test.c static void do_setup(int argc, char *argv[]) · line 922
Quoted 5 lines
lib/tst_test.c +2
-0@@ -918,6 +918,9 @@ static void do_setup(int argc, char *argv[])if (tst_test->all_filesystems) tst_test->needs_device =1 ; +if (tst_test->min_cpus >tst_ncpus ()) +tst_brk (TCONF ,"Test needs %lu CPUs online" , tst_test->min_cpus);
^at least
Quoted 6 lines
lib/tst_test.c +1
-0+if (tst_test->request_hugepages)tst_request_hugepages (tst_test->request_hugepages);Signature · 1 line
2.21.3
Signature · 2 lines
Thank you, Richard.
PATCH v2 1/3 lib: add .min_cpus in tst_test struct
In reply to Li WangAs the name implies, this new field is mainly to set minimum numbers of CPU for LTP testcase. If system online CPUs are less than .min_cpus, test will be exit with TCONF.
Note: I wouldn't add more description in test-writing-guidelines.txt, because it is easy to understand the usage from the name.
--- include/tst_test.h | 3 +++ lib/tst_test.c | 3 +++ 2 files changed, 6 insertions(+)
include/tst_test.h +3 -0
@@ -157,6 +157,9 @@ struct tst_test {*/ int all_filesystems:1; +/* Minimum numbers of online CPU required by the test */ +unsigned long min_cpus; +/* * If set non-zero number of request_hugepages, test will try to reserve the * expected number of hugepage for testing in setup phase. If system does not
lib/tst_test.c +3 -0
@@ -918,6 +918,9 @@ static void do_setup(int argc, char *argv[])if (tst_test->all_filesystems) tst_test->needs_device =1 ; +if (tst_test->min_cpus >tst_ncpus ()) +tst_brk (TCONF ,"Test needs at least %lu CPUs online" , tst_test->min_cpus); +if (tst_test->request_hugepages)tst_request_hugepages (tst_test->request_hugepages);
Signature · 1 line
2.21.3
PATCH v2 2/3 syscalls: make use of .min_cpus
To set the minimum numbers of online CPU for test.
From Martin Doucha:
af_alg07 requires 2 CPUs, otherwise it'll report false positives. The test will pass only if fchownat() hits a half-closed socket and returns error. But IIRC the half-closed socket will be destroyed during reschedule which means there's no race window to hit anymore. But it would be better to put the TCONF condition into the test itself.
getcwd04: as itself requirements.
--- testcases/kernel/crypto/af_alg07.c | 1 + testcases/kernel/syscalls/getcwd/getcwd04.c | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-)
testcases/kernel/crypto/af_alg07.c +1 -0
@@ -110,6 +110,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .min_kver = "4.10.0", + .min_cpus = 2, .taint_check = TST_TAINT_W | TST_TAINT_D, .tags = (const struct tst_tag []) { {"linux-git" ,"9060cb719e61" },
testcases/kernel/syscalls/getcwd/getcwd04.c +2 -4
@@ -68,9 +68,6 @@ static void verify_getcwd(void)static void setup (void ) { -if (tst_ncpus () ==1 ) -tst_brk (TCONF ,"This test needs two cpus at least" ); -SAFE_SIGNAL (SIGALRM , sigproc);alarm (TIMEOUT );
@@ -101,5 +98,6 @@ static struct tst_test test = { .setup = setup, .test_all = verify_getcwd, .needs_tmpdir = 1, - .forks_child = 1 + .forks_child = 1, + .min_cpus = 2 };
Signature · 1 line
2.21.3
PATCH v2 2/3 syscalls: make use of .min_cpus
Hi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 3/3 af_alg07: add dynamic bias for ARM
In reply to Li WangWe observed that af_alg07 sporadically failed on hpe-moonshot(aarch64) with fixed kernel, but after trying manually we can NOT reproduce it again, one possibility is that the FAIL is caused by an unaligned race window between two threads, so here add dynamic bias adjustment to see if it helps.
From Martin Doucha:
1) fchownat() returns 0 => fchownat() was called too early or the kernel is vulnerable
2) fchwonat() fails with ENOENT => kernel is fixed, print TPASS and exit
3) fchownat() fails with EBADF => fchownat() was called too late
Considering the test does NOT takes too time in 1) so we only adjust delay when syscalls return an error state that clearly falls outside the race window.
--- testcases/kernel/crypto/af_alg07.c | 5 +++++ 1 file changed, 5 insertions(+)
testcases/kernel/crypto/af_alg07.c +5 -0
@@ -76,6 +76,11 @@ static void run(void)return ; } +if (TST_RET ==-1 &&TST_ERR ==EBADF ) { +tst_fzsync_pair_add_bias (&fzsync_pair,1 ); +continue ; + } +if (TST_RET ==-1 &&TST_ERR ==ENOENT ) {tst_res (TPASS |TTERRNO ,"fchownat() failed successfully" );
Signature · 1 line
2.21.3
PATCH v2 3/3 af_alg07: add dynamic bias for ARM
Hi all,
Any objection to merging this one? or comments?
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20201209/9a2111b5/attachment.htm>
PATCH v2 3/3 af_alg07: add dynamic bias for ARM
Hello Li,
Quoted 3 lines · Li Wang
Hi all,
Any objection to merging this one? or comments?
LGTM!
Signature · 2 lines
Thank you, Richard.
PATCH v2 3/3 af_alg07: add dynamic bias for ARM
In reply to Li WangQuoted 15 lines · Li Wang
We observed that
af_alg07sporadically failed on hpe-moonshot(aarch64) with fixed kernel, but after trying manually we can NOT reproduce it again, one possibility is that the FAIL is caused by an unaligned race window between two threads, so here add dynamic bias adjustment to see if it helps.From Martin Doucha:
1)
fchownat()returns 0 =>fchownat()was called too early or the kernel is vulnerable
2)fchwonat()fails with ENOENT => kernel is fixed, print TPASS and exit
3)fchownat()fails with EBADF =>fchownat()was called too lateConsidering the test does NOT takes too time in 1) so we only adjust delay when syscalls return an error state that clearly falls outside the race window.
Quoted 6 lines
Signed-off-by Li Wang <[email protected]>CC Richard Palethorpe <[email protected]>CC Martin Doucha <[email protected]>CC Joerg Vehlow <[email protected]>CC Chunyu Hu <[email protected]>CC Cyril Hrubis <[email protected]>
Quoted 21 lines
--- testcases/kernel/crypto/af_alg07.c | 5 +++++ 1 file changed, 5 insertions(+)testcases/kernel/crypto/af_alg07.c +5
-0@@ -76,6 +76,11 @@ static void run(void)return ; } +if (TST_RET ==-1 &&TST_ERR ==EBADF ) { +tst_fzsync_pair_add_bias (&fzsync_pair,1 ); +continue ; + } +if (TST_RET ==-1 &&TST_ERR ==ENOENT ) {tst_res (TPASS |TTERRNO ,"fchownat() failed successfully" );
Signature · 7 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic
PATCH v2 3/3 af_alg07: add dynamic bias for ARM
Quoted 2 lines
Reviewed-by Martin Doucha <[email protected]>
Pushed, thanks Martin and Richard for the review.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20201209/f4af3ab7/attachment.htm>
PATCH v2 1/3 lib: add .min_cpus in tst_test struct
In reply to Li WangHi!
Pushed with two fixes, thanks.
include/tst_test.h struct tst_test { · line 160
Quoted 1 line
include/tst_test.h +1
-0+/* Minimum numbers of online CPU required by the test */
^ number
Quoted 10 lines
include/tst_test.h +2
-0+unsigned long min_cpus; +/* * If set non-zero number of request_hugepages, test will try to reserve the * expected number of hugepage for testing in setup phase. If system does not lib/tst_test.c +0
-0
lib/tst_test.c static void do_setup(int argc, char *argv[]) · line 921
Quoted 4 lines
lib/tst_test.c +1
-0@@ -918,6 +918,9 @@ static void do_setup(int argc, char *argv[])if (tst_test->all_filesystems) tst_test->needs_device =1 ; +if (tst_test->min_cpus >tst_ncpus ())
^
Added (unsigned long) cast to silence warnings.
Quoted 11 lines
lib/tst_test.c +2
-0+tst_brk (TCONF ,"Test needs at least %lu CPUs online" , tst_test->min_cpus); +if (tst_test->request_hugepages)tst_request_hugepages (tst_test->request_hugepages);Signature · 5 lines
2.21.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis [email protected]