Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1555640pxa; Thu, 6 Aug 2020 10:10:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6eUDjzP7B6ymuO775WnySEkgXw+VLrtN8scOhL4PSKlfseuaGETEnLgtUke89MAL7u6Hx X-Received: by 2002:a17:906:15cc:: with SMTP id l12mr5555631ejd.7.1596733830094; Thu, 06 Aug 2020 10:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596733830; cv=none; d=google.com; s=arc-20160816; b=tTdB7K7Dkd/e1CizPcRzYRifCQ5xDRELfpK6JCg6OsW5/rEKvgaye3DHKz+YPoIrX9 C/HjFwPzx950HVNRqB5P82hX2v+UH/v2JqQY4XpfnhODvEOoH3Yvr3iSjqJDTqpjkE+q gXa15zLn0uQrMKsnqD8U6bwz6pqUaWTXRtz19Z2vMidLWv6bx4VXlw06gtbNSwW04L6k T1bjPbn/YC6CQjF3tcQtC7okDXoiUaFtSH8Lwn/ppGd5FrNlZOlfb2bU1NFWLFqxgPsJ PhK5l9gYbec36p1Fke53C5mz5IUk5IPDq69Ko/9YwH4B6rk5AOnH7cQhzlYG2ooUkoxB ldcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nC6PJfNXVU4vFSBxvbjKSl0ryoqOjAjd9RWGvuVHbDM=; b=k00o3iIpX9xg59fOvO2dfPrBw5mZtpDusCejM49gttGm9HBl7x12XITQdefX+LQCxX pmwU+UoyqINFYqKslQxFPQejwloExnIePGTkMwdSMMyVxHD23gMQS/7A84S+TEMoKGbU nF8xXqRE6GIA7QRy0WpFVnkrOOgHmbyaovC2UFz3VnVVvqtHHmi0n3AF5VRXJdDRYNgI Vc8UPHcxY5IWNu3ePtzPpbVA0jT7PeEJfZIItWQcma21tnrufUvzmqTeOhVhXvf1xqoA 2gAm6cj0NPWWRa0b/RXn7jWDY5QYWcahfKFTyWrz+HpsaPBKjxD8DFUzwkT5UW1deDT4 YUYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oLZpvRf1; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch2si3468928edb.244.2020.08.06.10.10.07; Thu, 06 Aug 2020 10:10:30 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=oLZpvRf1; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729861AbgHFRJH (ORCPT + 99 others); Thu, 6 Aug 2020 13:09:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727081AbgHFRGE (ORCPT ); Thu, 6 Aug 2020 13:06:04 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52D40C06138D for ; Thu, 6 Aug 2020 10:04:11 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id l17so50335044iok.7 for ; Thu, 06 Aug 2020 10:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nC6PJfNXVU4vFSBxvbjKSl0ryoqOjAjd9RWGvuVHbDM=; b=oLZpvRf1kTJ4eibRUBcjxdeDvtdZOPtNEomtrXn5C94Hbs8Rj8dHrZnApxdRFEwjCl WBc8yQHq3KYajW40zb9qdXGQih4IRSt9uGsN29kdUUfkeijhhBhk6xJqY18RwkHQExnz En5loq1sNJvdr9jvuHobjEotIrsWjcIKsW/9iQLsjtEx4p2gHXPoyKfw1uUZjlnoMgEr cwfI76oogIyUiUU8qlY+Ugbn9lc35uMPWzQr+rfeC0c6wD3GxBi6pVfoIgQbJ8oLdNTa F4WcNsXK48XhtTQShEm/52gGR2owP8y3C7Uh7G0GJAgUeyMsrEVGHSwuLDZzOSVQ3qXj YEhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nC6PJfNXVU4vFSBxvbjKSl0ryoqOjAjd9RWGvuVHbDM=; b=PPRnj14g+wzfd1hzgkHnFWxZ2GtDal0BfxSghaEUsKm0w0cYWUmsXEs2I4jfhvxLhP FTZl48k9MhK5GyKqjriVDug/UG/80yTk04yNXxxK7RGhdHKWyyu0bXKGTtuPArNIUBLn BgscBVBKb0ZCRsMoSPSws14z0StE0o9/7mUtHwVngzyCvm+7MTb4sVTUfFJHYj+bSFvq KqOBdtvm0r7poiXPOyZcZg4Fg3dTzo4Fb3+61cSI7SxoYfaBpUt/QznaftX7DwvJJTym kaXW08kho/EDP54MsNCmxA+g3VC6pw2sLIc8xuOSoWKkIedLGq1j0pKjFTRHxUXB52oq vBCw== X-Gm-Message-State: AOAM533NEPLV6dS0wbURItqrTWWlxlWitE/VWb7DoLJvsWNGHioeLsNl 49T2zzfz2i9l9BPNZzwhU7us8xgcd3WfHXGaMQ0eQQ== X-Received: by 2002:a5d:80cb:: with SMTP id h11mr10901351ior.189.1596733449095; Thu, 06 Aug 2020 10:04:09 -0700 (PDT) MIME-Version: 1.0 References: <20200805141202.8641-1-yulei.kernel@gmail.com> In-Reply-To: <20200805141202.8641-1-yulei.kernel@gmail.com> From: Ben Gardon Date: Thu, 6 Aug 2020 10:03:57 -0700 Message-ID: Subject: Re: [RFC 0/9] KVM:x86/mmu:Introduce parallel memory virtualization to boost performance To: Yulei Zhang Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Jim Mattson , Vitaly Kuznetsov , xiaoguangrong.eric@gmail.com, kernellwp@gmail.com, lihaiwei.kernel@gmail.com, Yulei Zhang , Junaid Shahid Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 5, 2020 at 9:53 AM Yulei Zhang wrote: > > From: Yulei Zhang > > Currently in KVM memory virtulization we relay on mmu_lock to synchronize > the memory mapping update, which make vCPUs work in serialize mode and > slow down the execution, especially after migration to do substantial > memory mapping setup, and performance get worse if increase vCPU numbers > and guest memories. > > The idea we present in this patch set is to mitigate the issue with > pre-constructed memory mapping table. We will fast pin the guest memory > to build up a global memory mapping table according to the guest memslots > changes and apply it to cr3, so that after guest starts up all the vCPUs > would be able to update the memory concurrently, thus the performance > improvement is expected. Is a re-implementation of the various MMU functions in this series necessary to pre-populate the EPT/NPT? I realize the approach you took is probably the fastest way to pre-populate an EPT, but it seems like similar pre-population could be achieved with some changes to the PF handler's prefault scheme or, from user space by adding a dummy vCPU to touch memory before loading the actual guest image. I think this series is taking a similar approach to the direct MMU RFC I sent out a little less than a year ago. (I will send another version of that series in the next month.) I'm not sure this level of complexity is worth it if you're only interested in EPT pre-population. Is pre-population your goal? You mention "parallel memory virtualization," does that refer to parallel page fault handling you intend to implement in a future series? There are a number of features I see you've chosen to leave behind in this series which might work for your use case, but I think they're necessary. These include handling vCPUs with different roles (SMM, VMX non root mode, etc.), MMU notifiers (which I realize matter less for pinned memory), demand paging through UFFD, fast EPT invalidation/teardown and others. > > And after test the initial patch with memory dirty pattern workload, we > have seen positive results even with huge page enabled. For example, > guest with 32 vCPUs and 64G memories, in 2M/1G huge page mode we would get > more than 50% improvement. > > > Yulei Zhang (9): > Introduce new fields in kvm_arch/vcpu_arch struct for direct build EPT > support > Introduce page table population function for direct build EPT feature > Introduce page table remove function for direct build EPT feature > Add release function for direct build ept when guest VM exit > Modify the page fault path to meet the direct build EPT requirement > Apply the direct build EPT according to the memory slots change > Add migration support when using direct build EPT > Introduce kvm module parameter global_tdp to turn on the direct build > EPT mode > Handle certain mmu exposed functions properly while turn on direct > build EPT mode > > arch/mips/kvm/mips.c | 13 + > arch/powerpc/kvm/powerpc.c | 13 + > arch/s390/kvm/kvm-s390.c | 13 + > arch/x86/include/asm/kvm_host.h | 13 +- > arch/x86/kvm/mmu/mmu.c | 537 ++++++++++++++++++++++++++++++-- > arch/x86/kvm/svm/svm.c | 2 +- > arch/x86/kvm/vmx/vmx.c | 17 +- > arch/x86/kvm/x86.c | 55 ++-- > include/linux/kvm_host.h | 7 +- > virt/kvm/kvm_main.c | 43 ++- > 10 files changed, 648 insertions(+), 65 deletions(-) > > -- > 2.17.1 >