Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp773612pxb; Thu, 25 Feb 2021 15:03:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9N+5EHuM0vegwFuyeyhIx+AC4/Oe32w0cskk/mC0OJ/3w16++1nuABxi+97K1cCXLWQyA X-Received: by 2002:a05:6402:1750:: with SMTP id v16mr305962edx.54.1614294205389; Thu, 25 Feb 2021 15:03:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614294205; cv=none; d=google.com; s=arc-20160816; b=Iou456iS6jMz51YoJWOJQmKTGSASQj/XvBXSMY2yWRZmI1JsOUkCEP7CxwAfJ+e7Ae hNIZ3R0ZEkkWUwSKbSaCrGBGpxV0MeaNP9/2J//+1BD2k3UbKm5y9dmlpBiQkwq+yXmf zikgLl/AteGt1R7onm2BndlJxsNYmMSB44485s2P2b09b1AwezmVPaFuypPohHUP2+xp YSqVcb2NWELuEQ9rYsdVJchs5MQ5KsWYZKxa7KOpg9Gex6lxZzGpnnJnKMi+1g7olA6s BSEEBqZSLDiERiYeWYc8FkPzr8OKsPSHW/NIhhlfk3j7j+ewCzlA8xXK/w4MLjD9QlJR LB1w== 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=5XspxK0PdIQsovjLyVyGdSX6BoQMz+G/8K5JhMr+loc=; b=WbkrxLyrLtIr0ry+mkOmoK3T0jdSb/tUAGU59wm+hvON3ylAP4Tqy2HCa0J/ano9tF uRV68ySvVRCFcewEEX3M56xANm0vCPQ3ua735caRPz5lYBDadbALoAW+ytWN4VuoW1hG p8uNJxWOY7oJIGLjmVzfNd+IwTRcBqieAcjjYKxIjMB/G1d8D3TzjjVMvdyJojImeCRY /ANfj/H0IxC92X/WcH5x3yElUj2VhfIZNo2K/V4SaFoMIStMtyiyoHgcQTP+zsMbt95x ivHWx+KqYkfNhgKsUV+w/02frSJ9nz2rozlTjt3Nh8h3Aq6H5P2GIIKgYbGp/GWB+rw6 Vx4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pkh4T7yn; 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 kk8si4210167ejc.404.2021.02.25.15.03.02; Thu, 25 Feb 2021 15:03:25 -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=pkh4T7yn; 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 S231375AbhBYXAr (ORCPT + 99 others); Thu, 25 Feb 2021 18:00:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbhBYXAp (ORCPT ); Thu, 25 Feb 2021 18:00:45 -0500 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACA25C06174A for ; Thu, 25 Feb 2021 15:00:05 -0800 (PST) Received: by mail-il1-x12c.google.com with SMTP id f10so5889513ilq.5 for ; Thu, 25 Feb 2021 15:00:05 -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=5XspxK0PdIQsovjLyVyGdSX6BoQMz+G/8K5JhMr+loc=; b=pkh4T7ynn+GB+pZAd1CZylm7bj8M2Xc+JTtE118zzJdpjKIMiDStQIRKnGP9zdyYf0 BcpHSYoF6BYT45oSWTGema+9VDxw3PKp3ap9LoceEXBA/Sknxf7Kr7EZrWKL8BqJ2KUG 9ELfgX5pqNvwEb5ihIYdyjdykB5OTHsBKxYeu+A2my1Wgq7Rf0D1r5qbi2QA+3pDlbxm VqiRRMYFfMxVNCRHFejZHzJwJdGqzbxA1snO5BsDXDbRO4kb4a8niLoE3BlbV71085K7 h4482SDdLc5pKRUj1JubV008AxQdlD6wElzH+woME/Sk4C/vp1FUil43I/fuMWEtH0tV 8REw== 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=5XspxK0PdIQsovjLyVyGdSX6BoQMz+G/8K5JhMr+loc=; b=CGLk9HrugfwL8F7clIFiTLp2frUcueskh/iY3PfGsq2k/Yv1G5OjOtYWFajcHmmeZt phKMP4Qddfy8zwPraOEWGH1T68x8t3KWhi9ssS0S98yqLZAVHI7GFOkKuAFboI7bZd9L xZSQV1/+4CD1sRqRx6ORJDmTEz11CbZpNETttVXtE3iS2moXEXuSSDPNSsBM0v10CxEX q4MGO34y1FNk3FezpLeF/r8TAbcuNj1rlQdRzpTs8FTGNbJcr5RKH2nEmpupX3prnjcY xXbjBDgd8+nW1FEMbbjaFd15IUKn692Lw0uwQpvg3+pq92uJ/0jczqdG1zqXNNDghlnJ P+0g== X-Gm-Message-State: AOAM533Cxg3ShF4VsyBZD9xZyZkTEgaQgYG5oI5wcXcMG+2FMEoL1HXU 7PKzfnitBwqIQ2GAXSs/W8AzZD7wGocyg4yL8vmcqA== X-Received: by 2002:a92:cd8a:: with SMTP id r10mr35361ilb.110.1614294004761; Thu, 25 Feb 2021 15:00:04 -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: <20210225202008.GA5208@ashkalra_ubuntu_server> From: Steve Rutherford Date: Thu, 25 Feb 2021 14:59:27 -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" , "rkrcmar@redhat.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 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