Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp233201pxy; Fri, 7 May 2021 01:53:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6c5Uc40RKofLfrVeTt5/Rt0Ta/YBXjy8R2vrCRFCbnx7a83vR3y0fqUBM/gdPgpy3wkff X-Received: by 2002:a05:6402:268c:: with SMTP id w12mr10443284edd.234.1620377602670; Fri, 07 May 2021 01:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620377602; cv=none; d=google.com; s=arc-20160816; b=en/sHqdFsyq8CJXJHcIVwNcJTq9bY5bbugoNGn/xJJDmAc/reGfYQvx8w3w+Iel2T2 7jefU2zvSYDGCnuOspB1W61JK8qUsmiX//H86jZkZs2cwZRjRGKTllNJPMZHc85kNaHB R0EPydNFg91BraRPdVVprudOMa1PqUbhEh5xfsjhaN/b0/jKOAc8++pr3bgqTqI1CUzK CvBCwarzgGrb/TO+IIXdEjgoxGjyoJ8H3FpHT9q+GCoeFcCXj78cPco70sUomd2OGTZx SbGQPB2YpAY1sfzIfP5Cjsb/FREL+r5AVvD9nmz6vkvlygN9hafZUYnWR7eb1fJ77Cs4 +jkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=cytpn5HUqqHMQi7fHCbchsnpUSL44ZuNU5lozqiis8I=; b=QzDrqUYwom3Am5wCm/Nfs0qATKc0Q4uky5IchaF8rX0L46XMCgWf0Ts4IvTlL3k0PT 5rtYLhbvj9mAGKYckOp6CUsA7n+zWJ1AxsCcMgYXo8XAYWKvGV2+je9DQtKLWkzyvi2I NJRil8+3Gw07mvDIqwZHcC9O3PE9k4zJFIAhEdhX/GvfK/HNNZ6c8K99zE9/pl/DiUd/ 7vUJchUyyk6VbCxdzDddqJiO4TA+PZgyFtRtxYjv42U6/fEe9nRAiLd+ceWOuVT7f4XW inM9Xml5+A2qiV8+kS0g0+L/NFqlydyI/nvkVnNQNXgDC5ACQPH+ckUgHVRl7hpxR7d7 nZsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Vj7VxN4K; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u15si5444448edt.43.2021.05.07.01.52.58; Fri, 07 May 2021 01:53: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=@redhat.com header.s=mimecast20190719 header.b=Vj7VxN4K; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235539AbhEGHl2 (ORCPT + 99 others); Fri, 7 May 2021 03:41:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48402 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235525AbhEGHl1 (ORCPT ); Fri, 7 May 2021 03:41:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620373227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cytpn5HUqqHMQi7fHCbchsnpUSL44ZuNU5lozqiis8I=; b=Vj7VxN4KJSZLyja15lpWInfSGG3t2c5YptbWcP/AfwgzhrhmlM+ATPBnR730OWHtHKQnHY J0WNSHSCv6z/5JnAfyvYSpVDASJKKK3GhbBsdLjPvwGKtKh2IHk56/JBYfprDPquZhBCda NXobOMEmlfQgX6gYENnKO8kvTUVhq5A= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-546-59BLuhTmM6WLZQv2Lx-HRQ-1; Fri, 07 May 2021 03:40:25 -0400 X-MC-Unique: 59BLuhTmM6WLZQv2Lx-HRQ-1 Received: by mail-wm1-f72.google.com with SMTP id x82-20020a1c63550000b0290158057efb6dso95060wmb.3 for ; Fri, 07 May 2021 00:40:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=cytpn5HUqqHMQi7fHCbchsnpUSL44ZuNU5lozqiis8I=; b=e7+FJcPdnED274NyqJQYxTOOEzCPAwP6qgyBpLmp9yVQckdr2fdO41ao3Mz4y0/dG+ 95bOeuIzsY/ipx7Bvh2mIW4kImsnY9IMPgwAftIoouWH1vKS4M90XQLB6VvTsiI6YCLu 3egaEyndzz2S93i+3oojPlMPo5+0X7nSo5f67QACyCN2tsdkEfPX8sqZysgXEsgtrMHb wRPOZJRbILpRPEObJsPGy0Mzgys/+J4wUdbcH7foheftN4BVtSPWxaa5AQ+ymKn84e0Z yQJY98Yi2Z/lzgf23IgEjS5EWLpwxRgaiZk00p+wBRHhb3rN2nyW2DTQg5F742HWpvC/ jdLw== X-Gm-Message-State: AOAM531j0kYW34TdwOrA21yelxybmCnAPQrJvwr91I7BGDACDQCStXCQ 3S0aL6hay59ae3/vHGYSXMSfTlTn1rtK2gerVe1wyYtJD7l7Uf4HAQamkM6VR3hcasjtUVj6F5X lBTLvenLw7UtUrlnE17XgcIBZ X-Received: by 2002:a5d:4532:: with SMTP id j18mr10234867wra.223.1620373224754; Fri, 07 May 2021 00:40:24 -0700 (PDT) X-Received: by 2002:a5d:4532:: with SMTP id j18mr10234842wra.223.1620373224509; Fri, 07 May 2021 00:40:24 -0700 (PDT) Received: from [192.168.3.132] (p5b0c63c0.dip0.t-ipconnect.de. [91.12.99.192]) by smtp.gmail.com with ESMTPSA id x8sm7313019wru.70.2021.05.07.00.40.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 May 2021 00:40:24 -0700 (PDT) Subject: Re: [PATCH v3 0/8] Lazily allocate memslot rmaps To: Ben Gardon , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Peter Xu , Sean Christopherson , Peter Shier , Yulei Zhang , Wanpeng Li , Xiao Guangrong , Kai Huang , Keqian Zhu References: <20210506184241.618958-1-bgardon@google.com> From: David Hildenbrand Organization: Red Hat Message-ID: <05848766-b13c-2a58-81da-0f1e839a6cd0@redhat.com> Date: Fri, 7 May 2021 09:40:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210506184241.618958-1-bgardon@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06.05.21 20:42, 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. > Happy to see this change pop up, I remember discussing this with Paolo recently. Another step to reduce the rmap overhead could be looking into using a dynamic datastructure to manage the rmap, instead of allocating a fixed-sized array. That could also significantly reduce memory overhead in some setups and give us more flexibility, for example, for resizing or splitting slots atomically. -- Thanks, David / dhildenb