Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 09 Aug 2026 19:17:12 +0000
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Cc:        Ali Mashtizadeh <ali@mashtizadeh.com>
Subject:   git: d38b3a5ead0d - main - libpmc: Fix AMD L3 counter parameter parsing
Message-ID:  <6a78d238.4790f.316d55e2@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by mhorne:

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

commit d38b3a5ead0d3507080da5321144219b13d43aa9
Author:     Ali Mashtizadeh <ali@mashtizadeh.com>
AuthorDate: 2026-07-31 02:11:17 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-08-09 19:16:49 +0000

    libpmc: Fix AMD L3 counter parameter parsing
    
    Fix two small bugs affecting the event parsing of AMD L3 counters.
    AMD's manual and JSON disagree about the naming scheme on recent
    processors.  I use the naming scheme present in the recent PPRs to be
    consistent, so in the JSON parser we rename 'allslices' to 'allsources'
    just as we already do with sliceid and sourceid.  Also ensure that we
    parse the 0x prefix present in the newer JSON files.
    
    Reviewed by:    mhorne
    Sponsored by:   Netflix
    MFC after:      1 week
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2180
---
 lib/libpmc/libpmc_pmu_util.c    | 8 ++++----
 lib/libpmc/pmu-events/jevents.c | 9 ++++++++-
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c
index 5db60fe6dafe..050cbc120cd8 100644
--- a/lib/libpmc/libpmc_pmu_util.c
+++ b/lib/libpmc/libpmc_pmu_util.c
@@ -371,13 +371,13 @@ pmu_parse_event(struct pmu_event_desc *ped, const char *eventin)
 		else if (strcmp(key, "l3_slice_mask") == 0)
 			ped->ped_l3_slice = strtol(value, NULL, 16);
 		else if (strcmp(key, "sourceid") == 0)
-			ped->ped_sourceid = strtol(value, NULL, 16);
+			ped->ped_sourceid = strtol(value, NULL, 0);
 		else if (strcmp(key, "coreid") == 0)
-			ped->ped_coreid = strtol(value, NULL, 16);
+			ped->ped_coreid = strtol(value, NULL, 0);
 		else if (strcmp(key, "allcores") == 0)
-			ped->ped_allcores = strtol(value, NULL, 10);
+			ped->ped_allcores = strtol(value, NULL, 0);
 		else if (strcmp(key, "allsources") == 0)
-			ped->ped_allsources = strtol(value, NULL, 10);
+			ped->ped_allsources = strtol(value, NULL, 0);
 		else if (strcmp(key, "pebs") == 0)
 			ped->ped_pebs = strtol(value, NULL, 10);
 		else {
diff --git a/lib/libpmc/pmu-events/jevents.c b/lib/libpmc/pmu-events/jevents.c
index facec3361c70..b4d073f13708 100644
--- a/lib/libpmc/pmu-events/jevents.c
+++ b/lib/libpmc/pmu-events/jevents.c
@@ -623,7 +623,14 @@ static int json_events(const char *fn,
 			} else if (json_streq(map, field, "EnAllCores")) {
 				addfield(map, &allcores, "", "allcores=", val);
 			} else if (json_streq(map, field, "EnAllSlices")) {
-				addfield(map, &allslices, "", "allslices=", val);
+				/*
+				 * We use the AMD PPR Family 1Ah Model 70h
+				 * naming scheme of allsources rather than
+				 * slices.  The symbol EnAllSlices is not used
+				 * anywhere except in Zen 4+ for the L3
+				 * counters.
+				 */
+				addfield(map, &allslices, "", "allsources=", val);
 			} else if (json_streq(map, field, "SliceId")) {
 				/*
 				 * We use sourceid because there's a


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a78d238.4790f.316d55e2>