All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cr_tests: Fix hang when robust futex lists are not restored during restart
@ 2009-07-09 19:22 Matt Helsley
       [not found] ` <20090709192207.GJ32310-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Matt Helsley @ 2009-07-09 19:22 UTC (permalink / raw)
  To: Serge Hallyn; +Cc: Containers

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
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-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Reported-by: Serge Hallyn <serue-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
--
Still needs testing.

diff --git a/futex/robust.c b/futex/robust.c
index a52f638..4cda4f7 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 val = 0;
 
 	rlist.list_op_pending = &rf->rlist; /* ARCH TODO make sure this assignment is atomic */
@@ -125,7 +129,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) {
@@ -139,8 +143,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++;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-07-11 20:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-09 19:22 [PATCH] cr_tests: Fix hang when robust futex lists are not restored during restart Matt Helsley
     [not found] ` <20090709192207.GJ32310-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-07-09 20:00   ` Serge E. Hallyn
     [not found]     ` <20090709200040.GA21053-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-07-09 20:06       ` Matt Helsley
     [not found]         ` <20090709200649.GL32310-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-07-09 20:14           ` Oren Laadan
2009-07-09 20:58   ` Serge E. Hallyn
     [not found]     ` <20090709205853.GA23637-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-07-10  0:21       ` Sukadev Bhattiprolu
     [not found]         ` <20090710002144.GA13085-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-07-10 23:34           ` Matt Helsley
     [not found]             ` <20090710233457.GA5213-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-07-11 20:56               ` Sukadev Bhattiprolu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.