[Devel] Re: [PATCH 01/11] cr_tests: Add timeout to robust futex test.

Matt Helsley matthltc at us.ibm.com
Wed Aug 19 22:08:38 PDT 2009


On Wed, Aug 19, 2009 at 09:58:04PM -0700, Matt Helsley wrote:
> The robust futex test can hang if the kernel fails to properly set the
> robust list pointer. This currently happens during restart. The test should not
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Argh. Forgot to update the description and remove this sentence. I do
not wish to report a bug :).

Nonetheless, the patch is a nice way to ensure the test
doesn't hang under as many circumstances as possible.

> hang and instead should report failure.
> 
> Use a timeout to ensure that hangs are caught and reported as failure.
> The timeout should return ETIMEDOUT. This limits the total amount of
> time checkpoint/restart can take so a suitable timeout is essential here.
> 
> Signed-off-by: Matt Helsley <matthltc at us.ibm.com>
> Cc: containers at lists.linux-foundation.org
> ---
>  futex/robust.c |   11 ++++++++---
>  1 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/futex/robust.c b/futex/robust.c
> index 1025515..304c35f 100644
> --- a/futex/robust.c
> +++ b/futex/robust.c
> @@ -103,6 +103,10 @@ void add_rfutex(struct futex *rf)
> 
>  void acquire_rfutex(struct futex *rf, pid_t tid)
>  {
> +	struct timespec timeout = {
> +		.tv_sec = 5,
> +		.tv_nsec = 0
> +	};
>  	int oldval, newval, val = 0;
> 
>  	rlist.list_op_pending = &rf->rlist; /* ARCH TODO make sure this assignment is atomic */
> @@ -126,7 +130,7 @@ void acquire_rfutex(struct futex *rf, pid_t tid)
>  		val = __sync_or_and_fetch(&rf->tid.counter, FUTEX_WAITERS);
>  		log("INFO", "futex(FUTEX_WAIT, %x)\n", val);
>  		if (futex(&rf->tid.counter, FUTEX_WAIT, val,
> -			  NULL, NULL, 0) == 0)
> +			  &timeout, NULL, 0) == 0)
>  			break;
>  		log("INFO", "futex returned with errno %d (%s).\n", errno, strerror(errno));
>  		switch(errno) {
> @@ -147,8 +151,9 @@ void acquire_rfutex(struct futex *rf, pid_t tid)
>  				log("WARN", "EINTR while sleeping on futex\n");
>  				continue;
>  			case ETIMEDOUT:
> -				log("WARN", "ETIMEDOUT while sleeping on futex\n");
> -				continue;
> +				log("FAIL", "ETIMEDOUT while sleeping on futex.\n");
> +				fail++;
> +				return;
>  			case EACCES:
>  				log("FAIL", "FUTEX_WAIT EACCES - no read access to futex memory\n");
>  				fail++;
> -- 
> 1.5.6.3
> 
> 
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list