mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 20:20:50 +07:00
19ccb76a19
With a KVM guest operating in SMT4 mode (i.e. 4 hardware threads per core), whenever a CPU goes idle, we have to pull all the other hardware threads in the core out of the guest, because the H_CEDE hcall is handled in the kernel. This is inefficient. This adds code to book3s_hv_rmhandlers.S to handle the H_CEDE hcall in real mode. When a guest vcpu does an H_CEDE hcall, we now only exit to the kernel if all the other vcpus in the same core are also idle. Otherwise we mark this vcpu as napping, save state that could be lost in nap mode (mainly GPRs and FPRs), and execute the nap instruction. When the thread wakes up, because of a decrementer or external interrupt, we come back in at kvm_start_guest (from the system reset interrupt vector), find the `napping' flag set in the paca, and go to the resume path. This has some other ramifications. First, when starting a core, we now start all the threads, both those that are immediately runnable and those that are idle. This is so that we don't have to pull all the threads out of the guest when an idle thread gets a decrementer interrupt and wants to start running. In fact the idle threads will all start with the H_CEDE hcall returning; being idle they will just do another H_CEDE immediately and go to nap mode. This required some changes to kvmppc_run_core() and kvmppc_run_vcpu(). These functions have been restructured to make them simpler and clearer. We introduce a level of indirection in the wait queue that gets woken when external and decrementer interrupts get generated for a vcpu, so that we can have the 4 vcpus in a vcore using the same wait queue. We need this because the 4 vcpus are being handled by one thread. Secondly, when we need to exit from the guest to the kernel, we now have to generate an IPI for any napping threads, because an HDEC interrupt doesn't wake up a napping thread. Thirdly, we now need to be able to handle virtual external interrupts and decrementer interrupts becoming pending while a thread is napping, and deliver those interrupts to the guest when the thread wakes. This is done in kvmppc_cede_reentry, just before fast_guest_return. Finally, since we are not using the generic kvm_vcpu_block for book3s_hv, and hence not calling kvm_arch_vcpu_runnable, we can remove the #ifdef from kvm_arch_vcpu_runnable. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Alexander Graf <agraf@suse.de> |
||
---|---|---|
.. | ||
44x_emulate.c | ||
44x_tlb.c | ||
44x_tlb.h | ||
44x.c | ||
book3s_32_mmu_host.c | ||
book3s_32_mmu.c | ||
book3s_32_sr.S | ||
book3s_64_mmu_host.c | ||
book3s_64_mmu_hv.c | ||
book3s_64_mmu.c | ||
book3s_64_slb.S | ||
book3s_64_vio_hv.c | ||
book3s_emulate.c | ||
book3s_exports.c | ||
book3s_hv_builtin.c | ||
book3s_hv_interrupts.S | ||
book3s_hv_rm_mmu.c | ||
book3s_hv_rmhandlers.S | ||
book3s_hv.c | ||
book3s_interrupts.S | ||
book3s_mmu_hpte.c | ||
book3s_paired_singles.c | ||
book3s_pr_papr.c | ||
book3s_pr.c | ||
book3s_rmhandlers.S | ||
book3s_segment.S | ||
book3s.c | ||
booke_emulate.c | ||
booke_interrupts.S | ||
booke.c | ||
booke.h | ||
e500_emulate.c | ||
e500_tlb.c | ||
e500_tlb.h | ||
e500.c | ||
emulate.c | ||
fpu.S | ||
Kconfig | ||
Makefile | ||
powerpc.c | ||
timing.c | ||
timing.h | ||
trace.h |