WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Fix locking bug in vcpu_migrate

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Fix locking bug in vcpu_migrate
From: John Weekes <lists.xen@xxxxxxxxxxxxxxxxxx>
Date: Fri, 22 Apr 2011 03:00:26 -0700
Cc: George Dunlap <george.dunlap@xxxxxxxxxx>
Delivery-date: Fri, 22 Apr 2011 03:01:51 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
c/s 22957:c5c4688d5654 (unstable) changed the locking scheme for vcpu_migrate by adjusting the order so that the lock with the lowest lock address is obtained first. However, the code does not release them in the correct reverse order; it removes new_lock first if it differs from old_lock, but that is not the last lock obtained when old_lock > new_lock.

As a result of this bug, under credit2, domUs would sometimes take a long time to start, and there was an occasional panic.

This fix should be applied to both xen-unstable and xen-4.1-testing. I have tested and seen the problem with both, and also tested to confirm an improvement for both.

Signed-off-by: John Weekes <lists.xen@xxxxxxxxxxxxxxxxxx>

diff -r eb4505f8dd97 xen/common/schedule.c
--- a/xen/common/schedule.c     Wed Apr 20 12:02:51 2011 +0100
+++ b/xen/common/schedule.c     Fri Apr 22 03:46:00 2011 -0500
@@ -455,9 +455,20 @@
             pick_called = 0;
         }

-        if ( old_lock != new_lock )
+        if ( old_lock == new_lock )
+        {
+            spin_unlock_irqrestore(old_lock, flags);
+        }
+        else if ( old_lock < new_lock )
+        {
             spin_unlock(new_lock);
-        spin_unlock_irqrestore(old_lock, flags);
+            spin_unlock_irqrestore(old_lock, flags);
+        }
+        else
+        {
+            spin_unlock(old_lock);
+            spin_unlock_irqrestore(new_lock, flags);
+        }
     }

     /*
@@ -468,9 +479,20 @@
     if ( v->is_running ||
          !test_and_clear_bit(_VPF_migrating, &v->pause_flags) )
     {
-        if ( old_lock != new_lock )
+        if ( old_lock == new_lock )
+        {
+            spin_unlock_irqrestore(old_lock, flags);
+        }
+        else if ( old_lock < new_lock )
+        {
             spin_unlock(new_lock);
-        spin_unlock_irqrestore(old_lock, flags);
+            spin_unlock_irqrestore(old_lock, flags);
+        }
+        else
+        {
+            spin_unlock(old_lock);
+            spin_unlock_irqrestore(new_lock, flags);
+        }
         return;
     }

@@ -491,9 +513,20 @@
      */
     v->processor = new_cpu;

-    if ( old_lock != new_lock )
+    if ( old_lock == new_lock )
+    {
+        spin_unlock_irqrestore(old_lock, flags);
+    }
+    else if ( old_lock < new_lock )
+    {
         spin_unlock(new_lock);
-    spin_unlock_irqrestore(old_lock, flags);
+        spin_unlock_irqrestore(old_lock, flags);
+    }
+    else
+    {
+        spin_unlock_irqrestore(old_lock, flags);
+        spin_unlock(new_lock);
+    }

     if ( old_cpu != new_cpu )
         evtchn_move_pirqs(v);

Attachment: schedule.dff
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel