[PATCH 3/4] cr_tests: futex: pu: Fix potential livelock

Serge E. Hallyn serue at us.ibm.com
Wed Apr 14 07:58:40 PDT 2010


Quoting Matt Helsley (matthltc at us.ibm.com):
> Fixup flow of release_pi_futex to truly break out of the loop during
> an error.
> 
> Also, since it's not used, remove the retries parameter from
> do_unlock_contended_futex.
> 
> Signed-off-by: Matt Helsley <matthltc at us.ibm.com>
> ---
>  futex/pi.c |    9 +++++----
>  1 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/futex/pi.c b/futex/pi.c
> index 53d4c5d..a39964d 100644
> --- a/futex/pi.c
> +++ b/futex/pi.c
> @@ -330,7 +330,7 @@ again:
>  	return -1;
>  }
> 
> -int do_unlock_contended_pi_futex(int retries)
> +int do_unlock_contended_pi_futex(void)
>  {
>  	if (futex(&pi_futex->counter, FUTEX_UNLOCK_PI, 1, NULL, NULL, 0) == 0)
>  		return 0;
> @@ -400,12 +400,12 @@ void release_pi_futex(int *retries, int *retval, pid_t tid)
>  		/* Release the futex */
>  		pi_val = atomic_cmpxchg(pi_futex, tid, 0);
>  		if (pi_val != tid) {
> -		    switch (do_unlock_contended_pi_futex(*retries)) {
> +		    switch (do_unlock_contended_pi_futex(void)) {

Just fyi, my compiler didn't like this.  Replacing it with
		    switch (do_unlock_contended_pi_futex()) {

It also doesn't change the failure of robust testcase on my s390 box:

linuz11:~/cr_tests/futex # sh run.sh 
Using output dir ./cr_futex_PR5nlHC
WARNING: Priority inheritance test must be able to set at least two realtime priorities. ulimit -r indicates otherwise so skipping pi futex test(s).
Running test: plain
Test plain done, returned 0
PASS
Restart of test plain done, returned 0
PASS
Running test: robust
run.sh: line 49: kill: (3900) - No such process
run.sh: line 49: kill: (3900) - No such process

Changing the line waiting for the original testcase to
exit from
	wait ${TEST_PID}
to
        wait ${TEST_PID} || true

lets that continue and pass.

(further changing it to
	wait ${TEST_PID} || echo "wait returned $?" && true
gives me
	wait returned 1
while checking process listings before and after the wait
shows that robust is running for a few seconds, and does
die before wait returns, so I assume robust.c is in fact
exiting with error code)

Meanwhile, after ulimit -r 2 pi testcase still just hogs my
cpus :)

-serge


More information about the Containers mailing list