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-changelog

[Xen-changelog] [xen-unstable] scheduler: Update vcpu_schedule_lock to c

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] scheduler: Update vcpu_schedule_lock to check for changed lock pointer as well
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 24 Dec 2010 15:46:36 -0800
Delivery-date: Fri, 24 Dec 2010 15:51:06 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1293179189 0
# Node ID 26783586eb51195b46ca2fa6e53f8f2574b98e6a
# Parent  d6d7f4f3dcf86ea0efca1ec11f45ef4562cfa2a4
scheduler: Update vcpu_schedule_lock to check for changed lock pointer as well

Credit2 has different cpus share a lock; which means that as cpus are
added, and as they're moved between pools, the pointer to the
scheduler lock may also change as well.

Since we don't want to have to grab a lock before grabbing the per-cpu
scheduler lock, we use the lock itself to protect against the pointer
changing.

However, since it may change between reading and locking, after we
grab the lock we need to check to make sure it's still the right one.

Update the vcpu_schedule_lock() definition to reflect this: both
v->processor and that processor's schedule lock are liable to change;
check both after grabbing the lock, and release / re-acquire if
necessary.

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
---
 xen/include/xen/sched-if.h |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff -r d6d7f4f3dcf8 -r 26783586eb51 xen/include/xen/sched-if.h
--- a/xen/include/xen/sched-if.h        Fri Dec 24 08:25:54 2010 +0000
+++ b/xen/include/xen/sched-if.h        Fri Dec 24 08:26:29 2010 +0000
@@ -41,23 +41,25 @@ DECLARE_PER_CPU(struct cpupool *, cpupoo
 
 static inline void vcpu_schedule_lock(struct vcpu *v)
 {
-    unsigned int cpu;
+    spinlock_t * lock;
 
     for ( ; ; )
     {
-        /* NB: For schedulers with multiple cores per runqueue,
-         * a vcpu may change processor w/o changing runqueues;
-         * so we may release a lock only to grab it again.
+        /* v->processor may change when grabbing the lock; but
+         * per_cpu(v->processor) may also change, if changing
+         * cpu pool also changes the scheduler lock.  Retry
+         * until they match.
          *
-         * If that is measured to be an issue, then the check
-         * should be changed to checking if the locks pointed to
-         * by cpu and v->processor are still the same.
+         * It may also be the case that v->processor may change
+         * but the lock may be the same; this will succeed
+         * in that case.
          */
-        cpu = v->processor;
-        spin_lock(per_cpu(schedule_data, cpu).schedule_lock);
-        if ( likely(v->processor == cpu) )
+        lock=per_cpu(schedule_data, v->processor).schedule_lock;
+
+        spin_lock(lock);
+        if ( likely(lock == per_cpu(schedule_data, 
v->processor).schedule_lock) )
             break;
-        spin_unlock(per_cpu(schedule_data, cpu).schedule_lock);
+        spin_unlock(lock);
     }
 }
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] scheduler: Update vcpu_schedule_lock to check for changed lock pointer as well, Xen patchbot-unstable <=