Re: [PATCH v2 07/10] x86/msr: Switch rdmsr_safe_on_cpu() users to rdmsrq_safe_on_cpu()

From: Jürgen Groß

Date: Sun Jun 07 2026 - 02:32:32 EST


On 06.06.26 11:51, Ingo Molnar wrote:

* Juergen Gross <jgross@xxxxxxxx> wrote:

In order to prepare retiring rdmsr_safe_on_cpu() switch
rdmsr_safe_on_cpu() users to rdmsrq_safe_on_cpu().

--- a/arch/x86/lib/msr-smp.c
+++ b/arch/x86/lib/msr-smp.c
@@ -190,11 +190,22 @@ EXPORT_SYMBOL(wrmsrq_safe_on_cpu);
int rdmsrq_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 *q)
{
- u32 low, high;
+ struct msr_info_completion rv;
+ call_single_data_t csd;
int err;
- err = rdmsr_safe_on_cpu(cpu, msr_no, &low, &high);
- *q = (u64)high << 32 | low;
+ INIT_CSD(&csd, __rdmsr_safe_on_cpu, &rv);
+
+ memset(&rv, 0, sizeof(rv));
+ init_completion(&rv.done);
+ rv.msr.msr_no = msr_no;
+
+ err = smp_call_function_single_async(cpu, &csd);
+ if (!err) {
+ wait_for_completion(&rv.done);
+ err = rv.msr.err;
+ }
+ *q = rv.msr.reg.q;

While technically this is another API user conversion,
I'd split this out into another preparatory patch,
because this changes the API itself.

Okay, fine with me.

I'll send V3 after rc1 of 7.2 as Dave suggested.

One final question (not directly for this series, but for a future one):

I'd like to switch rdmsrq() from a macro to an inline function, as a macro
using one of its parameters as the destination for an assignment isn't
nice. Additionally I'd like to replace rdmsr*() use cases with rdmsrq*()
and wrmsr*() with wrmsrq*() (similar to the replacements done is this
series).

The rdmsrq() transformation into a function can easily be done via a
coccinelle script. What would be your choice regarding the sequence doing
this?

a) Start with rdmsrq() transformation into a function.
b) First do the rdmsr/wrmsr -> rdmsrq/wrmsrq replacements, then do the
rdmsrq() transformation into a function (this will touch more code, as
the initial rdmsr() use cases will be affected, too).
c) Leave rdmsrq() as a macro.


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature