Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2462337ybg; Fri, 5 Jun 2020 14:44:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDDjcZ8TWYhq334KmI/jNwllnNklX0CVOkgbHgIBzwzhVWOfGqXadNw8+vsS4UT/cCan8m X-Received: by 2002:a17:906:af84:: with SMTP id mj4mr10240066ejb.473.1591393446812; Fri, 05 Jun 2020 14:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591393446; cv=none; d=google.com; s=arc-20160816; b=mLGn/Itas1KS+gS5AkYCkkRDwcGEkZpMHdfdRf+H1Te6CGNLsaavdomdOnaSDI4SLq zyQbvHvsANgFqf+zi5/BJWMiJpZJdc8dxcNt2/xUFAGLk29LdaPhUIQL5JKrWl4e/c4R uHmMNh8cD+Wp3ur739UthFGJ0YwA4MBNKGBtjJIX7b4NoAnJs1we1hewANxP53Qu3K93 rXjUCdLzmbvyDGfepxwHVm06+wSf6eI32DzBpa5ZJMrrYtw8AzVqY0SVcmnWX0yPrp9G AoKfo2q8VcwuQ05ecTqnNdftgahUR8P11Nu53eYSr1fLcwMny5k5zoJk3ZGGtuq7jOHX sUnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=JX1cofUIhRB6BwR4qBQZeUyVj5YkG5UQb+bFqTTpymM=; b=SVlKqav61jRjHvM02svK4MiqrNXR8vE5tgtE7zFlYY2xjFJpW8ZhUoq7Qn/QII+3Ld CrFTRCP/Y0Q29QkD4+OQkTg3XA7oa3T1oRvVtSunGz+6HdcXfg25PjcaOYZR9CBNd9Cx iJHSnP4nDu/pzL539k5h731fUsy8TNfTlbJVHf+qY35K4d6t6JcvyFBg6aF8foRs15Fj BXuEqPNSy6QKtzPbLMstEfQPnEcnJjbhW704NkXtMRB2GHshOc0qsrCbW11JU94oD2pT 7aO0y8XWt+LGEO9BpeIzv8bzPqu1DIE4WRjmDT+a42tjKM1/hMhlcKvv6qKD2zByZyA/ 3lug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i1si1646724ejr.634.2020.06.05.14.43.44; Fri, 05 Jun 2020 14:44:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728664AbgFEVjU (ORCPT + 99 others); Fri, 5 Jun 2020 17:39:20 -0400 Received: from mga02.intel.com ([134.134.136.20]:55947 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728406AbgFEVjJ (ORCPT ); Fri, 5 Jun 2020 17:39:09 -0400 IronPort-SDR: siOTqAqkBZhYWPTxFVOp41r96cKgQAPsVwrFd/YQBqUcs8WT/h03hbZpOM8WHfo9PakWP44bjg IcxeInor7JrQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2020 14:39:08 -0700 IronPort-SDR: cEudBF59LK3CTMPSDdTBbkcm2oAb/IvJgot/66IKxKiXC9zDyuWMBiauqZf470L4+E7qPhWsaa pirhGky+lfRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,477,1583222400"; d="scan'208";a="287860892" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.152]) by orsmga002.jf.intel.com with ESMTP; 05 Jun 2020 14:39:08 -0700 From: Sean Christopherson To: Marc Zyngier , Paul Mackerras , Christian Borntraeger , Janosch Frank , Paolo Bonzini Cc: James Morse , Julien Thierry , Suzuki K Poulose , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Feiner , Peter Shier , Junaid Shahid , Ben Gardon , Christoffer Dall Subject: [PATCH 09/21] KVM: x86/mmu: Separate the memory caches for shadow pages and gfn arrays Date: Fri, 5 Jun 2020 14:38:41 -0700 Message-Id: <20200605213853.14959-10-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200605213853.14959-1-sean.j.christopherson@intel.com> References: <20200605213853.14959-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use separate caches for allocating shadow pages versus gfn arrays. This sets the stage for specifying __GFP_ZERO when allocating shadow pages without incurring extra cost for gfn arrays. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/mmu/mmu.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 16347b050754..e7a427547557 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -636,7 +636,8 @@ struct kvm_vcpu_arch { struct kvm_mmu *walk_mmu; struct kvm_mmu_memory_cache mmu_pte_list_desc_cache; - struct kvm_mmu_memory_cache mmu_page_cache; + struct kvm_mmu_memory_cache mmu_shadow_page_cache; + struct kvm_mmu_memory_cache mmu_gfn_array_cache; struct kvm_mmu_memory_cache mmu_page_header_cache; /* diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 451e0365e5dd..d245acece3cd 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -1108,8 +1108,12 @@ static int mmu_topup_memory_caches(struct kvm_vcpu *vcpu) 1 + PT64_ROOT_MAX_LEVEL + PTE_PREFETCH_NUM); if (r) return r; - r = mmu_topup_memory_cache(&vcpu->arch.mmu_page_cache, - 2 * PT64_ROOT_MAX_LEVEL); + r = mmu_topup_memory_cache(&vcpu->arch.mmu_shadow_page_cache, + PT64_ROOT_MAX_LEVEL); + if (r) + return r; + r = mmu_topup_memory_cache(&vcpu->arch.mmu_gfn_array_cache, + PT64_ROOT_MAX_LEVEL); if (r) return r; return mmu_topup_memory_cache(&vcpu->arch.mmu_page_header_cache, @@ -1119,7 +1123,8 @@ static int mmu_topup_memory_caches(struct kvm_vcpu *vcpu) static void mmu_free_memory_caches(struct kvm_vcpu *vcpu) { mmu_free_memory_cache(&vcpu->arch.mmu_pte_list_desc_cache); - mmu_free_memory_cache(&vcpu->arch.mmu_page_cache); + mmu_free_memory_cache(&vcpu->arch.mmu_shadow_page_cache); + mmu_free_memory_cache(&vcpu->arch.mmu_gfn_array_cache); mmu_free_memory_cache(&vcpu->arch.mmu_page_header_cache); } @@ -2096,9 +2101,9 @@ static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu, int direct struct kvm_mmu_page *sp; sp = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_header_cache); - sp->spt = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_cache); + sp->spt = mmu_memory_cache_alloc(&vcpu->arch.mmu_shadow_page_cache); if (!direct) - sp->gfns = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_cache); + sp->gfns = mmu_memory_cache_alloc(&vcpu->arch.mmu_gfn_array_cache); set_page_private(virt_to_page(sp->spt), (unsigned long)sp); /* -- 2.26.0