Message ID | 0fb7b738-5637-4e9a-ad2e-6b61a894348a@default (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
>>> On 08.10.17 at 07:29, <dongli.zhang@oracle.com> wrote: > Whatever the fix would be applied to guest kernel side, I think the root cause > is because xen hypervisor returns a RUNSTATE_runnable time less than the > previous one before live migration. > > As I am not clear enough with xen scheduling, I do not understand why > RUNSTATE_runnable cputime is decreased after live migration. Isn't this simply because accounting starts from zero again in the new (migrated) domain? If so, that's nothing that ought to change, it would still be the guest kernel responsible to take care of if it matters to it. Jan
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index a846cf8..3546e21 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -274,11 +274,17 @@ static __always_inline cputime_t steal_account_process_time(cputime_t maxtime) if (static_key_false(¶virt_steal_enabled)) { cputime_t steal_cputime; u64 steal; + s64 steal_diff; steal = paravirt_steal_clock(smp_processor_id()); - steal -= this_rq()->prev_steal_time; + steal_diff = steal - this_rq()->prev_steal_time; - steal_cputime = min(nsecs_to_cputime(steal), maxtime); + if (steal_diff < 0) { + this_rq()->prev_steal_time = steal; + return 0; + } + + steal_cputime = min(nsecs_to_cputime(steal_diff), maxtime); account_steal_time(steal_cputime); this_rq()->prev_steal_time += cputime_to_nsecs(steal_cputime);