Re: [PATCH v10 01/25] x86/virt/tdx: Clarify try_init_module_global() result caching
From: Kiryl Shutsemau
Date: Wed May 27 2026 - 06:43:18 EST
On Wed, May 20, 2026 at 06:38:04AM -0700, Chao Gao wrote:
> TDX module global initialization is executed only once. The first call
> caches both the result and the "done" state, and later callers reuse the
> saved result. A lock protects that cached state.
>
> The current code is hard to read because sysinit_done is accessed under
> the lock, while sysinit_ret is not.
>
> To improve readability, move sysinit_ret accesses within the lock.
Have you considered using the guard for the lock. It would simplify the
flow.
--
Kiryl Shutsemau / Kirill A. Shutemov