Re: [PATCH v6 06/11] x86/virt/tdx: Optimize tdx_pamt_get/put()
From: Chao Gao
Date: Fri Jun 05 2026 - 01:41:01 EST
On Thu, Jun 04, 2026 at 05:59:02PM +0100, Kiryl Shutsemau wrote:
>On Tue, May 26, 2026 at 04:42:24PM +0000, Edgecombe, Rick P wrote:
>> On Tue, 2026-05-26 at 16:57 +0800, Chao Gao wrote:
>> > > - scoped_guard(spinlock, &pamt_lock) {
>> >
>> > This converts the scoped_guard() added by the previous patch to
>> > explicit lock/unlock and goto. It would reduce code churn if the
>> > previous patch used that form directly.
>>
>> Yea, it's a good point. I actually debated doing it, but decided not to because
>> the scoped version is cleaner for the non-optimized version. But for
>> reviewability, never doing the scoped version is probably better.
>
>I don't see a reason why we can't keep the scoped_guard() on get side.
One additional reason to drop scoped_guard() is that it mixes cleanup helpers
with goto, which is discouraged. See [*]
:Lastly, given that the benefit of cleanup helpers is removal of “goto”, and
:that the “goto” statement can jump between scopes, the expectation is that
:usage of “goto” and cleanup helpers is never mixed in the same function.
Removing scoped_guard() here also reduces indentation.
*: https://www.kernel.org/doc/html/v7.1-rc6/core-api/cleanup.html
>
>On put side, we cannot get atomic_get_and_lock() semantics without
>dropping the scoped_guard().
>
>Maybe we should keep it for get?
>
>--
> Kiryl Shutsemau / Kirill A. Shutemov