From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org,
linux-perf-users@vger.kernel.org, linux-edac@vger.kernel.org
Cc: Juergen Gross <jgross@suse.com>, "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Tony Luck <tony.luck@intel.com>
Subject: [PATCH RFC 0/6] x86/msr: Rename MSR access functions
Date: Mon, 20 Apr 2026 11:16:28 +0200 [thread overview]
Message-ID: <20260420091634.128787-1-jgross@suse.com> (raw)
This is a RFC for renaming the main MSR access functions. The main
motivations for doing that are:
- Prepare for wide spread use cases of WRMSRNS by making it easily
visible whether a MSR write is serializing or not. This has the
advantage that new use cases of MSR writes would need to decide
whether a serializing MSR write is needed or not. Using today's
MSR write interfaces would probably result in most new use cases
to use the serializing form, having a negative performance impact.
- Use functions instead of macros for accessing MSRs, which will drop
modifying variables passed as a parameter.
- Eliminate multiple accessors doing exactly the same thing (e.g.
rdmsrl() and rdmsrq()).
- Instead of having function names based on the underlying instruction
mnemonics, have functions of a common name space (msr_*()).
This series is containing only a needed prerequisite patch removing a
name collision with the new access functions, 3 patches introducing
the new access functions, and 2 example patches adapting users to use
the new functions instead the old ones.
I have selected the 2 example patches based on the needed code changes:
Patch 5 is very simple, because all the changes are really trivial.
While using a mixture of serializing and non-serializing MSR writes,
the non-serializing form is used only in case another MSR write is
following in the same function, resulting in each function doing MSR
writes having still serializing semantics (it might be possible to
change that later, but I wanted to be conservative just in case).
Patch 6 is a little bit less simple, as there are a couple of cases
where the new functions are no direct replacements of the old
interfaces. The new functions only work on 64-bit values, so in cases
where 2 32-bit values are needed, "struct msr" is used as a conversion
layer. I thought about adding macros for the same purpose, but in the
end this seemed to be a more simple and readable solution.
In case the general idea is accepted, I'd do the conversion of the rest
of the users (this will be probably a rather large, but mostly trivial
series).
As this series is RFC, I have done only basic compile testing.
Juergen Gross (6):
x86/msr: Rename msr_read() and msr_write()
x86/msr: Create a new minimal set of local MSR access functions
x86/msr: Create a new minimal set of inter-CPU MSR access functions
x86/msr: Rename the *_safe_regs[_on_cpu]() MSR functions
x86/events: Switch core parts to use new MSR access functions
x86/cpu/mce: Switch code to use new MSR access functions
arch/x86/events/core.c | 42 ++++++-------
arch/x86/events/msr.c | 2 +-
arch/x86/events/perf_event.h | 26 ++++----
arch/x86/events/probe.c | 2 +-
arch/x86/events/rapl.c | 8 +--
arch/x86/include/asm/msr.h | 87 ++++++++++++++++++++++---
arch/x86/kernel/cpu/amd.c | 4 +-
arch/x86/kernel/cpu/mce/amd.c | 101 +++++++++++++++---------------
arch/x86/kernel/cpu/mce/core.c | 18 +++---
arch/x86/kernel/cpu/mce/inject.c | 40 ++++++------
arch/x86/kernel/cpu/mce/intel.c | 32 +++++-----
arch/x86/kernel/cpu/mce/p5.c | 16 ++---
arch/x86/kernel/cpu/mce/winchip.c | 10 +--
arch/x86/kernel/msr.c | 16 ++---
arch/x86/lib/msr-reg-export.c | 4 +-
arch/x86/lib/msr-reg.S | 16 ++---
arch/x86/lib/msr-smp.c | 20 +++---
arch/x86/lib/msr.c | 12 ++--
18 files changed, 263 insertions(+), 193 deletions(-)
--
2.53.0
next reply other threads:[~2026-04-20 9:16 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 9:16 Juergen Gross [this message]
2026-04-20 9:16 ` [PATCH RFC 1/6] x86/msr: Rename msr_read() and msr_write() Juergen Gross
2026-04-20 9:16 ` [PATCH RFC 2/6] x86/msr: Create a new minimal set of local MSR access functions Juergen Gross
2026-04-20 9:16 ` [PATCH RFC 3/6] x86/msr: Create a new minimal set of inter-CPU " Juergen Gross
2026-04-20 9:16 ` [PATCH RFC 4/6] x86/msr: Rename the *_safe_regs[_on_cpu]() MSR functions Juergen Gross
2026-04-20 9:16 ` [PATCH RFC 5/6] x86/events: Switch core parts to use new MSR access functions Juergen Gross
2026-04-20 9:16 ` [PATCH RFC 6/6] x86/cpu/mce: Switch code " Juergen Gross
2026-04-20 11:35 ` [PATCH RFC 0/6] x86/msr: Rename " Peter Zijlstra
2026-04-20 11:41 ` Peter Zijlstra
2026-04-20 11:51 ` Jürgen Groß
2026-04-20 13:44 ` Sean Christopherson
2026-04-20 14:04 ` Jürgen Groß
2026-04-20 15:34 ` H. Peter Anvin
2026-04-20 11:49 ` Jürgen Groß
2026-04-20 12:33 ` Peter Zijlstra
2026-04-20 13:01 ` Jürgen Groß
2026-04-20 13:10 ` Peter Zijlstra
2026-04-20 13:23 ` Jürgen Groß
2026-04-20 13:36 ` Sean Christopherson
2026-04-20 13:57 ` Jürgen Groß
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260420091634.128787-1-jgross@suse.com \
--to=jgross@suse.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox