Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Jul 2020 18:11:06 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r363188 - in head: lib/libpmc sys/dev/hwpmc
Message-ID:  <202007141811.06EIB6b3008168@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Tue Jul 14 18:11:05 2020
New Revision: 363188
URL: https://svnweb.freebsd.org/changeset/base/363188

Log:
  Add stepping to the kern.hwpmc.cpuid string on x86.
  
  It follows the equivalent Linux change to be able to differentiate
  skylakex and cascadelakex, sharing the same model but not stepping.
  
  This fixes skylakex handling broken by r363144.
  
  MFC after:	6 days

Modified:
  head/lib/libpmc/libpmc_pmu_util.c
  head/sys/dev/hwpmc/hwpmc_amd.c
  head/sys/dev/hwpmc/hwpmc_intel.c

Modified: head/lib/libpmc/libpmc_pmu_util.c
==============================================================================
--- head/lib/libpmc/libpmc_pmu_util.c	Tue Jul 14 18:02:24 2020	(r363187)
+++ head/lib/libpmc/libpmc_pmu_util.c	Tue Jul 14 18:11:05 2020	(r363188)
@@ -169,7 +169,7 @@ pmu_events_map_get(const char *cpuid)
 {
 	regex_t re;
 	regmatch_t pmatch[1];
-	size_t s, len;
+	size_t s;
 	char buf[64];
 	int match;
 	const struct pmu_events_map *pme;
@@ -193,8 +193,8 @@ pmu_events_map_get(const char *cpuid)
 		match = regexec(&re, buf, 1, pmatch, 0);
 		regfree(&re);
 		if (match == 0) {
-			len = pmatch[0].rm_eo - pmatch[0].rm_so;
-			if(len == strlen(buf))
+			if (pmatch[0].rm_so == 0 && (buf[pmatch[0].rm_eo] == 0
+			    || buf[pmatch[0].rm_eo] == '-'))
 				return (pme);
 		}
 	}

Modified: head/sys/dev/hwpmc/hwpmc_amd.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_amd.c	Tue Jul 14 18:02:24 2020	(r363187)
+++ head/sys/dev/hwpmc/hwpmc_amd.c	Tue Jul 14 18:11:05 2020	(r363188)
@@ -1073,7 +1073,7 @@ pmc_amd_initialize(void)
 	enum pmc_cputype cputype;
 	struct pmc_mdep *pmc_mdep;
 	enum pmc_class class;
-	int model;
+	int model, stepping;
 	char *name;
 
 	/*
@@ -1086,12 +1086,13 @@ pmc_amd_initialize(void)
 
 	name = NULL;
 	model = ((cpu_id & 0xF0000) >> 12) | ((cpu_id & 0xF0) >> 4);
+	stepping = cpu_id & 0xF;
 	if (CPUID_TO_FAMILY(cpu_id) == 0x17)
-		snprintf(pmc_cpuid, sizeof(pmc_cpuid), "AuthenticAMD-%d-%02X",
-				 CPUID_TO_FAMILY(cpu_id), model);
+		snprintf(pmc_cpuid, sizeof(pmc_cpuid), "AuthenticAMD-%d-%02X-%X",
+				 CPUID_TO_FAMILY(cpu_id), model, stepping);
 	if (CPUID_TO_FAMILY(cpu_id) == 0x18)
-		snprintf(pmc_cpuid, sizeof(pmc_cpuid), "HygonGenuine-%d-%02X",
-				 CPUID_TO_FAMILY(cpu_id), model);
+		snprintf(pmc_cpuid, sizeof(pmc_cpuid), "HygonGenuine-%d-%02X-%X",
+				 CPUID_TO_FAMILY(cpu_id), model, stepping);
 
 	switch (cpu_id & 0xF00) {
 #if	defined(__i386__)

Modified: head/sys/dev/hwpmc/hwpmc_intel.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_intel.c	Tue Jul 14 18:02:24 2020	(r363187)
+++ head/sys/dev/hwpmc/hwpmc_intel.c	Tue Jul 14 18:11:05 2020	(r363188)
@@ -94,8 +94,8 @@ pmc_intel_initialize(void)
 	model = ((cpu_id & 0xF0000) >> 12) | ((cpu_id & 0xF0) >> 4);
 	stepping = cpu_id & 0xF;
 
-	snprintf(pmc_cpuid, sizeof(pmc_cpuid), "GenuineIntel-%d-%02X",
-			 (cpu_id & 0xF00) >> 8, model);
+	snprintf(pmc_cpuid, sizeof(pmc_cpuid), "GenuineIntel-%d-%02X-%X",
+			 (cpu_id & 0xF00) >> 8, model, stepping);
 	switch (cpu_id & 0xF00) {
 	case 0x600:		/* Pentium Pro, Celeron, Pentium II & III */
 		switch (model) {



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