fzsync: Prevent early exit
PATCH 1/1 fzsync: Prevent early exit
From: Richard Palethorpe <[email protected]>
In some tests it may be possible for the child thread to exit before it has completed an equal number of iterations to main thread (the thread which sets the exit state). Due to the way most tests use the library this is unlikely to matter, but in theory it could cause some tests to exit uncleanly. To fix this, we only exit if we find that the thread has progressed to a wait() call which would spin indefinitely if exit were not set.
I already suspected this bug existed, but confirmed while trying to formally verify the algorithm using Modex, see:
https://github.com/richiejp/modex_models
Signed-off-by Richard Palethorpe <[email protected]>
--- include/tst_fuzzy_sync.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/tst_fuzzy_sync.h +3 -1
@@ -265,7 +265,9 @@ static inline int tst_fzsync_pair_wait(struct tst_fzsync_pair *pair, ; } -return !tst_atomic_load (&pair->exit); +/* Only exit if we have done the same amount of work as the other thread */ +return !tst_atomic_load (&pair->exit) || +tst_atomic_load (other_cntr) <=tst_atomic_load (our_cntr); }static inline int tst_fzsync_wait_a (struct tst_fzsync_pair *pair)
Signature · 1 line
2.14.2
PATCH 1/1 fzsync: Prevent early exit
Hi!
Applied, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]