Bug scenario:
While a VCPU is running on a core, it may misses its deadline.
Then repl_timer_handler() will update the VCPU period and deadline.
The VCPU may have high priority with the new deadline and repl_timer_handler()
decides to keep the VCPU running on the core, but with new period and deadline.
However, the budget enforcement timer for the previous period is still armed.
When rt_schedule() is called in the new period to enforce the budget
for the previous period, current burn_budget() will deduct the time spent
in previous period from the budget in current period, which is incorrect.

Fix:
We keeps last_start always within the current period for a VCPU, so that
We only deduct the time spent in the current period from the VCPU budget.

Signed-off-by: Meng Xu <men...@cis.upenn.edu>
Reported-by: Dagaen Golomb <dgol...@cis.upenn.edu>
---
Cc: Dario Faggioli <dario.faggi...@citrix.com>
Cc: George Dunlap <george.dun...@eu.citrix.com>
Cc: Wei Liu <wei.l...@citrix.com>
Cc: Linh Thi Xuan Phan <linhp...@cis.upenn.edu>
Cc: Haoran Li <lihao...@wustl.edu>
Cc: Meng Xu <xumengpa...@gmail.com>
Cc: Dagaen Golomb <dgol...@cis.upenn.edu>
Cc: Tianyang Chen <ti...@cis.upenn.edu>
---
Changes from v1:
* Change commit message to make the bug scenario easire to understand;
* The two bug scenarios described in v1 can be actually fixed by this patch;
  so we do not need to change the runq_tickle
---
 xen/common/sched_rt.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c
index d95f798..ff17bd2 100644
--- a/xen/common/sched_rt.c
+++ b/xen/common/sched_rt.c
@@ -407,6 +407,14 @@ rt_update_deadline(s_time_t now, struct rt_vcpu *svc)
         svc->cur_deadline += count * svc->period;
     }
 
+    /*
+     * svc may be scheduled to run immediately after it misses deadline
+     * Then rt_update_deadline is called before rt_schedule, which 
+     * should only deduct the time spent in current period from the budget
+     */
+    if ( svc->last_start < (svc->cur_deadline - svc->period) )
+        svc->last_start = svc->cur_deadline - svc->period;
+
     svc->cur_budget = svc->budget;
 
     /* TRACE */
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

Reply via email to