git: 39515d8b623a - main - hwpmc: Use rdtsc instead of rdtscp for timestamps

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Mon, 23 Mar 2026 20:22:14 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=39515d8b623a2be39d0c42a537fd9a17c417ff6e

commit 39515d8b623a2be39d0c42a537fd9a17c417ff6e
Author:     Ali Mashtizadeh <mashti@uwaterloo.ca>
AuthorDate: 2026-03-23 20:21:21 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-03-23 20:21:21 +0000

    hwpmc: Use rdtsc instead of rdtscp for timestamps
    
    No need for a barrier here, we are inside an NMI handler and executing a
    number of serializing instructions with stronger semantics. Reducing
    this overhead will increase our maximum safe sampling rate.
    
    Tested by:      Paulo Fragoso <paulo@nlink.com.br>
    Reviewed by:    mhorne
    MFC after:      1 week
    Sponsored by:   Netflix
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2076
---
 sys/dev/hwpmc/hwpmc_mod.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index fb1fdf832398..6133b52b516f 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -818,11 +818,9 @@ pmc_force_context_switch(void)
 uint64_t
 pmc_rdtsc(void)
 {
-#if defined(__i386__) || defined(__amd64__)
-	if (__predict_true(amd_feature & AMDID_RDTSCP))
-		return (rdtscp());
-	else
-		return (rdtsc());
+#if defined(__i386__)
+	/* Unfortunately get_cyclecount on i386 uses cpu_ticks. */
+	return (rdtsc());
 #else
 	return (get_cyclecount());
 #endif