[Xen-devel] [OSSTEST PATCH 17/21] starvation: Use "starved" for hostalloc_maxwait_max

Ian Jackson posted 21 patches 6 years, 9 months ago
[Xen-devel] [OSSTEST PATCH 17/21] starvation: Use "starved" for hostalloc_maxwait_max
Posted by Ian Jackson 6 years, 9 months ago
Previously this was "broken".

We mustn't just call `broken' inside attempt_allocation because that
runs in a db transaction.  Instead, we arrange that attempt_allocation
returns 2, which threads its way back out to the return value from
alloc_resources, and then call broken there.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 ts-hosts-allocate-Executive | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive
index 3425c8ce..8c9ddaf7 100755
--- a/ts-hosts-allocate-Executive
+++ b/ts-hosts-allocate-Executive
@@ -683,12 +683,17 @@ sub alloc_hosts () {
         ? -10000
         : -10 * @hids;
 
-    alloc_resources(WaitStart =>
+    my $ok = alloc_resources(WaitStart =>
                     ($ENV{OSSTEST_RESOURCE_WAITSTART} || $fi->{started}),
                     WaitStartAdjust => $waitstartadjust,
 		    DebugFh => \*DEBUG,
                     \&attempt_allocation);
 
+    if ($ok==2) {
+	broken "starved or timed out", 'starved';
+    }
+    die $ok unless $ok==1;
+
     foreach my $hid (@hids) {
         my $sel= $hid->{Selected};
         die $hid->{Ident} unless defined $sel->{resname};
@@ -764,9 +769,11 @@ sub attempt_allocation {
 	    #  * we have been waiting at least $maxwait/2
 	    #  * we estimate it will take at least $maxwait overall
 	    my $wait_sofar = $now - $alloc_start_time;
-	    die "timed out: $wait_sofar, $best->{Start}, $maxwait"
-                if $wait_sofar > $maxwait/2
-		&& $wait_sofar + $best->{Start} > $maxwait;
+	    if ($wait_sofar > $maxwait/2
+		&& $wait_sofar + $best->{Start} > $maxwait) {
+		logm "timed out: $wait_sofar, $best->{Start}, $maxwait";
+		return 2;
+	    }
 	}
     }
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel