Commits
Alexandr Andreev authored and Pavel Emelianov committed e1c1be83b4a
[SCHED] VCPU should be initialized completely before deletion There is a race in vsched_del_vcpu() - we can kill migration_thread() even if it has not started yet, i.e. migration_thread() function is not called at all. So, migrate_live_tasks() and migrate_dead_tasks() will not be called on this vcpu while migration thread is killed. But there can be some tasks, that have already migrated on this vcpu, because this vcpu is already marked as online. This bug can be easily reproduced. On a busy host with many running tasks user can run: In this case, after the second vzctl, migration thread on VCPU 2 will be created and just waked up, but it can be not really started (scheduled) yet if there are a lot of other more priority tasks running on the host. If it will not be scheduled before the third vzctl call, there will be kernel bug in vsched_del_vcpu(): ... /* * all tasks should migrate from this VCPU somewhere, * also, since this moment VCPU is offline, so migration_thread * won't accept any new tasks... */ vmigration_call(&migration_notifier, CPU_DEAD, vcpu); BUG_ON(rq->nr_running != 0); ...