git: f72a16118608 - stable/15 - hwpmc: Use rdtsc instead of rdtscp for timestamps

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 16 Apr 2026 15:28:26 UTC
The branch stable/15 has been updated by mhorne:

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

commit f72a161186084f170de8ace22722e848cb1073fa
Author:     Ali Mashtizadeh <mashti@uwaterloo.ca>
AuthorDate: 2026-03-23 20:21:21 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-04-16 15:18:24 +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
    
    (cherry picked from commit 39515d8b623a2be39d0c42a537fd9a17c417ff6e)
---
 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 a6a6ae68996c..04e23ae24c31 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -812,11 +812,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