Re: [PATCH 17/24] sched/fair: Implement delayed dequeue
From: Peter Zijlstra
Date: Thu Oct 10 2024 - 04:41:07 EST
On Wed, Oct 09, 2024 at 07:49:54PM -0700, Sean Christopherson wrote:
> TL;DR: Code that checks task_struct.on_rq may be broken by this commit.
Correct, and while I did look at quite a few, I did miss KVM used it,
damn.
> Peter,
>
> Any thoughts on how best to handle this? The below hack-a-fix resolves the issue,
> but it's obviously not appropriate. KVM uses vcpu->preempted for more than just
> posted interrupts, so KVM needs equivalent functionality to current->on-rq as it
> was before this commit.
>
> @@ -6387,7 +6390,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
>
> WRITE_ONCE(vcpu->scheduled_out, true);
>
> - if (current->on_rq && vcpu->wants_to_run) {
> + if (se_runnable(¤t->se) && vcpu->wants_to_run) {
> WRITE_ONCE(vcpu->preempted, true);
> WRITE_ONCE(vcpu->ready, true);
> }
se_runnable() isn't quite right, but yes, a helper along those lines is
probably best. Let me try and grep more to see if there's others I
missed as well :/