[LTP] [PATCH] cpuset_hotplug_test.sh: Fix a race condition

Petr Vorel pvorel@suse.cz
Thu Jul 16 11:57:38 CEST 2020


Hi Qais,

> > BTW this has already been reviewed and tested by Huacai Chen [1].
> > LGTM, although I'd prefer to detect with with polling, isn't it possible? [1].

> FWIW I did try to avoid the sleep [1].
Yes, I know, but that was in kernel code (great you tried to fix the problem in
the kernel). Here I mean avoid blind sleep in the test. Reporting problem and
taking "sleep 1" fix would be most probably just enough. Below are suggestions to
consider before taking your posted fix as is.

> Were you thinking of something like that (pseudo code)?

> 	for i in $(seq 3)
> 	do
> 		sleep 1
> 		verify()
> 		if [ sucess ]; then
> 			break;
> 		fi
> 	done

> Or you had something more sophisticated in mind?
No, certainly not more sophisticated :). You can also use TST_RETRY_FUNC helper
instead of creating loop manually. It sleeps in 1 sec.

NOTE: TST_RETRY_FUNC is a wrapper for TST_RETRY_FN_EXP_BACKOFF, using it you can
define sleep time. Unfortunately current code does not allow to loop over less
than 1s, maybe it'd be worth for some cases, where the event is really fast.

@Metan, @Li: would it be worth to change TST_RETRY_FUNC (in both C and shell) to
use ms instead of s?

Also, we have tst_sleep helper, which supports also ms and us (but using
TST_RETRY_FUNC is IMHO better).

I'd have to look more deeply into the test to figure out the verifier.

Kind regards,
Petr


More information about the ltp mailing list