[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <yexfu34vq5wrctlhafkrhvwfdcp5aenkleq6zolgqquz74dmzh@5336rz6kfulo>
Date: Fri, 19 Sep 2025 10:39:02 +0100
From: Kiryl Shutsemau <kas@...nel.org>
To: Rick Edgecombe <rick.p.edgecombe@...el.com>
Cc: bp@...en8.de, chao.gao@...el.com, dave.hansen@...ux.intel.com,
isaku.yamahata@...el.com, kai.huang@...el.com, kvm@...r.kernel.org,
linux-coco@...ts.linux.dev, linux-kernel@...r.kernel.org, mingo@...hat.com,
pbonzini@...hat.com, seanjc@...gle.com, tglx@...utronix.de, x86@...nel.org,
yan.y.zhao@...el.com, vannapurve@...gle.com,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Subject: Re: [PATCH v3 08/16] x86/virt/tdx: Optimize tdx_alloc/free_page()
helpers
On Thu, Sep 18, 2025 at 04:22:16PM -0700, Rick Edgecombe wrote:
> + } else if (IS_TDX_HPA_RANGE_NOT_FREE(tdx_status)) {
> + /*
> + * Less obviously, another CPU's call to tdx_pamt_put() could have
> + * decremented the refcount before entering its lock section.
> + * In this case, the PAMT is not actually removed yet. Luckily
> + * TDX module tells about this case, so increment the refcount
> + * 0-1, so tdx_pamt_put() skips its pending PAMT.REMOVE.
> + *
> + * The call didn't need the pages though, so free them.
> + */
> atomic_inc(pamt_refcount);
It is still 0->1 transition. atomic_set(pamt_refcount, 1) would be
slightly faster here.
--
Kiryl Shutsemau / Kirill A. Shutemov
Powered by blists - more mailing lists