* Avi Kivity <avi@xxxxxxxxxxxx> wrote:
+#ifdef CONFIG_SCHED_KVM
+static __read_mostly struct sched_kvm_hooks kvm_hooks;
+#endif
please just add a current->put_vcpu() function pointer instead of this hooks thing.
static inline void prepare_task_switch(struct rq *rq, struct task_struct *next)
{
+ unload_kvm_vcpu(current);
prepare_lock_switch(rq, next);
prepare_arch_switch(next);
}
@@ -1860,6 +1912,7 @@ static inline void finish_task_switch(struct rq *rq, struct task_struct *prev)
prev_state = prev->state;
finish_arch_switch(prev);
finish_lock_switch(rq, prev);
+ reload_kvm_vcpu(current);
ok, this looks certainly cheap enough from a scheduler POV, and it cleans up the whole KVM/scheduling interaction quite nicely. (I'd not bother with tweaking the migration logic, there's enough incentive for the scheduler to keep tasks from migrating unnecessarily.)