From: Adrian Hunter <adrian.hunter@intel.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
<pbonzini@redhat.com>
Cc: <seanjc@google.com>, <kvm@vger.kernel.org>,
<rick.p.edgecombe@intel.com>, <kai.huang@intel.com>,
<reinette.chatre@intel.com>, <xiaoyao.li@intel.com>,
<tony.lindgren@linux.intel.com>, <binbin.wu@linux.intel.com>,
<isaku.yamahata@intel.com>, <linux-kernel@vger.kernel.org>,
<yan.y.zhao@intel.com>, <chao.gao@intel.com>
Subject: Re: [PATCH RFC] KVM: TDX: Defer guest memory removal to decrease shutdown time
Date: Tue, 18 Mar 2025 17:41:26 +0200 [thread overview]
Message-ID: <2ac8bb8e-c05b-4dc3-a2c1-43e8b936e8f3@intel.com> (raw)
In-Reply-To: <ful5rg4jmtxtpyf4apdgrcp3ohttqvwfdwbcrszf6h3jnlhlr5@pfkl6uvadwhu>
On 17/03/25 10:13, Kirill A. Shutemov wrote:
> On Thu, Mar 13, 2025 at 08:16:29PM +0200, Adrian Hunter wrote:
>> @@ -3221,6 +3241,19 @@ int tdx_gmem_private_max_mapping_level(struct kvm *kvm, kvm_pfn_t pfn)
>> return PG_LEVEL_4K;
>> }
>>
>> +int tdx_gmem_defer_removal(struct kvm *kvm, struct inode *inode)
>> +{
>> + struct kvm_tdx *kvm_tdx = to_kvm_tdx(kvm);
>> +
>> + if (kvm_tdx->nr_gmem_inodes >= TDX_MAX_GMEM_INODES)
>> + return 0;
>
> We have graceful way to handle this, but should we pr_warn_once() or
> something if we ever hit this limit?
>
> Hm. It is also a bit odd that we need to wait until removal to add a link
> to guest_memfd inode from struct kvm/kvm_tdx. Can we do it right away in
> __kvm_gmem_create()?
Sure.
The thing is, the inode is currently private within virt/kvm/guest_memfd.c
so there needs to be a way to make it accessible to arch code. Either a
callback passes it, or it is put on struct kvm in some way.
>
> Do I read correctly that inode->i_mapping->i_private_list only ever has
> single entry of the gmem? Seems wasteful.
Yes, it is presently used for only 1 gmem.
>
> Maybe move it to i_private (I don't see flags being used anywhere) and
> re-use the list_head to link all inodes of the struct kvm?
>
> No need in the gmem_inodes array.
There is also inode->i_mapping->i_private_data which is unused.
next prev parent reply other threads:[~2025-03-18 15:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 18:16 [PATCH RFC] KVM: TDX: Defer guest memory removal to decrease shutdown time Adrian Hunter
2025-03-13 18:39 ` Paolo Bonzini
2025-03-13 19:07 ` Adrian Hunter
2025-03-17 8:13 ` Kirill A. Shutemov
2025-03-18 15:41 ` Adrian Hunter [this message]
2025-03-18 21:11 ` Vishal Annapurve
2025-03-20 0:42 ` Vishal Annapurve
2025-03-24 10:40 ` Adrian Hunter
2025-03-27 8:14 ` Vishal Annapurve
2025-03-27 10:10 ` Adrian Hunter
2025-03-27 15:54 ` Sean Christopherson
2025-03-28 10:26 ` Adrian Hunter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2ac8bb8e-c05b-4dc3-a2c1-43e8b936e8f3@intel.com \
--to=adrian.hunter@intel.com \
--cc=binbin.wu@linux.intel.com \
--cc=chao.gao@intel.com \
--cc=isaku.yamahata@intel.com \
--cc=kai.huang@intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=reinette.chatre@intel.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=tony.lindgren@linux.intel.com \
--cc=xiaoyao.li@intel.com \
--cc=yan.y.zhao@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox