linux-coco.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: "Huang, Kai" <kai.huang@intel.com>,
	"kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"seanjc@google.com" <seanjc@google.com>
Cc: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"Zhao, Yan Y" <yan.y.zhao@intel.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
	"Yamahata, Isaku" <isaku.yamahata@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC, PATCH 05/12] KVM: TDX: Add tdx_pamt_get()/put() helpers
Date: Wed, 7 May 2025 09:31:22 -0700	[thread overview]
Message-ID: <4bb2119a-ff6d-42b6-acf4-86d87b0e9939@intel.com> (raw)
In-Reply-To: <55c1c173bfb13d897eaaabcc04f38d010608a7e3.camel@intel.com>

On 5/5/25 05:44, Huang, Kai wrote:
>> +static int tdx_pamt_add(atomic_t *pamt_refcount, unsigned long hpa,
>> +			struct list_head *pamt_pages)
>> +{
>> +	u64 err;
>> +
>> +	hpa = ALIGN_DOWN(hpa, SZ_2M);
>> +
>> +	spin_lock(&pamt_lock);
> Just curious, Can the lock be per-2M-range?

Folks, please keep it simple.

If there's lock contention on this, we'll fix the lock contention, or
hash the physical address into a fixed number of locks. But having it be
per-2M-range sounds awful. Then you have to size it, and allocate it and
then resize it if there's ever hotplug, etc...

Kirill, could you put together some kind of torture test for this,
please? I would imagine a workload which is sitting in a loop setting up
and tearing down VMs on a bunch of CPUs would do it.

That ^ would be the worst possible case, I think. If you don't see lock
contention there, you'll hopefully never see it on real systems.

I *suspect* that real systems will get bottlenecked somewhere in the
page conversion process rather than on this lock. But it should be a
pretty simple experiment to run.

  parent reply	other threads:[~2025-05-07 16:31 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-02 13:08 [RFC, PATCH 00/12] TDX: Enable Dynamic PAMT Kirill A. Shutemov
2025-05-02 13:08 ` [RFC, PATCH 01/12] x86/virt/tdx: Allocate page bitmap for " Kirill A. Shutemov
2025-05-05 10:08   ` Huang, Kai
2025-05-02 13:08 ` [RFC, PATCH 02/12] x86/virt/tdx: Allocate reference counters for PAMT memory Kirill A. Shutemov
2025-05-05 11:05   ` Huang, Kai
2025-05-08 13:03     ` kirill.shutemov
2025-05-09  1:06       ` Huang, Kai
2025-05-12  9:53         ` kirill.shutemov
2025-05-13 23:24           ` Huang, Kai
2025-05-09  9:52   ` Chao Gao
2025-05-12  9:51     ` Kirill A. Shutemov
2025-05-02 13:08 ` [RFC, PATCH 03/12] x86/virt/tdx: Add wrappers for TDH.PHYMEM.PAMT.ADD/REMOVE Kirill A. Shutemov
2025-05-09 10:18   ` Chao Gao
2025-05-12  9:55     ` Kirill A. Shutemov
2025-05-02 13:08 ` [RFC, PATCH 04/12] x86/virt/tdx: Account PAMT memory and print if in /proc/meminfo Kirill A. Shutemov
2025-05-02 13:08 ` [RFC, PATCH 05/12] KVM: TDX: Add tdx_pamt_get()/put() helpers Kirill A. Shutemov
2025-05-05 12:44   ` Huang, Kai
2025-05-07  1:01     ` Yan Zhao
2025-05-07  1:15       ` Vishal Annapurve
2025-05-07  2:42         ` Yan Zhao
2025-05-08 13:19           ` kirill.shutemov
2025-05-07 16:31     ` Dave Hansen [this message]
2025-05-08  2:08       ` Yan Zhao
2025-05-08 13:21         ` kirill.shutemov
2025-05-08 13:16       ` kirill.shutemov
2025-05-23  9:42     ` kirill.shutemov
2025-05-14  5:25   ` Chao Gao
2025-05-23 10:46     ` Kirill A. Shutemov
2025-05-14  5:33   ` Chao Gao
2025-05-14  6:25     ` Kirill A. Shutemov
2025-05-02 13:08 ` [RFC, PATCH 06/12] KVM: TDX: Allocate PAMT memory in __tdx_td_init() Kirill A. Shutemov
2025-05-05 12:46   ` Huang, Kai
2025-05-02 13:08 ` [RFC, PATCH 07/12] KVM: TDX: Allocate PAMT memory in tdx_td_vcpu_init() Kirill A. Shutemov
2025-05-02 13:08 ` [RFC, PATCH 08/12] KVM: x86/tdp_mmu: Add phys_prepare() and phys_cleanup() to kvm_x86_ops Kirill A. Shutemov
2025-05-06 11:55   ` Yan Zhao
2025-05-08 13:23     ` Kirill A. Shutemov
2025-05-09  1:25       ` Yan Zhao
2025-05-12  9:55         ` Kirill A. Shutemov
2025-05-14  0:00           ` Huang, Kai
2025-05-14  6:43             ` kirill.shutemov
2025-05-19  5:00               ` Huang, Kai
2025-05-23 12:00             ` kirill.shutemov
2025-06-05 13:01               ` kirill.shutemov
2025-06-05 22:21                 ` Huang, Kai
2025-06-06 10:20                   ` kirill.shutemov
2025-05-14  6:15   ` Chao Gao
2025-05-02 13:08 ` [RFC, PATCH 09/12] KVM: TDX: Preallocate PAMT pages to be used in page fault path Kirill A. Shutemov
2025-05-14  0:07   ` Huang, Kai
2025-05-14  6:30   ` Chao Gao
2025-05-30 10:28     ` Kirill A. Shutemov
2025-05-02 13:08 ` [RFC, PATCH 10/12] KVM: TDX: Hookup phys_prepare() and phys_cleanup() kvm_x86_ops Kirill A. Shutemov
2025-05-02 13:08 ` [RFC, PATCH 11/12] KVM: TDX: Reclaim PAMT memory Kirill A. Shutemov
2025-05-14  1:11   ` Huang, Kai
2025-05-14 15:21     ` Vishal Annapurve
2025-05-19  5:06       ` Huang, Kai
2025-05-02 13:08 ` [RFC, PATCH 12/12] x86/virt/tdx: Enable Dynamic PAMT Kirill A. Shutemov
2025-05-14 13:41 ` [RFC, PATCH 00/12] TDX: " Sean Christopherson
2025-05-15 14:22   ` Kirill A. Shutemov
2025-05-15 15:03     ` Dave Hansen
2025-05-15 16:02       ` Kirill A. Shutemov
2025-05-14 20:33 ` Zhi Wang
2025-05-15  9:17   ` Kirill A. Shutemov
2025-05-15 14:03     ` Dave Hansen

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=4bb2119a-ff6d-42b6-acf4-86d87b0e9939@intel.com \
    --to=dave.hansen@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.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-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).