mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, Juergen Gross <jgross@suse.com>,
	virtualization@lists.linux.dev,
	Dave Hansen <dave.hansen@linux.intel.com>
Subject: [PATCH 6/8] x86/msr: Consolidate rdpmc() implementations
Date: Fri, 20 Mar 2026 12:03:38 -0700	[thread overview]
Message-ID: <20260320190338.E4E8CA9C@davehans-spike.ostc.intel.com> (raw)
In-Reply-To: <20260320190330.A97C443B@davehans-spike.ostc.intel.com>


From: Dave Hansen <dave.hansen@linux.intel.com>

Doing this is debatable. It does not actually remove any code. But,
rdpmc() is the last thing left in the #ifdef CONFIG_PARAVIRT_XXL
block and this seems like nice consistency.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
---

 b/arch/x86/include/asm/msr.h      |   12 +++++++-----
 b/arch/x86/include/asm/paravirt.h |    2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff -puN arch/x86/include/asm/msr.h~rdmsr-dups-9 arch/x86/include/asm/msr.h
--- a/arch/x86/include/asm/msr.h~rdmsr-dups-9	2026-03-20 11:24:21.013880656 -0700
+++ b/arch/x86/include/asm/msr.h	2026-03-20 11:24:21.020880966 -0700
@@ -176,6 +176,7 @@ static inline u64 native_read_pmc(int co
 #define raw_read_msr_safe	paravirt_read_msr_safe
 #define raw_write_msr		paravirt_write_msr
 #define raw_write_msr_safe	paravirt_write_msr_safe
+#define raw_read_pmc		paravirt_read_pmc
 
 #else
 #include <linux/errno.h>
@@ -184,6 +185,7 @@ static inline u64 native_read_pmc(int co
 #define raw_read_msr_safe	native_read_msr_safe
 #define raw_write_msr		native_write_msr
 #define raw_write_msr_safe	native_write_msr_safe
+#define raw_read_pmc		native_read_pmc
 
 /*
  * Access to machine-specific registers (available on 586 and better only)
@@ -191,11 +193,6 @@ static inline u64 native_read_pmc(int co
  * pointer indirection), this allows gcc to optimize better
  */
 
-static __always_inline u64 rdpmc(int counter)
-{
-	return native_read_pmc(counter);
-}
-
 #endif	/* !CONFIG_PARAVIRT_XXL */
 
 /*
@@ -242,6 +239,11 @@ static inline void wrmsrq(u32 msr, u64 v
 	raw_write_msr(msr, val);
 }
 
+static __always_inline u64 rdpmc(int counter)
+{
+	return raw_read_pmc(counter);
+}
+
 /* Instruction opcode for WRMSRNS supported in binutils >= 2.40 */
 #define ASM_WRMSRNS _ASM_BYTES(0x0f,0x01,0xc6)
 
diff -puN arch/x86/include/asm/paravirt.h~rdmsr-dups-9 arch/x86/include/asm/paravirt.h
--- a/arch/x86/include/asm/paravirt.h~rdmsr-dups-9	2026-03-20 11:24:21.017880833 -0700
+++ b/arch/x86/include/asm/paravirt.h	2026-03-20 11:24:21.020880966 -0700
@@ -161,7 +161,7 @@ static inline int paravirt_write_msr_saf
 	return PVOP_CALL2(int, pv_ops, cpu.write_msr_safe, msr, val);
 }
 
-static __always_inline u64 rdpmc(int counter)
+static __always_inline u64 paravirt_read_pmc(int counter)
 {
 	return PVOP_CALL1(u64, pv_ops, cpu.read_pmc, counter);
 }
_

  parent reply	other threads:[~2026-03-20 19:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 19:03 [PATCH 0/8] x86/msr: Consolidate native/paravirt MSR functions Dave Hansen
2026-03-20 19:03 ` [PATCH 1/8] x86/msr: Use "raw_" names for calls to native_* functions Dave Hansen
2026-03-20 19:03 ` [PATCH 2/8] x86/msr: Consolidate rdmsr() definitions Dave Hansen
2026-03-20 19:03 ` [PATCH 3/8] x86/msr: Consolidate rdmsr_safe() implementations Dave Hansen
2026-03-20 19:03 ` [PATCH 4/8] x86/msr: Consolidate rdmsrq() implementations Dave Hansen
2026-03-20 19:03 ` [PATCH 5/8] x86/msr: Consolidate {rd,wr}msr[q]_safe() implementations Dave Hansen
2026-03-20 19:03 ` Dave Hansen [this message]
2026-03-20 19:03 ` [PATCH 7/8] x86/msr: Remove old crusty comment Dave Hansen
2026-03-20 19:03 ` [PATCH 8/8] x86/msr: Remove duplicate #include Dave Hansen
2026-03-20 23:33 ` [PATCH 0/8] x86/msr: Consolidate native/paravirt MSR functions Borislav Petkov
2026-03-20 23:39   ` Dave Hansen
2026-03-21  6:23   ` Jürgen Groß
2026-03-23 15:22     ` Juergen Gross
2026-03-31 21:41     ` Dave Hansen
2026-04-01  6:12       ` Jürgen Groß
2026-03-31 21:37   ` Dave Hansen

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=20260320190338.E4E8CA9C@davehans-spike.ostc.intel.com \
    --to=dave.hansen@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=virtualization@lists.linux.dev \
    --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

all inboxes | Powered by JetHome®