Re: [PATCH v9 07/18] x86/virt/tdx: Do TDX module per-cpu initialization

From: Peter Zijlstra
Date: Tue Feb 14 2023 - 10:27:19 EST


On Tue, Feb 14, 2023 at 12:59:14AM +1300, Kai Huang wrote:
> +/*
> + * Call @func on all online cpus one by one but skip those cpus
> + * when @skip_func is valid and returns true for them.
> + */
> +static int tdx_on_each_cpu_cond(int (*func)(void *), void *func_data,
> + bool (*skip_func)(int cpu, void *),
> + void *skip_data)
> +{
> + int cpu;
> +
> + for_each_online_cpu(cpu) {
> + int ret;
> +
> + if (skip_func && skip_func(cpu, skip_data))
> + continue;
> +
> + /*
> + * SEAMCALL can be time consuming. Call the @func on
> + * remote cpu via smp_call_on_cpu() instead of
> + * smp_call_function_single() to avoid busy waiting.
> + */
> + ret = smp_call_on_cpu(cpu, func, func_data, true);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}

schedule_on_each_cpu() ?