Skip to content

Commit 968947f

Browse files
Boris Ostrovskyvijay-suman
authored andcommitted
kvm/x86: Inherit userspace's core scheduling cookie
When creating kvm-pit and kvm_nx_huge_page_recovery_worker threads assign them the calling process' core scheduling cookie. Orabug: 34152329 Signed-off-by: Boris Ostrovsky <[email protected]> Reviewed-by: Libo Chen <[email protected]> Reviewed-by: Chris Hyser <[email protected]>
1 parent aebec5f commit 968947f

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,7 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin,
19841984
extern bool tdp_enabled;
19851985

19861986
u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu);
1987+
extern bool inherit_cs_cookie;
19871988

19881989
/*
19891990
* EMULTYPE_NO_DECODE - Set when re-emulating an instruction (after completing

arch/x86/kvm/i8254.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,9 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags)
685685
if (IS_ERR(pit->worker))
686686
goto fail_kthread;
687687

688+
if (inherit_cs_cookie)
689+
sched_cs_copy(current, pit->worker->task);
690+
688691
kthread_init_work(&pit->expired, pit_do_work);
689692

690693
pit->kvm = kvm;

arch/x86/kvm/mmu/mmu.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7578,8 +7578,13 @@ int kvm_mmu_post_init_vm(struct kvm *kvm)
75787578
err = kvm_vm_create_worker_thread(kvm, kvm_nx_huge_page_recovery_worker, 0,
75797579
"kvm-nx-lpage-recovery",
75807580
&kvm->arch.nx_huge_page_recovery_thread);
7581-
if (!err)
7581+
if (!err) {
7582+
if (inherit_cs_cookie)
7583+
sched_cs_copy(current,
7584+
kvm->arch.nx_huge_page_recovery_thread);
7585+
75827586
kthread_unpark(kvm->arch.nx_huge_page_recovery_thread);
7587+
}
75837588

75847589
return err;
75857590
}

arch/x86/kvm/x86.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ module_param(eager_page_split, bool, 0644);
197197
static bool __read_mostly mitigate_smt_rsb;
198198
module_param(mitigate_smt_rsb, bool, 0444);
199199

200+
bool __read_mostly inherit_cs_cookie;
201+
module_param(inherit_cs_cookie, bool, S_IRUGO);
202+
200203
/*
201204
* Restoring the host value for MSRs that are only consumed when running in
202205
* usermode, e.g. SYSCALL MSRs and TSC_AUX, can be deferred until the CPU

0 commit comments

Comments
 (0)