Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1190346imi; Fri, 22 Jul 2022 20:37:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1svZ05i3UtU6VDPnCxEwCF5In1o86dv3hxn/CKnr2sWJmjYJSshJr8Y1atIPHAzxb+kCkon X-Received: by 2002:a05:6a02:30a:b0:41a:b002:83ac with SMTP id bn10-20020a056a02030a00b0041ab00283acmr2513532pgb.113.1658547479312; Fri, 22 Jul 2022 20:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658547479; cv=none; d=google.com; s=arc-20160816; b=cSm87wgrYSaHgGbBXU65sAw45g5goBBax/3RZ2lw0RQSGOSgZ4zUFGHGR9L8GaRURR SEtXJR7Q75F/+vPNMF0y6BKQFDP8ouklA598E5xlffcdpA5WENKxRxTChExQYZdEOwu/ RKZs5b8ESm1D9csZ0PPlDrQVafGocd5J6/n1U5VS97PpCo3rHYgDbbEwiYvBJ3oOnlx6 Qv7kkvAUqlhu3Mv/LIuvP4zrgnEyZtD6yAbcA1IDgZy1pAAKhAJnqn53FIl+uGdJO+no QAmbdnMPXLhQRlk/McV0l5F9UhXqh5OVnYCDrEA+O2P1Sdgdo/QLZbEHWirBKJP7lAlK cmCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=WN8s71kh4vPKmDr/z8AIdcbzkWE7OH3T+1bWhguw5DA=; b=gfJrsIV/6HIxaTFhyQFepyNc+hSTfiENzOmj4LwB7JAc1enWo52Gd1oZqk+nVVays6 bQqsjMUgiZgaEvTgn8N8fLVOiu/+I0KjGhLDT8N0KqSbeKQvPI1R+qJjSVjoE9TGhPHI 3ZTaU8lb4YK7rlc7XygZPleR36CnLjX7fPVPhr5kf3WlNR49nro25Xo7kFObPaEuiJu9 ulNR4omQFzmPXNRmrCpH0Qp7tP/7KATRwgOaQlDwpXHxBRj4QHVVOFjWwntkEQ9gEZQh pqmEdQH914gbevhDtCcCc77X8PD1UpZKq6/W6O7frl0Gu+zHCSrkTWh1tCtOqfYQ8i3B P8dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oxm6j4n4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020aa78f35000000b0051c28de280fsi7553675pfr.346.2022.07.22.20.37.38; Fri, 22 Jul 2022 20:37:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oxm6j4n4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235100AbiGWDJb (ORCPT + 99 others); Fri, 22 Jul 2022 23:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbiGWDJ2 (ORCPT ); Fri, 22 Jul 2022 23:09:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC03278598; Fri, 22 Jul 2022 20:09:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6EEA762308; Sat, 23 Jul 2022 03:09:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD8C9C341C6; Sat, 23 Jul 2022 03:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658545766; bh=yfeKrSA/SfbRW4ZHy2JK6fnHYLeUM29oPE55X5506UQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Oxm6j4n4k6TEwVlK1dp/rDs53BLhwoauQbLGK35rc3QJ+wKey0b7sGTpikHW4XCvY 1JQNGkU2/ealbT+TOlf5zdl65Ecd0y/txIIQwq85gdvSTrBRDN00VMmMFOzHLaK8co Tm3Ejfx8av5weVgr8UFTcaBA8CZcFNbCF4xWNajYI9OCEWgsi3etdizaEN291jOYya EWgKUJ6hjldQNmY7xRMSkvHOK0oqmPh1bMP39edxeiCh9w3Extm3R/FoZu5F+ZGeWS zPTL4jl/DeG2NZSThdoMW+a3xiq0qebMTY8jfhn4XDCwuNqYBjJqN6Y4E1vBNieytj F3xnrGkgASOBQ== Message-ID: <2171cf37-ea82-25c5-ad85-a80519525045@kernel.org> Date: Fri, 22 Jul 2022 20:09:23 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v5 00/13] KVM: mm: fd-based approach for supporting KVM guest private memory Content-Language: en-US To: Sean Christopherson , "Gupta, Pankaj" Cc: Chao Peng , Quentin Perret , Michael Roth , Steven Price , kvm list , Linux Kernel Mailing List , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Linux API , qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , the arch/x86 maintainers , "H. Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Mike Rapoport , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A. Shutemov" , "Nakajima, Jun" , Dave Hansen , Andi Kleen , David Hildenbrand , Marc Zyngier , Will Deacon , nikunj@amd.com, ashish.kalra@amd.com References: <83fd55f8-cd42-4588-9bf6-199cbce70f33@www.fastmail.com> <20220422105612.GB61987@chaop.bj.intel.com> <20220509223056.pyazfxjwjvipmytb@amd.com> From: Andy Lutomirski In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/21/22 14:19, Sean Christopherson wrote: > On Thu, Jul 21, 2022, Gupta, Pankaj wrote: >> >>> I view it as a performance problem because nothing stops KVM from copying from >>> userspace into the private fd during the SEV ioctl(). What's missing is the >>> ability for userspace to directly initialze the private fd, which may or may not >>> avoid an extra memcpy() depending on how clever userspace is. >> Can you please elaborate more what you see as a performance problem? And >> possible ways to solve it? > > Oh, I'm not saying there actually _is_ a performance problem. What I'm saying is > that in-place encryption is not a functional requirement, which means it's purely > an optimization, and thus we should other bother supporting in-place encryption > _if_ it would solve a performane bottleneck. Even if we end up having a performance problem, I think we need to understand the workloads that we want to optimize before getting too excited about designing a speedup. In particular, there's (depending on the specific technology, perhaps, and also architecture) a possible tradeoff between trying to reduce copying and trying to reduce unmapping and the associated flushes. If a user program maps an fd, populates it, and then converts it in place into private memory (especially if it doesn't do it in a single shot), then that memory needs to get unmapped both from the user mm and probably from the kernel direct map. On the flip side, it's possible to imagine an ioctl that does copy-and-add-to-private-fd that uses a private mm and doesn't need any TLB IPIs. All of this is to say that trying to optimize right now seems quite premature to me.