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

[Xen-changelog] [xen master] xen:rtds: Fix bug in budget accounting



commit 514e5eb015cb2c7714a3a3320e4f49c55324c76a
Author:     Meng Xu <mengxu@xxxxxxxxxxxxx>
AuthorDate: Wed Oct 26 15:06:06 2016 -0400
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Thu Oct 27 11:00:03 2016 +0100

    xen:rtds: Fix bug in budget accounting
    
    Bug scenario:
    repl_timer_handler() may be called before rt_schedule() for a VCPU.
    This situation may happen in two scenarios:
    (1) The VCPU misses deadline due to the system is oversubscribed. For 
example,
        the sum of VCPUs utilization on a core is larger than one.
    (2) The VCPU has budget = period, which causes the timers for
        rt_schedule() and repl_timer_handler() are fired at the same time.
    When the situation happens, it causes the following incorrect behavior:
    repl_timer_handler() will update the VCPU period and deadline.
    If the VCPU is still the highest priority one, even with the new deadline,
    it will continue to run, but with new period and deadline.
    Since the budget enforcement timer for the previous period is still armed,
    rt_schedule() will still be called in the new period and enforce the budget
    for the previous period.
    The 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.
    We always update last_start whenever we update cur_deadline for a VCPU.
    
    Signed-off-by: Meng Xu <mengxu@xxxxxxxxxxxxx>
    Reported-by: Dagaen Golomb <dgolomb@xxxxxxxxxxxxx>
    Acked-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
    Release-acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/common/sched_rt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c
index d61804a..2119199 100644
--- a/xen/common/sched_rt.c
+++ b/xen/common/sched_rt.c
@@ -407,6 +407,12 @@ 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
+     */
+    svc->last_start = now;
     svc->cur_budget = svc->budget;
 
     /* TRACE */
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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