Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6343049rwn; Tue, 13 Sep 2022 02:51:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR7gZto4dfm3/Ot0P1qODhH4vo7y6AKSWFrOsODM1dqXUqszzZNEDWuoiPAWXA4zspdJn9mz X-Received: by 2002:a17:906:9b92:b0:730:a237:40fe with SMTP id dd18-20020a1709069b9200b00730a23740femr21440345ejc.464.1663062684863; Tue, 13 Sep 2022 02:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663062684; cv=none; d=google.com; s=arc-20160816; b=RcxMpcfists/haqYg7h1IObTIgSZktM4xBTq+WJC8i9dI+4k0OGVW2Z89lYSPwsxwz TbJOsCoh527Wuyngee7jQAAptaR17hzVWGaBY/FuqdP5SYV1tnP0xhDrnRYQRMg4eFoW k8ebOUiFH+EufWnwCG+PBs5ZWHllJWXw1egrLvPhuc+UFy5abQWU3e+hwng1XMO6fXYv 2Go6tA66bG48oDHchkjBt/0oiARkPuSzzmKoK1I5MyofaGH2u6nc9pJ17+HH22N50S0p Y+dI7fG6mwQ4rz35rDRFCcV8yeoYmkpgstWtuqDaTI9xqMgVQ2/WbjdPl/Gc3yBd4Ize TQOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZmfmFbMYmaq0ZyQMdMN01+8jHfJN0luS93tqSO/DBY4=; b=dW+8B7hlswicKZaa48F9sK1MkPdHAS0WrCfA4lY/wVKUHm/RJXdQQGxPVGZTUWYNwU y/3/8NxLeK6IRD0La4Qml5ZT9Xfpl49O3X8kSv9Z31eNlN4GUUNyZ4S3sgMIRsFhCO83 ctcXlwbd+N2Iwmn7oZLy2ZqcwKXd/zIRGcb5oJd61JIlN/c6VRVTZCNGtINpkllE9XTh jS7IF4I4WOG25dhrrOxY8FRmy50Sfk0w1T7wWkHdgFVHmKuTdSE8iPItBN3sfvWIjFjC ftv7jQGqsrm6U2s4jlHo7KFTcUls4rp/b8Z8PmU5ALf1LR2LJdXm2RmuWdRvTLXyRJp3 p2Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="kjd/plfm"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt3-20020a170907728300b00730983c4646si8408246ejc.508.2022.09.13.02.50.58; Tue, 13 Sep 2022 02:51:24 -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=@google.com header.s=20210112 header.b="kjd/plfm"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231338AbiIMJol (ORCPT + 99 others); Tue, 13 Sep 2022 05:44:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231423AbiIMJoh (ORCPT ); Tue, 13 Sep 2022 05:44:37 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 640AB10C0 for ; Tue, 13 Sep 2022 02:44:32 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id w2so941252pfb.0 for ; Tue, 13 Sep 2022 02:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=ZmfmFbMYmaq0ZyQMdMN01+8jHfJN0luS93tqSO/DBY4=; b=kjd/plfmNvrnSBexSRLrDTrVGwbFvpmKW/pCZ9ip9X3RoMI0PIUIt+BX7cJtWwzy+T N6FzGmRSYRbga2Hfey2bwFqsTNtkZ3PtoRAzL2bq20SSTD099hzZZR2HKnkQsBLhs0Xr pGrlRrtmyHjhWXepdyNQlVL4TclSL5+7o2GRqb1mg8L5MJsCX5BMltQxX5lleEImYIJG jQwSkPAv/SNPTmNOeqDc8HSrQIrmjdhIBFOXM2UC3nT0BG/Yq8OC3tiPvYTDIPnEEAq/ hZzpJnQ3ur8fgAox4BiTLBYLUW/hY8W89cnaJk+CshU7bSYsyWnaw+0JSUVdBrg1EVXA 8W2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=ZmfmFbMYmaq0ZyQMdMN01+8jHfJN0luS93tqSO/DBY4=; b=ekGKWhokIOEFLwycVEq5Zh134gg6vp5ptZRedvAl9sxnX5tNUpjdKcoDVyK4BwIOHV v++glqycCtUHImSkDlsQzVCGRNFLYHlentn07N2UpnD4ORjqQ0Q4O1CIRHO575Efg4kq 4ZHxuB4qrHxpf7vC06UK+Me2lzHpbQCpx6j1IqKhT7f9WAaOqoZtwPANUm0x21q6jRgy 5egyeDa/AzPMj8L9+urxqiyizuL7mPUM/8tWxoxEWLRf8kie6UJlJb2E0+iKPoxpq78e x6O0OY8CJ/viuLuy9fGu2dODdNuLTnIBz/n1ag9faj/fVq2G1szXsyqTLjJoX35kfyBM IzHQ== X-Gm-Message-State: ACgBeo3wqTvPxbeBCmcYkMNsl290I3/rIISWwRI7HFoYZ8hRkyFd5hal H9Rxaj9KAWuv7Pc4n5PUdU5X1w== X-Received: by 2002:a05:6a00:1892:b0:540:acee:29e8 with SMTP id x18-20020a056a00189200b00540acee29e8mr24802369pfh.1.1663062271855; Tue, 13 Sep 2022 02:44:31 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id e14-20020a63db0e000000b0042c2def703asm7191167pgg.22.2022.09.13.02.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 02:44:31 -0700 (PDT) Date: Tue, 13 Sep 2022 09:44:27 +0000 From: Sean Christopherson To: "Kirill A. Shutemov" Cc: "Kirill A . Shutemov" , Hugh Dickins , Chao Peng , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, linux-kselftest@vger.kernel.org, Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song , "Gupta, Pankaj" , Elena Reshetova Subject: Re: [PATCH v7 00/14] KVM: mm: fd-based approach for supporting KVM guest private memory Message-ID: References: <20220706082016.2603916-1-chao.p.peng@linux.intel.com> <20220818132421.6xmjqduempmxnnu2@box> <20220820002700.6yflrxklmpsavdzi@box.shutemov.name> <20220831142439.65q2gi4g2d2z4ofh@box.shutemov.name> <20220908011037.ez2cdorthqxkerwk@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220908011037.ez2cdorthqxkerwk@box.shutemov.name> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 Thu, Sep 08, 2022, Kirill A. Shutemov wrote: > On Wed, Aug 31, 2022 at 05:24:39PM +0300, Kirill A . Shutemov wrote: > > On Sat, Aug 20, 2022 at 10:15:32PM -0700, Hugh Dickins wrote: > > > > I will try next week to rework it as shim to top of shmem. Does it work > > > > for you? > > > > > > Yes, please do, thanks. It's a compromise between us: the initial TDX > > > case has no justification to use shmem at all, but doing it that way > > > will help you with some of the infrastructure, and will probably be > > > easiest for KVM to extend to other more relaxed fd cases later. > > > > Okay, below is my take on the shim approach. > > > > I don't hate how it turned out. It is easier to understand without > > callback exchange thing. > > > > The only caveat is I had to introduce external lock to protect against > > race between lookup and truncate. As before, I think this lock is unnecessary. Or at least it's unnessary to hold the lock across get/put. The ->invalidate() call will ensure that the pfn is never actually used if get() races with truncation. Switching topics, what actually prevents mmapp() on the shim? I tried to follow, but I don't know these areas well enough.