Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3035302ybt; Mon, 22 Jun 2020 13:14:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuSTqJjycSsWDlnyuBFx+HB/wxrWBkb2GGUHslMGK4oj1orOVoDOEHH11csN3qpeT1TsQ+ X-Received: by 2002:a17:906:1c93:: with SMTP id g19mr16959557ejh.194.1592856894561; Mon, 22 Jun 2020 13:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592856894; cv=none; d=google.com; s=arc-20160816; b=M0m79x+inX8/ZNHg/rTA471sADlMxHg5u4BgVCkE1GDhNOpTkkD1k3OWqUKOPEpwnO duLcFiC/AjaN9+VH2M4TbBNi+AG1Biqi1LkPNIIIFIIt/fD2ImdaLSMil4njIiZ/vd7y HfaIUqr9fAci0olE5LM9A4SWbLVkcBnjnqzoW1T9xLwBuKX21n1hDcIG+PXq5t71ZEZd UlyEkU+9V45ixwI0WolfVcH6HWEe6BCuGIldmD3aADGhCSxVmq0DMkyi7wlpNLxRbaXT kAUgTOfrRqYQ93ohZLoPreO4Mlc7lYlG7i/5+5n5zXN0uWkhRzX569J2ovac5trXsyfo 7zWw== 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=BA+2ppcD5A9v2ViKjjhG62tGOCoApqGIe1aqMLphvX8=; b=vifyJ5TAk7GRFBywo5G81SlZX7sUgtm1Bt/TvVNy/C4d0YMYWZbNJnl7t0scttvpPL uVVv/tYPMNovkERBlaub8bi3jCne48bg8S9fAAFAXhXaxDxKAxjjP4d2CZBjKyCBFwmc qgeLpzmLKPxC6ghsoHZbklxnh0EnZu/nyqyJDtQ8Bo4a+gfQ6zxLigcQQNpOUSDRTx6x aFLzL0w4xJJsgLOASE4SG6g27D0VYVnb69HmY0tBeTJVbXDBCURE+Ml/JiVCYjDHcZsr 7vNz/3NliWPgDgtALbRY+7/zdCx/cIXRwoxOrL/VX8bEG2vntbo2ovICouC8GyDQZKp5 yrMA== 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 s15si9678929ejq.486.2020.06.22.13.14.31; Mon, 22 Jun 2020 13:14:54 -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 S1730684AbgFVUJU (ORCPT + 99 others); Mon, 22 Jun 2020 16:09:20 -0400 Received: from mga12.intel.com ([192.55.52.136]:60195 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730598AbgFVUJP (ORCPT ); Mon, 22 Jun 2020 16:09:15 -0400 IronPort-SDR: L4LvJnJsu9tKwtPWRJ43cjOJpaTuWYcZR4JBVMGCCZclcLWgvAdf0/qNUBk9uIMZ+H9XYYp/D6 c8CMTa4MXmpg== X-IronPort-AV: E=McAfee;i="6000,8403,9660"; a="123527739" X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="123527739" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2020 13:09:14 -0700 IronPort-SDR: ak1QnlFNmlOJvtP/hUTECRnOQeqVRiIZK96vwGh7pONYJj8Q1FtHto5qAAvNTpvRAMC6k+Twhw /ek8UxKqM3Rw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="318877082" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.152]) by FMSMGA003.fm.intel.com with ESMTP; 22 Jun 2020 13:09:13 -0700 From: Sean Christopherson To: Marc Zyngier , Paolo Bonzini , Arnd Bergmann Cc: James Morse , Julien Thierry , Suzuki K Poulose , 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, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon , Peter Feiner , Peter Shier , Junaid Shahid , Christoffer Dall Subject: [PATCH v2 09/21] KVM: x86/mmu: Separate the memory caches for shadow pages and gfn arrays Date: Mon, 22 Jun 2020 13:08:10 -0700 Message-Id: <20200622200822.4426-10-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200622200822.4426-1-sean.j.christopherson@intel.com> References: <20200622200822.4426-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. Reviewed-by: Ben Gardon 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 7b6ac8fad9c2..376e1653ac41 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