[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] sched_sedf: Avoid panic when adjusting sedf parameters



# HG changeset patch
# User Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
# Date 1321623283 0
# Node ID d7e6bfa114d05fc4da83a55d995fb031970a94d8
# Parent  0965e589fdcca22af04f70274a6fa54acc42e281
sched_sedf: Avoid panic when adjusting sedf parameters

When using sedf scheduler in a cpupool the system might panic when
setting sedf scheduling parameters for a domain.  Introduces
for_each_domain_in_cpupool macro as it is usable 4 times now.  Add
appropriate locking in cpupool_unassign_cpu().

Signed-off-by: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
Committed-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 0965e589fdcc -r d7e6bfa114d0 xen/common/cpupool.c
--- a/xen/common/cpupool.c      Fri Nov 18 13:32:50 2011 +0000
+++ b/xen/common/cpupool.c      Fri Nov 18 13:34:43 2011 +0000
@@ -309,10 +309,9 @@
     if ( (c->n_dom > 0) && (cpumask_weight(c->cpu_valid) == 1) &&
          (cpu != cpupool_moving_cpu) )
     {
-        for_each_domain(d)
+        rcu_read_lock(&domlist_read_lock);
+        for_each_domain_in_cpupool(d, c)
         {
-            if ( d->cpupool != c )
-                continue;
             if ( !d->is_dying )
             {
                 ret = -EBUSY;
@@ -327,6 +326,7 @@
             }
             cpupool0->n_dom++;
         }
+        rcu_read_unlock(&domlist_read_lock);
         if ( ret )
             goto out;
     }
diff -r 0965e589fdcc -r d7e6bfa114d0 xen/common/sched_sedf.c
--- a/xen/common/sched_sedf.c   Fri Nov 18 13:32:50 2011 +0000
+++ b/xen/common/sched_sedf.c   Fri Nov 18 13:34:43 2011 +0000
@@ -1304,6 +1304,8 @@
     rcu_read_lock(&domlist_read_lock);
     for_each_domain ( d )
     {
+        if ( (d->cpupool ? d->cpupool->sched : &sched_sedf_def) != ops )
+            continue;
         for_each_vcpu(d, ed)
         {
             if ( !__task_on_queue(ed) && (ed->processor == i) )
@@ -1335,10 +1337,8 @@
 
     /* Sum across all weights. */
     rcu_read_lock(&domlist_read_lock);
-    for_each_domain( d )
+    for_each_domain_in_cpupool( d, c )
     {
-        if ( c != d->cpupool )
-            continue;
         for_each_vcpu( d, p )
         {
             if ( (cpu = p->processor) >= nr_cpus )
@@ -1367,7 +1367,7 @@
 
     /* Adjust all slices (and periods) to the new weight. */
     rcu_read_lock(&domlist_read_lock);
-    for_each_domain( d )
+    for_each_domain_in_cpupool( d, c )
     {
         for_each_vcpu ( d, p )
         {
diff -r 0965e589fdcc -r d7e6bfa114d0 xen/common/schedule.c
--- a/xen/common/schedule.c     Fri Nov 18 13:32:50 2011 +0000
+++ b/xen/common/schedule.c     Fri Nov 18 13:34:43 2011 +0000
@@ -538,11 +538,8 @@
     if ( c == NULL )
         return ret;
 
-    for_each_domain ( d )
+    for_each_domain_in_cpupool ( d, c )
     {
-        if ( d->cpupool != c )
-            continue;
-
         affinity_broken = 0;
 
         for_each_vcpu ( d, v )
diff -r 0965e589fdcc -r d7e6bfa114d0 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h   Fri Nov 18 13:32:50 2011 +0000
+++ b/xen/include/xen/sched.h   Fri Nov 18 13:34:43 2011 +0000
@@ -564,11 +564,31 @@
 extern struct domain *domain_list;
 
 /* Caller must hold the domlist_read_lock or domlist_update_lock. */
+static inline struct domain *first_domain_in_cpupool( struct cpupool *c)
+{
+    struct domain *d;
+    for (d = rcu_dereference(domain_list); d && d->cpupool != c;
+         d = rcu_dereference(d->next_in_list));
+    return d;
+}
+static inline struct domain *next_domain_in_cpupool(
+    struct domain *d, struct cpupool *c)
+{
+    for (d = rcu_dereference(d->next_in_list); d && d->cpupool != c;
+         d = rcu_dereference(d->next_in_list));
+    return d;
+}
+
 #define for_each_domain(_d)                     \
  for ( (_d) = rcu_dereference(domain_list);     \
        (_d) != NULL;                            \
        (_d) = rcu_dereference((_d)->next_in_list )) \
 
+#define for_each_domain_in_cpupool(_d,_c)       \
+ for ( (_d) = first_domain_in_cpupool(_c);      \
+       (_d) != NULL;                            \
+       (_d) = next_domain_in_cpupool((_d), (_c)))
+
 #define for_each_vcpu(_d,_v)                    \
  for ( (_v) = (_d)->vcpu ? (_d)->vcpu[0] : NULL; \
        (_v) != NULL;                            \

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.