Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2904139pxy; Mon, 3 May 2021 10:34:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnMDyjQ+FAufmwTMawyp2o1Qvtfe2clzBQF9eZg7/wr8RA62+UHxoDQ6tbCUqHvy5YDfFw X-Received: by 2002:a17:906:dc4c:: with SMTP id yz12mr18165010ejb.284.1620063262161; Mon, 03 May 2021 10:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620063262; cv=none; d=google.com; s=arc-20160816; b=mXHzSRxWjQ6lH/VFXFlT7CkMKVjCVjA9no+5pEiCnZACxa7rWQ9ctexvpm3uTC7kqx DUKTK3HVFvcvGxp6Z60bElBn1LD8Oz8mx0qvQ4zbbcKk5X/F+as2O1No1CI8+0SzK9Rl dr1QRDlxwzkDDWn5pbDoM+LznAxwA+IzD/Vzl4o5idzNQnyC7W5m8+egIz+IDbZ/JIJr fJs43A3mkLbjdD37uqA6r2yUS3HV8qlDddSdFRoxrk+YxNFYSd31ukilRMy8rvsqEmb9 2agFPRNh7KgaRu8al2IVQnfkACVXMQiBgYRF4rik4I6QIjp55YC7+9KYrwOPRE30vmid McPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=I63jvYw0YNbi4LL7zlZz0OvOPS03MBsn8u87jlh6bAA=; b=PDjNKPliUuTIAG7npj+KL5Yk9IzS4RNrtru0R/mlLEROHVnz1Vq95Yo36y3dnHZHxK 9nC5OvdG8t4TOyKjkCmdIqH22deDtkJCQCvqlp5YeA2vEk2N6X9/QARAutmrpdf6jQFm 9SMjRGu3++epeGqfnhCKQBuWf0z+B89uUhqtR87lD4kQ/BNOcQi8B92vv+c3IHVtJSwx 0qISxsAhMgkPVqLnl43Y0iJVogpPhCWu9XdTIjbcp+Mr7q/ZxbpAchU8KcttMFikuYqZ A+nh7ycfmTOq9vDR3+6C0Vth5S2+ywNF93rfdiOLDuSulnyTVnoq8Y1dA7+irNiO5W1+ gFRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=R7ehcPOz; 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 hs36si391365ejc.134.2021.05.03.10.33.57; Mon, 03 May 2021 10:34:22 -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=R7ehcPOz; 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 S231443AbhECRcZ (ORCPT + 99 others); Mon, 3 May 2021 13:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231321AbhECRcY (ORCPT ); Mon, 3 May 2021 13:32:24 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2287CC061761 for ; Mon, 3 May 2021 10:31:31 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id di13so7242092edb.2 for ; Mon, 03 May 2021 10:31:31 -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=I63jvYw0YNbi4LL7zlZz0OvOPS03MBsn8u87jlh6bAA=; b=R7ehcPOzmxV3tekro6KJO+ChI3KqJl835Tx4EFtQGPgZ8JNPh7ckZPvNhMutXQubg2 9zks+QGlGg6P/v9OgkjD+fn+lhFJS9i8zcJnAIA3XN2tEu3lT0avVcrVhA1by0GGnMsl wdAz4AR69b5RsXOBH8dic41eDHPV6M/qxUrG+1/OXFG0hgwq/hv1npcCoQwTVxs4IBEi f9EGZL9Zc9zqTmYgwLGXR577XBGuYNw8pzk1xlVsIQL47w8JqsQsDFMCwFZLT5o+7dfH IPfyN9AbcIkckbfCYqiMMp7lnYANf6byR4HtkxhvnVk1I7AzmLAYPzU6eABPvVvhcYwR t3QQ== 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=I63jvYw0YNbi4LL7zlZz0OvOPS03MBsn8u87jlh6bAA=; b=V54TmWXULNL8NXQn88KjyUYiq/6jKsWAUs4o1EC0+UQX183WikQKz59dsE7Ct/4OF1 0O+I0C1qnxz+++qey4YGFC7G7fnVHZFMHMVSSzXoKezXrE7SfWxL9NefLY4K4lSI0V1k eFG5Ty3vGnRTRwuMdH+ePZ1zNmBrX+ZW+DSkMDXxMsps63FoXFBDWwmfaqdKJW/vFnvP A1XL0jpzNfwzfN8RbpWY+ztjqyItLthuVN7Jngtjfe/CDF0NNTw0Tor5d1A9+miIky2w KOCccCRYdwimbDSigR6svm7KJqA1y1Ksv6ew9GvsEbL6cFDcRHfaqnhzzzYlXmMHV4z5 Xlgg== X-Gm-Message-State: AOAM530PkiuSm8cUM3AUe4xxSr8VFWnaz1vvqOSVXaAnFCkO5hknSlHl nR0Bk0NQl88C1rstwK125AwlvCbOjVV8qQu3v0PXBoRtUt/wjw== X-Received: by 2002:aa7:dc54:: with SMTP id g20mr21179836edu.266.1620063089729; Mon, 03 May 2021 10:31:29 -0700 (PDT) MIME-Version: 1.0 References: <20210429211833.3361994-1-bgardon@google.com> In-Reply-To: From: Ben Gardon Date: Mon, 3 May 2021 10:31:18 -0700 Message-ID: Subject: Re: [PATCH v2 0/7] Lazily allocate memslot rmaps To: Paolo Bonzini Cc: LKML , kvm , Peter Xu , Sean Christopherson , Peter Shier , Junaid Shahid , Jim Mattson , Yulei Zhang , Wanpeng Li , Vitaly Kuznetsov , Xiao Guangrong Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 3, 2021 at 6:45 AM Paolo Bonzini wrote: > > On 29/04/21 23:18, Ben Gardon wrote: > > This series enables KVM to save memory when using the TDP MMU by waiting > > to allocate memslot rmaps until they are needed. To do this, KVM tracks > > whether or not a shadow root has been allocated. In order to get away > > with not allocating the rmaps, KVM must also be sure to skip operations > > which iterate over the rmaps. If the TDP MMU is in use and we have not > > allocated a shadow root, these operations would essentially be op-ops > > anyway. Skipping the rmap operations has a secondary benefit of avoiding > > acquiring the MMU lock in write mode in many cases, substantially > > reducing MMU lock contention. > > > > This series was tested on an Intel Skylake machine. With the TDP MMU off > > and on, this introduced no new failures on kvm-unit-tests or KVM selftests. > > Thanks, I only reported some technicalities in the ordering of loads > (which matter since the loads happen with SRCU protection only). Apart > from this, this looks fine! Awesome to hear, thank you for the reviews. Should I send a v3 addressing those comments, or did you already make those changes when applying to your tree? > > Paolo > > > Changelog: > > v2: > > Incorporated feedback from Paolo and Sean > > Replaced the memslot_assignment_lock with slots_arch_lock, which > > has a larger critical section. > > > > Ben Gardon (7): > > KVM: x86/mmu: Track if shadow MMU active > > KVM: x86/mmu: Skip rmap operations if shadow MMU inactive > > KVM: x86/mmu: Deduplicate rmap freeing > > KVM: x86/mmu: Factor out allocating memslot rmap > > KVM: mmu: Refactor memslot copy > > KVM: mmu: Add slots_arch_lock for memslot arch fields > > KVM: x86/mmu: Lazily allocate memslot rmaps > > > > arch/x86/include/asm/kvm_host.h | 13 +++ > > arch/x86/kvm/mmu/mmu.c | 153 +++++++++++++++++++++----------- > > arch/x86/kvm/mmu/mmu_internal.h | 2 + > > arch/x86/kvm/mmu/tdp_mmu.c | 6 +- > > arch/x86/kvm/mmu/tdp_mmu.h | 4 +- > > arch/x86/kvm/x86.c | 110 +++++++++++++++++++---- > > include/linux/kvm_host.h | 9 ++ > > virt/kvm/kvm_main.c | 54 ++++++++--- > > 8 files changed, 264 insertions(+), 87 deletions(-) > > >