Re: [PATCH v6 06/11] x86/virt/tdx: Optimize tdx_pamt_get/put()

From: Yan Zhao

Date: Wed Jul 01 2026 - 01:38:10 EST


On Wed, Jul 01, 2026 at 09:45:24AM +0800, Edgecombe, Rick P wrote:
> Oh! You already did some testing.
>
> On Mon, 2026-06-08 at 17:50 +0800, Yan Zhao wrote:
> > > How important is this patch? I see "Optimize" but I read "Optional".
> > This patch reduces the number of global pamt_lock acquisitions.
> >
> > Reference testing data with/without the optimization:
> > (collected on my SPR test machine)
> >
> > Booting/teardown of 1 TD (8 vcpus/8G memory) per iteration:
> >                 |--------------|-------------|------------|
> >                 |    avg (us)  |   max (us)  |   min (us) |
> >                 |  w/o  |  w/  |  w/o  | w/  | w/o  |  w/ |
> > ----------------|-------|------|-------|-----|------|-----|
> > __tdx_pamt_get()|   2   |  0   |  578  | 505 |  2   |  0  |
>
> ^ it looks like the old version. Is this on a huge page stack? Or just plain
> dynamic PAMT?
It's DPAMT v6 with the huge page stack. But the data was collected with huge
pages disabled.

>
> > __tdx_pamt_put()|   0   |  0   |  563  | 496 |  0   |  0  |
> > ----------------|--------------|-------------|------------|
> >
> > Boot/teardown of 5 TDs (each TD: 8 vcpus/8G memory) concurrently:
> >                 |--------------|-------------|------------|
> >                 |    avg (us)  |   max (us)  |   min (us) |
> >                 |  w/o  |  w/  |  w/o  | w/  | w/o  |  w/ |
> > ----------------|-------|------|-------|-----|------|-----|
> > __tdx_pamt_get()|  15   |  0   |  1723 | 1386|  2   |  0  |
> > __tdx_pamt_put()|   0   |  0   |   562 |  733|  0   |  0  |
> > ----------------|--------------|-------------|------------|
>
>
> Did you record total time, or number of invocations that we could use to turn
> this into some more real world impact?
Below data was collected on SPR, averaged over 3 runs (huge pages disabled):

Bootup+teardown of 1 TD (8 vcpus/8G memory):

|--------------|-------------|------------|
| avg (us) | #cnt | total (us) |
| w/o | w/ | w/o | w/ | w/o | w/ |
----------------|-------|------|-------|-----|------|-----|
__tdx_pamt_get()| 2 | 0 | 706k |704k |2025k | 51k |
__tdx_pamt_put()| 0 | 0 | 706k |704k | 130k | 34k |
----------------|--------------|-------------|------------|


Bootup+teardown of 5 TDs (each TD: 8 vcpus/8G memory) concurrently:
|--------------|-------------|------------|
| avg (us) | #cnt | total (us) |
| w/o | w/ | w/o | w/ | w/o | w/ |
----------------|-------|------|-------|-----|------|-----|
__tdx_pamt_get()| 15 | 0 | 3431k |3420k|55517k|334k |
__tdx_pamt_put()| 0 | 0 | 3431k |3420k| 2066k|137k |
----------------|--------------|-------------|------------|