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

[Xen-changelog] Whenever the slice of a domU is set to 0, sedf_adjdom() sets extraweight



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 5bf4d9a9694fe45f19dff8b1b04936358483f2f2
# Parent  323d40eefbced4e9374e91502bb08027ae753c50
Whenever the slice of a domU is set to 0, sedf_adjdom() sets extraweight
to 0.  Later, in desched_extra_dom(), if the extrawight is not set, the
vcpu's score is calculated with this:

 /*domain was running in L1 extraq => score is inverse of
   utilization and is used somewhat incremental!*/
   if ( !inf->extraweight )
       /*NB: use fixed point arithmetic with 10 bits*/
       inf->score[EXTRA_UTIL_Q] = (inf->period << 10) /
           inf->slice;

Which can result in a divide by zero.

This changeset adds a comments and additional sanity check to prevent this
case from crashing Xen.

Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>

diff -r 323d40eefbce -r 5bf4d9a9694f xen/common/sched_sedf.c
--- a/xen/common/sched_sedf.c   Thu Feb 23 10:27:35 2006
+++ b/xen/common/sched_sedf.c   Thu Feb 23 10:31:01 2006
@@ -1609,15 +1609,19 @@
         else {
             /*time driven domains*/
             for_each_vcpu(p, v) {
-                /* sanity checking! */
-                if(cmd->u.sedf.slice > cmd->u.sedf.period )
+                /*
+                 * Sanity checking: note that disabling extra weight requires
+                 * that we set a non-zero slice.
+                 */
+                if ( (cmd->u.sedf.slice == 0) ||
+                     (cmd->u.sedf.slice > cmd->u.sedf.period) )
                     return -EINVAL;
                 EDOM_INFO(v)->weight = 0;
                 EDOM_INFO(v)->extraweight = 0;
                 EDOM_INFO(v)->period_orig = 
-                    EDOM_INFO(v)->period   = cmd->u.sedf.period;
+                    EDOM_INFO(v)->period  = cmd->u.sedf.period;
                 EDOM_INFO(v)->slice_orig  = 
-                    EDOM_INFO(v)->slice    = cmd->u.sedf.slice;
+                    EDOM_INFO(v)->slice   = cmd->u.sedf.slice;
             }
         }
         if (sedf_adjust_weights(cmd))

_______________________________________________
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®.