mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 18:23:57 -06:00
spapr: avoid overhead of finding vhyp class in critical operations
PPC_VIRTUAL_HYPERVISOR_GET_CLASS is used in critical operations like interrupts and TLB misses and is quite costly. Running the kvm-unit-tests sieve program with radix MMU enabled thrashes the TCG TLB and spends a lot of time in TLB and page table walking code. The test takes 67 seconds to complete with a lot of time being spent in code related to finding the vhyp class: 12.01% [.] g_str_hash 8.94% [.] g_hash_table_lookup 8.06% [.] object_class_dynamic_cast 6.21% [.] address_space_ldq 4.94% [.] __strcmp_avx2 4.28% [.] tlb_set_page_full 4.08% [.] address_space_translate_internal 3.17% [.] object_class_dynamic_cast_assert 2.84% [.] ppc_radix64_xlate Keep a pointer to the class and avoid this lookup. This reduces the execution time to 40 seconds. Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
This commit is contained in:
parent
70581940ca
commit
c700b5e162
8 changed files with 17 additions and 40 deletions
|
@ -400,6 +400,7 @@ static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason)
|
||||||
machine->fdt = fdt;
|
machine->fdt = fdt;
|
||||||
|
|
||||||
pm->cpu->vhyp = PPC_VIRTUAL_HYPERVISOR(machine);
|
pm->cpu->vhyp = PPC_VIRTUAL_HYPERVISOR(machine);
|
||||||
|
pm->cpu->vhyp_class = PPC_VIRTUAL_HYPERVISOR_GET_CLASS(pm->cpu->vhyp);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum pegasos2_rtas_tokens {
|
enum pegasos2_rtas_tokens {
|
||||||
|
|
|
@ -1435,6 +1435,7 @@ struct ArchCPU {
|
||||||
int vcpu_id;
|
int vcpu_id;
|
||||||
uint32_t compat_pvr;
|
uint32_t compat_pvr;
|
||||||
PPCVirtualHypervisor *vhyp;
|
PPCVirtualHypervisor *vhyp;
|
||||||
|
PPCVirtualHypervisorClass *vhyp_class;
|
||||||
void *machine_data;
|
void *machine_data;
|
||||||
int32_t node_id; /* NUMA node this CPU belongs to */
|
int32_t node_id; /* NUMA node this CPU belongs to */
|
||||||
PPCHash64Options *hash64_opts;
|
PPCHash64Options *hash64_opts;
|
||||||
|
@ -1532,7 +1533,7 @@ DECLARE_OBJ_CHECKERS(PPCVirtualHypervisor, PPCVirtualHypervisorClass,
|
||||||
|
|
||||||
static inline bool vhyp_cpu_in_nested(PowerPCCPU *cpu)
|
static inline bool vhyp_cpu_in_nested(PowerPCCPU *cpu)
|
||||||
{
|
{
|
||||||
return PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp)->cpu_in_nested(cpu);
|
return cpu->vhyp_class->cpu_in_nested(cpu);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_USER_ONLY */
|
#endif /* CONFIG_USER_ONLY */
|
||||||
|
|
||||||
|
|
|
@ -6661,6 +6661,7 @@ void cpu_ppc_set_vhyp(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp)
|
||||||
CPUPPCState *env = &cpu->env;
|
CPUPPCState *env = &cpu->env;
|
||||||
|
|
||||||
cpu->vhyp = vhyp;
|
cpu->vhyp = vhyp;
|
||||||
|
cpu->vhyp_class = PPC_VIRTUAL_HYPERVISOR_GET_CLASS(vhyp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* With a virtual hypervisor mode we never allow the CPU to go
|
* With a virtual hypervisor mode we never allow the CPU to go
|
||||||
|
@ -7248,9 +7249,7 @@ static void ppc_cpu_exec_enter(CPUState *cs)
|
||||||
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
||||||
|
|
||||||
if (cpu->vhyp) {
|
if (cpu->vhyp) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
cpu->vhyp_class->cpu_exec_enter(cpu->vhyp, cpu);
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
vhc->cpu_exec_enter(cpu->vhyp, cpu);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7259,9 +7258,7 @@ static void ppc_cpu_exec_exit(CPUState *cs)
|
||||||
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
||||||
|
|
||||||
if (cpu->vhyp) {
|
if (cpu->vhyp) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
cpu->vhyp_class->cpu_exec_exit(cpu->vhyp, cpu);
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
vhc->cpu_exec_exit(cpu->vhyp, cpu);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_TCG */
|
#endif /* CONFIG_TCG */
|
||||||
|
|
|
@ -794,9 +794,7 @@ static void powerpc_excp_7xx(PowerPCCPU *cpu, int excp)
|
||||||
* HV mode, we need to keep hypercall support.
|
* HV mode, we need to keep hypercall support.
|
||||||
*/
|
*/
|
||||||
if (lev == 1 && cpu->vhyp) {
|
if (lev == 1 && cpu->vhyp) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
cpu->vhyp_class->hypercall(cpu->vhyp, cpu);
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
vhc->hypercall(cpu->vhyp, cpu);
|
|
||||||
powerpc_reset_excp_state(cpu);
|
powerpc_reset_excp_state(cpu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -946,9 +944,7 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp)
|
||||||
* HV mode, we need to keep hypercall support.
|
* HV mode, we need to keep hypercall support.
|
||||||
*/
|
*/
|
||||||
if (lev == 1 && cpu->vhyp) {
|
if (lev == 1 && cpu->vhyp) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
cpu->vhyp_class->hypercall(cpu->vhyp, cpu);
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
vhc->hypercall(cpu->vhyp, cpu);
|
|
||||||
powerpc_reset_excp_state(cpu);
|
powerpc_reset_excp_state(cpu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1437,9 +1433,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
|
||||||
|
|
||||||
/* "PAPR mode" built-in hypercall emulation */
|
/* "PAPR mode" built-in hypercall emulation */
|
||||||
if (lev == 1 && books_vhyp_handles_hcall(cpu)) {
|
if (lev == 1 && books_vhyp_handles_hcall(cpu)) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
cpu->vhyp_class->hypercall(cpu->vhyp, cpu);
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
vhc->hypercall(cpu->vhyp, cpu);
|
|
||||||
powerpc_reset_excp_state(cpu);
|
powerpc_reset_excp_state(cpu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1574,10 +1568,8 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((new_msr & MSR_HVB) && books_vhyp_handles_hv_excp(cpu)) {
|
if ((new_msr & MSR_HVB) && books_vhyp_handles_hv_excp(cpu)) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
/* Deliver interrupt to L1 by returning from the H_ENTER_NESTED call */
|
/* Deliver interrupt to L1 by returning from the H_ENTER_NESTED call */
|
||||||
vhc->deliver_hv_excp(cpu, excp);
|
cpu->vhyp_class->deliver_hv_excp(cpu, excp);
|
||||||
powerpc_reset_excp_state(cpu);
|
powerpc_reset_excp_state(cpu);
|
||||||
} else {
|
} else {
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
|
|
|
@ -865,9 +865,7 @@ int kvmppc_put_books_sregs(PowerPCCPU *cpu)
|
||||||
sregs.pvr = env->spr[SPR_PVR];
|
sregs.pvr = env->spr[SPR_PVR];
|
||||||
|
|
||||||
if (cpu->vhyp) {
|
if (cpu->vhyp) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
sregs.u.s.sdr1 = cpu->vhyp_class->encode_hpt_for_kvm_pr(cpu->vhyp);
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
sregs.u.s.sdr1 = vhc->encode_hpt_for_kvm_pr(cpu->vhyp);
|
|
||||||
} else {
|
} else {
|
||||||
sregs.u.s.sdr1 = env->spr[SPR_SDR1];
|
sregs.u.s.sdr1 = env->spr[SPR_SDR1];
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,9 +108,7 @@ static inline hwaddr ppc_hash64_hpt_mask(PowerPCCPU *cpu)
|
||||||
uint64_t base;
|
uint64_t base;
|
||||||
|
|
||||||
if (cpu->vhyp) {
|
if (cpu->vhyp) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
return cpu->vhyp_class->hpt_mask(cpu->vhyp);
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
return vhc->hpt_mask(cpu->vhyp);
|
|
||||||
}
|
}
|
||||||
if (cpu->env.mmu_model == POWERPC_MMU_3_00) {
|
if (cpu->env.mmu_model == POWERPC_MMU_3_00) {
|
||||||
ppc_v3_pate_t pate;
|
ppc_v3_pate_t pate;
|
||||||
|
|
|
@ -517,9 +517,7 @@ const ppc_hash_pte64_t *ppc_hash64_map_hptes(PowerPCCPU *cpu,
|
||||||
const ppc_hash_pte64_t *hptes;
|
const ppc_hash_pte64_t *hptes;
|
||||||
|
|
||||||
if (cpu->vhyp) {
|
if (cpu->vhyp) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
return cpu->vhyp_class->map_hptes(cpu->vhyp, ptex, n);
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
return vhc->map_hptes(cpu->vhyp, ptex, n);
|
|
||||||
}
|
}
|
||||||
base = ppc_hash64_hpt_base(cpu);
|
base = ppc_hash64_hpt_base(cpu);
|
||||||
|
|
||||||
|
@ -539,9 +537,7 @@ void ppc_hash64_unmap_hptes(PowerPCCPU *cpu, const ppc_hash_pte64_t *hptes,
|
||||||
hwaddr ptex, int n)
|
hwaddr ptex, int n)
|
||||||
{
|
{
|
||||||
if (cpu->vhyp) {
|
if (cpu->vhyp) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
cpu->vhyp_class->unmap_hptes(cpu->vhyp, hptes, ptex, n);
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
vhc->unmap_hptes(cpu->vhyp, hptes, ptex, n);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -821,9 +817,7 @@ static void ppc_hash64_set_r(PowerPCCPU *cpu, hwaddr ptex, uint64_t pte1)
|
||||||
hwaddr base, offset = ptex * HASH_PTE_SIZE_64 + HPTE64_DW1_R;
|
hwaddr base, offset = ptex * HASH_PTE_SIZE_64 + HPTE64_DW1_R;
|
||||||
|
|
||||||
if (cpu->vhyp) {
|
if (cpu->vhyp) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
cpu->vhyp_class->hpte_set_r(cpu->vhyp, ptex, pte1);
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
vhc->hpte_set_r(cpu->vhyp, ptex, pte1);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
base = ppc_hash64_hpt_base(cpu);
|
base = ppc_hash64_hpt_base(cpu);
|
||||||
|
@ -838,9 +832,7 @@ static void ppc_hash64_set_c(PowerPCCPU *cpu, hwaddr ptex, uint64_t pte1)
|
||||||
hwaddr base, offset = ptex * HASH_PTE_SIZE_64 + HPTE64_DW1_C;
|
hwaddr base, offset = ptex * HASH_PTE_SIZE_64 + HPTE64_DW1_C;
|
||||||
|
|
||||||
if (cpu->vhyp) {
|
if (cpu->vhyp) {
|
||||||
PPCVirtualHypervisorClass *vhc =
|
cpu->vhyp_class->hpte_set_c(cpu->vhyp, ptex, pte1);
|
||||||
PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
vhc->hpte_set_c(cpu->vhyp, ptex, pte1);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
base = ppc_hash64_hpt_base(cpu);
|
base = ppc_hash64_hpt_base(cpu);
|
||||||
|
|
|
@ -678,9 +678,7 @@ static bool ppc_radix64_xlate_impl(PowerPCCPU *cpu, vaddr eaddr,
|
||||||
|
|
||||||
/* Get Partition Table */
|
/* Get Partition Table */
|
||||||
if (cpu->vhyp) {
|
if (cpu->vhyp) {
|
||||||
PPCVirtualHypervisorClass *vhc;
|
if (!cpu->vhyp_class->get_pate(cpu->vhyp, cpu, lpid, &pate)) {
|
||||||
vhc = PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
|
|
||||||
if (!vhc->get_pate(cpu->vhyp, cpu, lpid, &pate)) {
|
|
||||||
if (guest_visible) {
|
if (guest_visible) {
|
||||||
ppc_radix64_raise_hsi(cpu, access_type, eaddr, eaddr,
|
ppc_radix64_raise_hsi(cpu, access_type, eaddr, eaddr,
|
||||||
DSISR_R_BADCONFIG);
|
DSISR_R_BADCONFIG);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue