Introduce two new module parameters allowing to keep more shadow structures * vsie_shadow_scb_max Override the maximum number of VSIE control blocks / vsie_pages to shadow in guest-1 that are not using the SSCA. KVM will either use this value or the number of current VCPUs. Either way the number will be capped to 256. This is the number of guest-3 control blocks / CPUs to keep shadowed to minimize the repeated shadowing effort. * vsie_shadow_sca_max Override the maximum number of VSIE system control areas / SSCAs to shadow in guest-1. KVM will use a minimum of the current number of vCPUs and a maximum of 256 or this value if it is lower. This is the number of guest-3 system control areas / VMs to keep shadowed to minimize repeated shadowing effort. Signed-off-by: Christoph Schlameuss --- arch/s390/kvm/vsie.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c index 6088a9c31564..5f6dd4b9e9fd 100644 --- a/arch/s390/kvm/vsie.c +++ b/arch/s390/kvm/vsie.c @@ -106,6 +106,16 @@ struct vsie_sca { */ static_assert(!(offsetof(struct vsie_sca, ssca))); +/* maximum vsie shadow scb */ +static unsigned int vsie_shadow_scb_max = 1; +module_param(vsie_shadow_scb_max, uint, 0644); +MODULE_PARM_DESC(vsie_shadow_scb_max, "Maximum number of VSIE shadow control blocks to keep. Values smaller number VCPUs uses number of VCPUs; maximum 256"); + +/* maximum vsie shadow sca */ +static unsigned int vsie_shadow_sca_max = 1; +module_param(vsie_shadow_sca_max, uint, 0644); +MODULE_PARM_DESC(vsie_shadow_sca_max, "Maximum number of VSIE shadow system control areas to keep. Values smaller number of VCPUs uses number of VCPUs; maximum 256"); + static inline hpa_t sca_o_hpa(struct vsie_sca *vsie_sca) { return vsie_sca->sca_o_pages[0].hpa | (vsie_sca->sca_gpa & ~PAGE_MASK); @@ -1063,7 +1073,8 @@ static struct vsie_sca *get_vsie_sca(struct kvm_vcpu *vcpu, struct kvm_s390_sie_ * We want at least #online_vcpus shadows, so every VCPU can execute the * VSIE in parallel. (Worst case all single core VMs.) */ - max_vsie_sca = MIN(atomic_read(&kvm->online_vcpus), KVM_S390_MAX_VSIE_VCPUS); + max_vsie_sca = min_t(unsigned int, max_t(unsigned int, atomic_read(&kvm->online_vcpus), + vsie_shadow_sca_max), KVM_S390_MAX_VSIE_VCPUS); if (kvm->arch.vsie.sca_count < max_vsie_sca) { vsie_sca_new = alloc_vsie_sca(); @@ -1940,7 +1951,8 @@ static struct vsie_page *get_vsie_page(struct kvm_vcpu *vcpu, unsigned long addr put_vsie_page(vsie_page); } - max_vsie_page = atomic_read(&kvm->online_vcpus); + max_vsie_page = min_t(unsigned int, max_t(unsigned int, atomic_read(&kvm->online_vcpus), + vsie_shadow_scb_max), KVM_S390_MAX_VSIE_VCPUS); /* allocate new vsie_page - we will likely need it */ if (kvm->arch.vsie.page_count < max_vsie_page) { -- 2.55.0