public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kim Phillips <kim.phillips@amd.com>
To: Borislav Petkov <bp@alien8.de>, Borislav Petkov <bp@suse.de>,
	"Peter Zijlstra" <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>, <kim.phillips@amd.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] perf/x86/amd: Use faster rdpmc instruction when waiting for overflow
Date: Tue, 16 Nov 2021 11:07:54 -0600	[thread overview]
Message-ID: <20211116170754.76409-1-kim.phillips@amd.com> (raw)

The relatively new amd_pmu_wait_on_overflow uses rdmsr.
Update it to use the faster rdpmc instruction.

Signed-off-by: Kim Phillips <kim.phillips@amd.com>
---
 arch/x86/events/amd/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index 9687a8aef01c..c36cb0c6f9e1 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -587,6 +587,8 @@ static void amd_pmu_cpu_dead(int cpu)
 
 static void amd_pmu_wait_on_overflow(int idx)
 {
+	struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
+	struct hw_perf_event *hwc = &cpuc->events[idx]->hw;
 	unsigned int i;
 	u64 counter;
 
@@ -596,7 +598,7 @@ static void amd_pmu_wait_on_overflow(int idx)
 	 * forever...
 	 */
 	for (i = 0; i < OVERFLOW_WAIT_COUNT; i++) {
-		rdmsrl(x86_pmu_event_addr(idx), counter);
+		rdpmcl(hwc->event_base_rdpmc, counter);
 		if (counter & (1ULL << (x86_pmu.cntval_bits - 1)))
 			break;
 
-- 
2.32.0


                 reply	other threads:[~2021-11-16 17:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20211116170754.76409-1-kim.phillips@amd.com \
    --to=kim.phillips@amd.com \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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