Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Jul 2022 18:09:19 GMT
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 2154db222027 - stable/13 - hwpmc: Correct selection of Intel fixed counters.
Message-ID:  <202207041809.264I9J4f064330@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help

The branch stable/13 has been updated by mav:

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

commit 2154db2220272cfdb1cc5f88482d6ea02a4aa1f6
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2022-05-30 23:46:48 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-07-04 17:48:09 +0000

    hwpmc: Correct selection of Intel fixed counters.
    
    Intel json's use event=0 to specify fixed counter number via umask.
    Alternatively fixed counters have equivalent programmable event/umask.
    
    MFC after:      1 month
    
    (cherry picked from commit c1e813d1230915e19a236ec687cadc1051841e56)
---
 sys/dev/hwpmc/hwpmc_core.c | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c
index 1581c28da78f..7d359e732291 100644
--- a/sys/dev/hwpmc/hwpmc_core.c
+++ b/sys/dev/hwpmc/hwpmc_core.c
@@ -248,15 +248,31 @@ iaf_allocate_pmc(int cpu, int ri, struct pmc *pm,
 	ev = IAP_EVSEL_GET(config);
 	umask = IAP_UMASK_GET(config);
 
-	/* INST_RETIRED.ANY */
-	if (ev == 0xC0 && ri != 0)
-		return (EINVAL);
-	/* CPU_CLK_UNHALTED.THREAD */
-	if (ev == 0x3C && ri != 1)
-		return (EINVAL);
-	/* CPU_CLK_UNHALTED.REF */
-	if (ev == 0x0 && umask == 0x3 && ri != 2)
-		return (EINVAL);
+	if (ev == 0x0) {
+		if (umask != ri + 1)
+			return (EINVAL);
+	} else {
+		switch (ri) {
+		case 0:	/* INST_RETIRED.ANY */
+			if (ev != 0xC0 || umask != 0x00)
+				return (EINVAL);
+			break;
+		case 1:	/* CPU_CLK_UNHALTED.THREAD */
+			if (ev != 0x3C || umask != 0x00)
+				return (EINVAL);
+			break;
+		case 2:	/* CPU_CLK_UNHALTED.REF */
+			if (ev != 0x3C || umask != 0x01)
+				return (EINVAL);
+			break;
+		case 3:	/* TOPDOWN.SLOTS */
+			if (ev != 0xA4 || umask != 0x01)
+				return (EINVAL);
+			break;
+		default:
+			return (EINVAL);
+		}
+	}
 
 	pmc_alloc_refs++;
 	if ((cpu_stdext_feature3 & CPUID_STDEXT3_TSXFA) != 0 &&



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207041809.264I9J4f064330>