Re: [PATCH v2 20/31] x86/virt/tdx: Add a helper to loop on TDX_INTERRUPTED_RESUMABLE

From: Huang, Kai

Date: Wed Apr 22 2026 - 20:31:33 EST


On Sat, 2026-03-28 at 00:01 +0800, Xu Yilun wrote:
> +static u64 __maybe_unused __seamcall_ir_resched(sc_func_t sc_func, u64 fn,
> + struct tdx_module_args *args)
> +{
> + struct tdx_module_args _args;
> + u64 r;
> +
> + while (1) {
> + _args = *(args);
> + r = sc_retry(sc_func, fn, &_args);
> + if (r != TDX_INTERRUPTED_RESUMABLE)
> + break;
> +
> + cond_resched();
> + }
> +
> + *args = _args;
> +
> + return r;
> +}

Since commit 7dadeaa6e851e ("sched: Further restrict the preemption modes")
for x86 only PREEMPT (full) and PREEMPT_LAZY are possible, even when
PREEMPT_DYNAMIC is on.

cond_resched() is useful in PREEMPT_NONE and PREEMPT_VOLUNTARY, but it is
basically a RET0 in both PREEMPT_LAZY and PREEMPT. My understanding is we
shouldn't add any more cond_resched() for x86 now (see the aforementioned
commit changelog for more info).