Re: [PATCH v4 2/7] x86/msr: add wrmsrq_on_cpus helper

From: Ackerley Tng

Date: Fri May 01 2026 - 14:34:57 EST


Ashish Kalra <Ashish.Kalra@xxxxxxx> writes:

>
> [...snip...]
>
> +void wrmsrq_on_cpus(const struct cpumask *mask, u32 msr_no, u64 q)
> +{
> + struct msr_info rv;
> + int this_cpu;
> +
> + memset(&rv, 0, sizeof(rv));
> +
> + rv.msr_no = msr_no;
> + rv.reg.q = q;
> +
> + this_cpu = get_cpu();
> +
> + if (cpumask_test_cpu(this_cpu, mask))
> + __wrmsr_on_cpu(&rv);
> +
> + smp_call_function_many(mask, __wrmsr_on_cpu, &rv, 1);
> + put_cpu();

I think

on_each_cpu_mask(mask, __wrmsr_on_cpu, (void *)&rv, true);

is more readable than get and put cpu.

I understand Dave wanted to remove the ugly casting earlier, but perhaps
it's okay now that the cast is wrapped in a function like this?

Just my 2c, feel free to go ahead either way.

Reviewed-by: Ackerley Tng <ackerleytng@xxxxxxxxxx>

>
> [...snip...]
>