Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3034549ybt; Mon, 22 Jun 2020 13:13:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZHUjJxRU+Ww159D3jucChyybLDrUVZNOkDvcaq7cKqAUnuvFcV/xCWtgd0g9cG2xVxLwn X-Received: by 2002:a05:6402:30b2:: with SMTP id df18mr7427081edb.229.1592856822973; Mon, 22 Jun 2020 13:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592856822; cv=none; d=google.com; s=arc-20160816; b=bngIizwth3/5wMN2nef+h/9TBsG5gF4nn2usUd8wbVOPMvR/fUFXW2fHdXX706qVuE Kr/7FZCAVXjhEmAPQM49H6wDujjZqXQHPHWp6gFZvnCSpubLW6obE1kdP8bUI+7zORk6 hzxNYO+Fsq2+ZId59kytaWAbePrK+ucgofB01nSA7a28Ic5hWgYcmRZx2TxTuhQX86xR ibTQngqoXztqwoZ1bQmaZs3cCl7eWuP0DN4f3fFZ6MZPZNuY2NCdpIR9zuJs+OX4t5n6 d4mIfSP6i5tn2HWOnmwebHrc3A6/JbHbzofFPzCaPawXwGk1o8ceb0SfdEFP9sgbpAcz ZNEg== 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=zPU+X38pqAYtyWmC4YVIC3rxA6SUvK5aJeUpSBclZzo=; b=eLzHgLqWPDyluLbtd/mRduesefiitCoxT0AbtafqphhWXc1VZLcrA3wf2ffMoUlmmw VqHa/0fLxNmJuuLkZUmfwIRMOh0T5zzMljhYnxqR9CAmT1d9nww7b+oCyAV0jIWUgObX HaAxwxOZCy3njI34KG+9u9qd9mdH/iY1qXyLtuTQd7K77OE1BMOT7v4NAOw1OIy/8o2r LN0Kxqg9NgMNniYA03/TmhdCtTzDJDZpMDye0v3WDSx7M0InQYM425NqkpywgG5UEvo/ RYq/7I4KccJG4RNCl/ySfG3D2pL0uEy6A7v1rjBm1CZiihnfPEAn97cYm/ogSxsr0LdT MSrg== 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 gq24si9394245ejb.55.2020.06.22.13.13.19; Mon, 22 Jun 2020 13:13:42 -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 S1730373AbgFVUK6 (ORCPT + 99 others); Mon, 22 Jun 2020 16:10:58 -0400 Received: from mga12.intel.com ([192.55.52.136]:60218 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730616AbgFVUJQ (ORCPT ); Mon, 22 Jun 2020 16:09:16 -0400 IronPort-SDR: +xuQJMjh3PXNsG2Re7levRsnwXHdP6/JF1+6vP6CWmqongtoRXOXf3bXwoyejOMEvL/tJCDIJZ FaHZJn3JxU4w== X-IronPort-AV: E=McAfee;i="6000,8403,9660"; a="123527746" X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="123527746" 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:16 -0700 IronPort-SDR: w4y4RhIxwywK7gLZhcnZ8zJZ2/tmsaEeOuzYXpKDxFqbOfafiMe34xl3o0yCJyETNVLXHqptHz oWXxrnFLUUEQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="318877091" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.152]) by FMSMGA003.fm.intel.com with ESMTP; 22 Jun 2020 13:09:15 -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 11/21] KVM: x86/mmu: Zero allocate shadow pages (outside of mmu_lock) Date: Mon, 22 Jun 2020 13:08:12 -0700 Message-Id: <20200622200822.4426-12-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 Set __GFP_ZERO for the shadow page memory cache and drop the explicit clear_page() from kvm_mmu_get_page(). This moves the cost of zeroing a page to the allocation time of the physical page, i.e. when topping up the memory caches, and thus avoids having to zero out an entire page while holding mmu_lock. Cc: Peter Feiner Cc: Peter Shier Cc: Junaid Shahid Cc: Jim Mattson Suggested-by: Ben Gardon Reviewed-by: Ben Gardon Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 6b0ec9060786..a8f8eebf67df 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -2545,7 +2545,6 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu, if (level > PG_LEVEL_4K && need_sync) flush |= kvm_sync_pages(vcpu, gfn, &invalid_list); } - clear_page(sp->spt); trace_kvm_mmu_get_page(sp, true); kvm_mmu_flush_or_zap(vcpu, &invalid_list, false, flush); @@ -5687,6 +5686,8 @@ int kvm_mmu_create(struct kvm_vcpu *vcpu) vcpu->arch.mmu_page_header_cache.kmem_cache = mmu_page_header_cache; vcpu->arch.mmu_page_header_cache.gfp_zero = __GFP_ZERO; + vcpu->arch.mmu_shadow_page_cache.gfp_zero = __GFP_ZERO; + vcpu->arch.mmu = &vcpu->arch.root_mmu; vcpu->arch.walk_mmu = &vcpu->arch.root_mmu; -- 2.26.0