Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp788001pxb; Thu, 25 Feb 2021 15:27:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLOE7FdLeCz7IngM7MrkqsPdn0j3qHwDlBmD2ZsDuMbPW3c8YAX/0LbpDu1u9UNOtC9AU2 X-Received: by 2002:a17:906:4088:: with SMTP id u8mr71262ejj.208.1614295650506; Thu, 25 Feb 2021 15:27:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614295650; cv=none; d=google.com; s=arc-20160816; b=Hn/fEgi3MwmU8xlHztxpUOql1SOc2se0cX8DfIhZ1awHRiTnmaamRhUIZN4TC94s4R PZEDLU2jvNQOTKm94nX4zYMN+DYRgzH3eVZ5H2CeYj9CumEzh/Bk2F6wPRDC/e85wIvF JXZg1krlIxwn3Ch87KACWJsQgKdp/K6mdWM4fZkKePTRq+6aXzuyXl0d0SPKGPo3s2Em jeNGXLctbQYjy0c4HEU1MB35ovn5L/Kgii+5aE0YT/JbR7t+uxD/5ejGCz9B+nU3nW3J Pgaq76WBqtHxmel7s62OcCxJAypg4MoLN9t94QbK5ZsIYqjD/Np2Q19G17x4rR9yPPCp o8JQ== 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=buKsp3p8qdkKup4y0TOrYPNSpU4MJwjrjc4Pg3aQsqY=; b=rK3fzV+0B2nUNr8/qLdyiDPs02RYf7eeZT+oES75tyDyik/uIf8GkZN584A9erY8Qx jNgZpGM8zqr4ssZvnxwxz+P1GRScxg1OrzEOLaQACnQmoDw94sdy583C2KFl3rEPdVZt t2NasJLRY9LqBEzAK2jikdbBAd63Q2YizefdGnB1o4ggOrBHxHjMyYku/E6D1WCy8kRc 9X8v7l7lo57uIQdojj0+dXl6/1SDQAdlETVtnaYu+fx5cWQp7VU3nlWLX5Wf1nRpEtim nQQbnAEHGThj7nhceJwSCC0jAnjXoclYs/t+4ey6ZJMs0mUCfWYqHS/jj/JThiwZE6As ljQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=A0JMF81D; 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 v7si4511663edj.572.2021.02.25.15.27.07; Thu, 25 Feb 2021 15:27:30 -0800 (PST) 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=A0JMF81D; 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 S231978AbhBYX0B (ORCPT + 99 others); Thu, 25 Feb 2021 18:26:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229966AbhBYXZ7 (ORCPT ); Thu, 25 Feb 2021 18:25:59 -0500 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 346E6C061574 for ; Thu, 25 Feb 2021 15:25:19 -0800 (PST) Received: by mail-io1-xd35.google.com with SMTP id s24so7785686iob.6 for ; Thu, 25 Feb 2021 15:25:19 -0800 (PST) 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=buKsp3p8qdkKup4y0TOrYPNSpU4MJwjrjc4Pg3aQsqY=; b=A0JMF81DswBAPlC8ypStKA2rg4ZYbEW5mBfM5bhmhEzNPXcc0KlET4IjVTpJFiKO6z RDwc49QZf0/ZzzdII9Fr4VKpSE93e03FNtdLX8mcWSvdZD24YnV9Z07H+wDUahF7H+ld kbHDMOWAVDvl1LeMLb5fG4G8pZcgzKerZGj1CK5hvU/EXXfyizruvwqE1cnDN//aLLzr Xz7+pFvi5nRbDm2zT4WzrG7AWnUJLCpOnub+ek8aH94l6DBCTFc4GvcpOHHKQWW7DFTC cFAWTc5XB+E9tEVntUEEgEiiNhrKT0W90+xVWfDD0+eXttgoLZKP+GiG/DjdV07SWD5r oobA== 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=buKsp3p8qdkKup4y0TOrYPNSpU4MJwjrjc4Pg3aQsqY=; b=UW6VEvylSNEUqtPmVwiUsCSZuyGdu+/TDIG+6guZntoU6oTp52MAUkDBf3uO1h4mTs gYgNZ6Mom3FXIxa/A5sicnczenEOOiZN1VdKBJTOtEp+CaRv0RStQw+EU92lbcAHo5Hk 8kYdqhW0/oqILEX8G9B2XLARdBw8pKe2o8FHWishL5ZcjkfqFQ9ewqnGJ7PUs+bLUghs vIkt0lWkAiO5mw7TcurLdXICDR+y4WCdNyV1c1dNNv88UXmFFktSzugDdpdU9+NuoaiM Ixt5AZrNUt89k5TGv9LDTJ+ObGcX3sYDcycTg3TLF+ayrWgNlg5dX9NToDBkOHNqVaBk 444w== X-Gm-Message-State: AOAM530tuGXlq0Gz6Y4nqUqarnF86blJBGcKIpb3K+Npb3jGr/ajZQWe ngkE/PzWI5Gc0p6aiJ88ZtTLls9j51VE3NwnsTceyQ== X-Received: by 2002:a6b:7a4a:: with SMTP id k10mr403062iop.8.1614295518399; Thu, 25 Feb 2021 15:25:18 -0800 (PST) MIME-Version: 1.0 References: <7266edd714add8ec9d7f63eddfc9bbd4d789c213.1612398155.git.ashish.kalra@amd.com> <20210224175122.GA19661@ashkalra_ubuntu_server> <20210225202008.GA5208@ashkalra_ubuntu_server> In-Reply-To: From: Steve Rutherford Date: Thu, 25 Feb 2021 15:24:41 -0800 Message-ID: Subject: Re: [PATCH v10 10/16] KVM: x86: Introduce KVM_GET_SHARED_PAGES_LIST ioctl To: Ashish Kalra Cc: Sean Christopherson , "pbonzini@redhat.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "joro@8bytes.org" , "bp@suse.de" , "Lendacky, Thomas" , "x86@kernel.org" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "venu.busireddy@oracle.com" , "Singh, Brijesh" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 25, 2021 at 2:59 PM Steve Rutherford wrote: > > On Thu, Feb 25, 2021 at 12:20 PM Ashish Kalra wrote: > > > > On Wed, Feb 24, 2021 at 10:22:33AM -0800, Sean Christopherson wrote: > > > On Wed, Feb 24, 2021, Ashish Kalra wrote: > > > > # Samples: 19K of event 'kvm:kvm_hypercall' > > > > # Event count (approx.): 19573 > > > > # > > > > # Overhead Command Shared Object Symbol > > > > # ........ ............... ................ ......................... > > > > # > > > > 100.00% qemu-system-x86 [kernel.vmlinux] [k] kvm_emulate_hypercall > > > > > > > > Out of these 19573 hypercalls, # of page encryption status hcalls are 19479, > > > > so almost all hypercalls here are page encryption status hypercalls. > > > > > > Oof. > > > > > > > The above data indicates that there will be ~2% more Heavyweight VMEXITs > > > > during SEV guest boot if we do page encryption status hypercalls > > > > pass-through to host userspace. > > > > > > > > But, then Brijesh pointed out to me and highlighted that currently > > > > OVMF is doing lot of VMEXITs because they don't use the DMA pool to minimize the C-bit toggles, > > > > in other words, OVMF bounce buffer does page state change on every DMA allocate and free. > > > > > > > > So here is the performance analysis after kernel and initrd have been > > > > loaded into memory using grub and then starting perf just before booting the kernel. > > > > > > > > These are the performance #'s after kernel and initrd have been loaded into memory, > > > > then perf is attached and kernel is booted : > > > > > > > > # Samples: 1M of event 'kvm:kvm_userspace_exit' > > > > # Event count (approx.): 1081235 > > > > # > > > > # Overhead Trace output > > > > # ........ ........................ > > > > # > > > > 99.77% reason KVM_EXIT_IO (2) > > > > 0.23% reason KVM_EXIT_MMIO (6) > > > > > > > > # Samples: 1K of event 'kvm:kvm_hypercall' > > > > # Event count (approx.): 1279 > > > > # > > > > > > > > So as the above data indicates, Linux is only making ~1K hypercalls, > > > > compared to ~18K hypercalls made by OVMF in the above use case. > > > > > > > > Does the above adds a prerequisite that OVMF needs to be optimized if > > > > and before hypercall pass-through can be done ? > > > > > > Disclaimer: my math could be totally wrong. > > > > > > I doubt it's a hard requirement. Assuming a conversative roundtrip time of 50k > > > cycles, those 18K hypercalls will add well under a 1/2 a second of boot time. > > > If userspace can push the roundtrip time down to 10k cycles, the overhead is > > > more like 50 milliseconds. > > > > > > That being said, this does seem like a good OVMF cleanup, irrespective of this > > > new hypercall. I assume it's not cheap to convert a page between encrypted and > > > decrypted. > > > > > > Thanks much for getting the numbers! > > > > Considering the above data and guest boot time latencies > > (and potential issues with OVMF and optimizations required there), > > do we have any consensus on whether we want to do page encryption > > status hypercall passthrough or not ? > > > > Thanks, > > Ashish > > Thanks for grabbing the data! > > I am fine with both paths. Sean has stated an explicit desire for > hypercall exiting, so I think that would be the current consensus. > > If we want to do hypercall exiting, this should be in a follow-up > series where we implement something more generic, e.g. a hypercall > exiting bitmap or hypercall exit list. If we are taking the hypercall > exit route, we can drop the kvm side of the hypercall. Userspace could > also handle the MSR using MSR filters (would need to confirm that). > Then userspace could also be in control of the cpuid bit. > > Essentially, I think you could drop most of the host kernel work if > there were generic support for hypercall exiting. Then userspace would > be responsible for all of that. Thoughts on this? > > --Steve This could even go a step further, and use an MSR write from within the guest instead of a hypercall, which could be patched through to userspace without host modification, if I understand the MSR filtering correctly. --Steve