From: John Weekes <lists.xen@nuclearfallout.net>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Cc: George Dunlap <george.dunlap@citrix.com>
Subject: [PATCH] Fix locking bug in vcpu_migrate
Date: Fri, 22 Apr 2011 03:00:26 -0700 [thread overview]
Message-ID: <4DB151BA.9010006@nuclearfallout.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 2623 bytes --]
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@nuclearfallout.net>
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 #2: schedule.dff --]
[-- Type: text/plain, Size: 1889 bytes --]
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 #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2011-04-22 10:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-22 10:00 John Weekes [this message]
2011-04-22 10:30 ` [PATCH] Fix locking bug in vcpu_migrate Keir Fraser
2011-04-22 18:23 ` John Weekes
2011-04-22 18:43 ` Keir Fraser
2011-04-22 22:33 ` John Weekes
2011-04-23 7:01 ` Keir Fraser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DB151BA.9010006@nuclearfallout.net \
--to=lists.xen@nuclearfallout.net \
--cc=george.dunlap@citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.