From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ryan Harper Subject: [PATCH] xen: fix empty slice bug in sedf_adjdom() Date: Wed, 22 Feb 2006 15:39:06 -0600 Message-ID: <20060222213906.GD3263@us.ibm.com> References: <20060110100113.39b3adf1@frecb000711.frec.bull.fr> <20060113093336.4f0f1da6@frecb000711.frec.bull.fr> <20060113105909.0da48d6b@frecb000711.frec.bull.fr> <336422f645fae4845f0ab17bfdc02206@cl.cam.ac.uk> <20060202133746.2e7f9429@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20060202133746.2e7f9429@localhost.localdomain> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Guillaume Thouvenin Cc: khoa@us.ibm.com, xen-devel@lists.xensource.com, JEAN-PIERRE DION , Gerrit Huizenga List-Id: xen-devel@lists.xenproject.org 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. The attached patch adds a comments and additional sanity check to prevent this case from crashing Xen. -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx (512) 838-9253 T/L: 678-9253 ryanh@us.ibm.com diffstat output: sched_sedf.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Signed-off-by: Ryan Harper --- diff -r 697fac283c9e xen/common/sched_sedf.c --- a/xen/common/sched_sedf.c Wed Feb 22 19:11:23 2006 +++ b/xen/common/sched_sedf.c Wed Feb 22 15:02:21 2006 @@ -1610,10 +1610,10 @@ /*time driven domains*/ for_each_vcpu(p, v) { /* sanity checking! */ - if(cmd->u.sedf.slice > cmd->u.sedf.period ) + if(!cmd->u.sedf.slice || cmd->u.sedf.slice > cmd->u.sedf.period) return -EINVAL; EDOM_INFO(v)->weight = 0; - EDOM_INFO(v)->extraweight = 0; + EDOM_INFO(v)->extraweight = 0; /* disabling extra weight requires non-zere slice */ EDOM_INFO(v)->period_orig = EDOM_INFO(v)->period = cmd->u.sedf.period; EDOM_INFO(v)->slice_orig =