From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org,
linux-perf-users@vger.kernel.org, linux-hyperv@vger.kernel.org,
kvm@vger.kernel.org
Cc: Juergen Gross <jgross@suse.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
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>,
Thomas Gleixner <tglx@kernel.org>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Long Li <longli@microsoft.com>,
Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH 32/32] x86/msr: Simplify some rdmsrq() use cases
Date: Mon, 29 Jun 2026 08:05:23 +0200 [thread overview]
Message-ID: <20260629060526.3638272-33-jgross@suse.com> (raw)
In-Reply-To: <20260629060526.3638272-1-jgross@suse.com>
After the conversion of rdmsrq() to an inline function some use cases
can be simplified by dropping an intermediate variable.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/events/amd/core.c | 6 +-----
arch/x86/events/amd/lbr.c | 12 ++----------
arch/x86/events/intel/core.c | 6 +-----
arch/x86/events/intel/cstate.c | 5 +----
arch/x86/events/intel/knc.c | 6 +-----
arch/x86/events/intel/lbr.c | 17 +++--------------
arch/x86/events/intel/uncore.c | 6 +-----
arch/x86/events/rapl.c | 4 +---
arch/x86/events/zhaoxin/core.c | 6 +-----
arch/x86/hyperv/hv_apic.c | 5 +----
arch/x86/include/asm/apic.h | 5 +----
arch/x86/include/asm/debugreg.h | 6 +-----
arch/x86/include/asm/kvm_host.h | 5 +----
13 files changed, 16 insertions(+), 73 deletions(-)
diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index ee08ed4f41ec..04f3c2e99c06 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -660,12 +660,8 @@ static __always_inline void amd_pmu_set_global_ctl(u64 ctl)
static inline u64 amd_pmu_get_global_status(void)
{
- u64 status;
-
/* PerfCntrGlobalStatus is read-only */
- status = rdmsrq(MSR_AMD64_PERF_CNTR_GLOBAL_STATUS);
-
- return status;
+ return rdmsrq(MSR_AMD64_PERF_CNTR_GLOBAL_STATUS);
}
static inline void amd_pmu_ack_global_status(u64 status)
diff --git a/arch/x86/events/amd/lbr.c b/arch/x86/events/amd/lbr.c
index 0b6aec1e5bf1..ada5278285cd 100644
--- a/arch/x86/events/amd/lbr.c
+++ b/arch/x86/events/amd/lbr.c
@@ -74,20 +74,12 @@ static __always_inline void amd_pmu_lbr_set_to(unsigned int idx, u64 val)
static __always_inline u64 amd_pmu_lbr_get_from(unsigned int idx)
{
- u64 val;
-
- val = rdmsrq(MSR_AMD_SAMP_BR_FROM + idx * 2);
-
- return val;
+ return rdmsrq(MSR_AMD_SAMP_BR_FROM + idx * 2);
}
static __always_inline u64 amd_pmu_lbr_get_to(unsigned int idx)
{
- u64 val;
-
- val = rdmsrq(MSR_AMD_SAMP_BR_FROM + idx * 2 + 1);
-
- return val;
+ return rdmsrq(MSR_AMD_SAMP_BR_FROM + idx * 2 + 1);
}
static __always_inline u64 sign_ext_branch_ip(u64 ip)
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index c6fc2d9079d9..02cc471cb5bd 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -2963,11 +2963,7 @@ static void intel_tfa_pmu_enable_all(int added)
static inline u64 intel_pmu_get_status(void)
{
- u64 status;
-
- status = rdmsrq(MSR_CORE_PERF_GLOBAL_STATUS);
-
- return status;
+ return rdmsrq(MSR_CORE_PERF_GLOBAL_STATUS);
}
static inline void intel_pmu_ack_status(u64 ack)
diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c
index 69eb6cf51d3b..c6d9146d8ec8 100644
--- a/arch/x86/events/intel/cstate.c
+++ b/arch/x86/events/intel/cstate.c
@@ -322,10 +322,7 @@ static int cstate_pmu_event_init(struct perf_event *event)
static inline u64 cstate_pmu_read_counter(struct perf_event *event)
{
- u64 val;
-
- val = rdmsrq(event->hw.event_base);
- return val;
+ return rdmsrq(event->hw.event_base);
}
static void cstate_pmu_event_update(struct perf_event *event)
diff --git a/arch/x86/events/intel/knc.c b/arch/x86/events/intel/knc.c
index c4f81215f758..a74caa8280be 100644
--- a/arch/x86/events/intel/knc.c
+++ b/arch/x86/events/intel/knc.c
@@ -199,11 +199,7 @@ static void knc_pmu_enable_event(struct perf_event *event)
static inline u64 knc_pmu_get_status(void)
{
- u64 status;
-
- status = rdmsrq(MSR_KNC_IA32_PERF_GLOBAL_STATUS);
-
- return status;
+ return rdmsrq(MSR_KNC_IA32_PERF_GLOBAL_STATUS);
}
static inline void knc_pmu_ack_status(u64 ack)
diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c
index e65a4ed121d7..0364655a8771 100644
--- a/arch/x86/events/intel/lbr.c
+++ b/arch/x86/events/intel/lbr.c
@@ -209,10 +209,7 @@ void intel_pmu_lbr_reset(void)
*/
static inline u64 intel_pmu_lbr_tos(void)
{
- u64 tos;
-
- tos = rdmsrq(x86_pmu.lbr_tos);
- return tos;
+ return rdmsrq(x86_pmu.lbr_tos);
}
enum {
@@ -311,26 +308,18 @@ static __always_inline u64 rdlbr_from(unsigned int idx, struct lbr_entry *lbr)
static __always_inline u64 rdlbr_to(unsigned int idx, struct lbr_entry *lbr)
{
- u64 val;
-
if (lbr)
return lbr->to;
- val = rdmsrq(x86_pmu.lbr_to + idx);
-
- return val;
+ return rdmsrq(x86_pmu.lbr_to + idx);
}
static __always_inline u64 rdlbr_info(unsigned int idx, struct lbr_entry *lbr)
{
- u64 val;
-
if (lbr)
return lbr->info;
- val = rdmsrq(x86_pmu.lbr_info + idx);
-
- return val;
+ return rdmsrq(x86_pmu.lbr_info + idx);
}
static inline void
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
index 0067bd35aa7f..7240849a6633 100644
--- a/arch/x86/events/intel/uncore.c
+++ b/arch/x86/events/intel/uncore.c
@@ -169,11 +169,7 @@ struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu
u64 uncore_msr_read_counter(struct intel_uncore_box *box, struct perf_event *event)
{
- u64 count;
-
- count = rdmsrq(event->hw.event_base);
-
- return count;
+ return rdmsrq(event->hw.event_base);
}
void uncore_mmio_exit_box(struct intel_uncore_box *box)
diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c
index 180cc18282ca..2d2376c59816 100644
--- a/arch/x86/events/rapl.c
+++ b/arch/x86/events/rapl.c
@@ -192,9 +192,7 @@ static inline unsigned int get_rapl_pmu_idx(int cpu, int scope)
static inline u64 rapl_read_counter(struct perf_event *event)
{
- u64 raw;
- raw = rdmsrq(event->hw.event_base);
- return raw;
+ return rdmsrq(event->hw.event_base);
}
static inline u64 rapl_scale(u64 v, struct perf_event *event)
diff --git a/arch/x86/events/zhaoxin/core.c b/arch/x86/events/zhaoxin/core.c
index 1980e5995e27..9203321c18b4 100644
--- a/arch/x86/events/zhaoxin/core.c
+++ b/arch/x86/events/zhaoxin/core.c
@@ -266,11 +266,7 @@ static void zhaoxin_pmu_enable_all(int added)
static inline u64 zhaoxin_pmu_get_status(void)
{
- u64 status;
-
- status = rdmsrq(MSR_CORE_PERF_GLOBAL_STATUS);
-
- return status;
+ return rdmsrq(MSR_CORE_PERF_GLOBAL_STATUS);
}
static inline void zhaoxin_pmu_ack_status(u64 ack)
diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
index 4e30f9a11bc4..52ee8c237c2c 100644
--- a/arch/x86/hyperv/hv_apic.c
+++ b/arch/x86/hyperv/hv_apic.c
@@ -36,10 +36,7 @@ static struct apic orig_apic;
static u64 hv_apic_icr_read(void)
{
- u64 reg_val;
-
- reg_val = rdmsrq(HV_X64_MSR_ICR);
- return reg_val;
+ return rdmsrq(HV_X64_MSR_ICR);
}
static void hv_apic_icr_write(u32 low, u32 id)
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index e028140fac49..993b52b52625 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -231,10 +231,7 @@ static inline void native_x2apic_icr_write(u32 low, u32 id)
static inline u64 native_x2apic_icr_read(void)
{
- unsigned long val;
-
- val = rdmsrq(APIC_BASE_MSR + (APIC_ICR >> 4));
- return val;
+ return rdmsrq(APIC_BASE_MSR + (APIC_ICR >> 4));
}
extern int x2apic_mode;
diff --git a/arch/x86/include/asm/debugreg.h b/arch/x86/include/asm/debugreg.h
index 426d48beef81..0b2f42c7f8eb 100644
--- a/arch/x86/include/asm/debugreg.h
+++ b/arch/x86/include/asm/debugreg.h
@@ -174,15 +174,11 @@ static inline unsigned long amd_get_dr_addr_mask(unsigned int dr)
static inline unsigned long get_debugctlmsr(void)
{
- unsigned long debugctlmsr = 0;
-
#ifndef CONFIG_X86_DEBUGCTLMSR
if (boot_cpu_data.x86 < 6)
return 0;
#endif
- debugctlmsr = rdmsrq(MSR_IA32_DEBUGCTLMSR);
-
- return debugctlmsr;
+ return rdmsrq(MSR_IA32_DEBUGCTLMSR);
}
static inline void update_debugctlmsr(unsigned long debugctlmsr)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index e9b4ad535643..c87545070347 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -2415,10 +2415,7 @@ static inline void kvm_load_ldt(u16 sel)
#ifdef CONFIG_X86_64
static inline unsigned long read_msr(unsigned long msr)
{
- u64 value;
-
- value = rdmsrq(msr);
- return value;
+ return rdmsrq(msr);
}
#endif
--
2.54.0
next prev parent reply other threads:[~2026-06-29 6:08 UTC|newest]
Thread overview: 112+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 6:04 [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces Juergen Gross
2026-06-29 6:04 ` Juergen Gross
2026-06-29 6:04 ` [PATCH 01/32] thermal/intel: Stop using " Juergen Gross
2026-07-02 9:31 ` Ingo Molnar
2026-07-02 11:18 ` Jürgen Groß
2026-07-03 11:22 ` [PATCH v2 " Juergen Gross
2026-06-29 6:04 ` [PATCH 02/32] powercap: " Juergen Gross
2026-06-29 11:25 ` Ingo Molnar
2026-06-29 11:33 ` Jürgen Groß
2026-06-29 12:31 ` Ingo Molnar
2026-06-29 12:52 ` Jürgen Groß
2026-06-29 6:04 ` [PATCH 03/32] edac: " Juergen Gross
2026-06-30 1:50 ` Zhuo, Qiuxu
2026-07-02 10:15 ` [tip: x86/msr] EDAC: " tip-bot2 for Juergen Gross
2026-06-29 6:04 ` [PATCH 04/32] acpi: " Juergen Gross
2026-06-30 12:30 ` Rafael J. Wysocki (Intel)
2026-06-30 12:42 ` Jürgen Groß
2026-07-02 9:17 ` Ingo Molnar
2026-07-02 11:33 ` Rafael J. Wysocki (Intel)
2026-07-04 8:26 ` Ingo Molnar
2026-06-29 6:04 ` [PATCH 05/32] x86/mtrr: " Juergen Gross
2026-06-29 11:33 ` Ingo Molnar
2026-06-29 11:41 ` Jürgen Groß
2026-06-29 12:27 ` Ingo Molnar
2026-06-29 13:04 ` Jürgen Groß
2026-07-02 9:15 ` Ingo Molnar
2026-07-03 11:23 ` [PATCH v2 " Juergen Gross
2026-06-29 6:04 ` [PATCH 06/32] x86/msr: Stop using 32-bit MSR interfaces in lib/msr-smp.c Juergen Gross
2026-07-02 10:16 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-06-29 6:04 ` [PATCH 07/32] x86/msr: Remove wrmsr_safe() Juergen Gross
2026-06-29 6:04 ` [PATCH 08/32] x86/mce: Stop using 32-bit MSR interfaces Juergen Gross
2026-07-02 10:16 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-07-03 10:55 ` [PATCH] x86/mce: Fix build warning after MSR-interface switch Juergen Gross
2026-06-29 6:05 ` [PATCH 09/32] KVM/x86: Stop using 32-bit MSR interfaces Juergen Gross
2026-06-29 6:05 ` [PATCH 10/32] x86/hygon: " Juergen Gross
2026-07-02 10:16 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-06-29 6:05 ` [PATCH 11/32] x86/pci: " Juergen Gross
2026-06-29 6:19 ` sashiko-bot
2026-07-02 10:16 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-07-02 10:25 ` sashiko-bot
2026-06-29 6:05 ` [PATCH 12/32] x86/amd: " Juergen Gross
2026-07-02 10:16 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-06-29 6:05 ` [PATCH 13/32] x86/featctl: " Juergen Gross
2026-07-02 9:39 ` Ingo Molnar
2026-07-02 11:19 ` Jürgen Groß
2026-07-03 11:24 ` [PATCH v2 " Juergen Gross
2026-06-29 6:05 ` [PATCH 14/32] x86/tsc: " Juergen Gross
2026-07-02 10:15 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-06-29 6:05 ` [PATCH 15/32] x86/msr: Remove rdmsr_safe() Juergen Gross
2026-06-29 6:05 ` [PATCH 16/32] cpufreq: Stop using 32-bit MSR interfaces Juergen Gross
2026-06-29 14:55 ` Zhongqiu Han
2026-06-30 6:38 ` Juergen Gross
2026-07-03 11:24 ` [PATCH v2 " Juergen Gross
2026-07-05 4:51 ` Zhongqiu Han
2026-06-29 6:05 ` [PATCH 17/32] x86/resctrl: " Juergen Gross
2026-07-01 16:49 ` Reinette Chatre
2026-07-02 10:15 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-06-29 6:05 ` [PATCH 18/32] x86/apic: " Juergen Gross
2026-07-02 10:15 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-06-29 6:05 ` [PATCH 19/32] x86/cpu: " Juergen Gross
2026-07-02 10:15 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-07-03 21:48 ` Borislav Petkov
2026-06-29 6:05 ` [PATCH 20/32] drivers/ata: " Juergen Gross
2026-06-29 6:23 ` sashiko-bot
2026-06-29 7:28 ` Jürgen Groß
2026-07-03 11:25 ` [PATCH v2 " Juergen Gross
2026-06-29 6:05 ` [PATCH 21/32] agp/nvidia: " Juergen Gross
2026-06-29 6:25 ` sashiko-bot
2026-06-29 6:05 ` [PATCH 22/32] fbdev/geode: " Juergen Gross
2026-06-29 6:05 ` [PATCH 23/32] hw_random/via-rng: " Juergen Gross
2026-06-29 6:05 ` [PATCH 24/32] drivers/gpio: " Juergen Gross
2026-06-29 10:33 ` Bartosz Golaszewski
2026-07-01 8:13 ` Linus Walleij
2026-07-01 8:32 ` Juergen Gross
2026-06-29 6:05 ` [PATCH 25/32] drivers/misc: " Juergen Gross
2026-06-29 6:05 ` [PATCH 26/32] x86/msr: Remove wrmsr() Juergen Gross
2026-06-29 6:05 ` [PATCH 27/32] x86/hyperv: Stop using 32-bit MSR interfaces Juergen Gross
2026-07-03 9:39 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-06-29 6:05 ` [PATCH 28/32] x86/olpc: " Juergen Gross
2026-07-03 9:39 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-06-29 6:05 ` [PATCH 29/32] hwmon: " Juergen Gross
2026-06-29 6:25 ` sashiko-bot
2026-06-29 15:05 ` Guenter Roeck
2026-07-03 9:39 ` [tip: x86/msr] " tip-bot2 for Juergen Gross
2026-06-29 6:05 ` [PATCH 30/32] x86/msr: Remove rdmsr() Juergen Gross
2026-06-29 6:05 ` [PATCH 31/32] treewide: convert rdmsrq() from a macro to an inline function Juergen Gross
2026-06-29 6:05 ` Juergen Gross
2026-06-29 6:24 ` sashiko-bot
2026-06-29 6:05 ` Juergen Gross [this message]
2026-06-29 6:52 ` [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces Arnd Bergmann
2026-06-29 6:52 ` Arnd Bergmann
2026-06-29 7:01 ` Jürgen Groß
2026-06-29 7:01 ` Jürgen Groß
2026-06-29 8:06 ` Arnd Bergmann
2026-06-29 8:06 ` Arnd Bergmann
2026-06-29 8:15 ` Jürgen Groß
2026-06-29 8:15 ` Jürgen Groß
2026-06-29 8:30 ` Jan Beulich
2026-06-29 8:38 ` Arnd Bergmann
2026-06-29 8:38 ` Arnd Bergmann
2026-06-30 20:06 ` H. Peter Anvin
2026-06-30 20:06 ` H. Peter Anvin
2026-06-29 11:19 ` Ingo Molnar
2026-06-29 11:19 ` Ingo Molnar
2026-06-30 18:59 ` Sean Christopherson
2026-06-30 18:59 ` Sean Christopherson
2026-07-01 8:33 ` Jürgen Groß
2026-07-01 8:33 ` Jürgen Groß
2026-07-02 10:07 ` Ingo Molnar
2026-07-02 10:07 ` Ingo Molnar
2026-07-02 11:03 ` Juergen Gross
2026-07-02 11:03 ` Juergen Gross
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=20260629060526.3638272-33-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=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=tglx@kernel.org \
--cc=wei.liu@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.