Skip to content

Commit bb01076

Browse files
Merge pull request #392 from Treece-Burgess/05-27-25-libpfm4-update
Update libpfm4 to commit 16d49e
2 parents e53a456 + 830545d commit bb01076

18 files changed

+449
-371
lines changed

src/libpfm4/docs/man3/libpfm_intel_knl.3

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
.TH LIBPFM 3 "July, 2016" "" "Linux Programmer's Manual"
22
.SH NAME
3-
libpfm_intel_knl - support for Intel Kinghts Landing core PMU
3+
libpfm_intel_knl - support for Intel Knights Landing core PMU
44
.SH SYNOPSIS
55
.nf
66
.B #include <perfmon/pfmlib.h>
77
.sp
88
.B PMU name: knl
9-
.B PMU desc: Intel Kinghts Landing
9+
.B PMU desc: Intel Knights Landing
1010
.sp
1111
.SH DESCRIPTION
12-
The library supports the Intel Kinghts Landing core PMU. It should be noted that
12+
The library supports the Intel Knights Landing core PMU. It should be noted that
1313
this PMU model only covers each core's PMU and not the socket level PMU.
1414

1515
On Knights Landing, the number of generic counters is 4. There is 4-way HyperThreading support.
1616
The \fBpfm_get_pmu_info()\fR function returns the maximum number of generic counters
1717
in \fBnum_cntrs\fr.
1818

1919
.SH MODIFIERS
20-
The following modifiers are supported on Intel Kinghts Landing processors:
20+
The following modifiers are supported on Intel Knights Landing processors:
2121
.TP
2222
.B u
2323
Measure at user level which includes privilege levels 1, 2, 3. This corresponds to \fBPFM_PLM3\fR.

src/libpfm4/docs/man3/libpfm_intel_knm.3

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ libpfm_intel_knm - support for Intel Knights Mill core PMU
66
.B #include <perfmon/pfmlib.h>
77
.sp
88
.B PMU name: knm
9-
.B PMU desc: Intel Kinghts Mill
9+
.B PMU desc: Intel Knights Mill
1010
.sp
1111
.SH DESCRIPTION
12-
The library supports the Intel Kinghts Mill core PMU. It should be noted that
12+
The library supports the Intel Knights Mill core PMU. It should be noted that
1313
this PMU model only covers each core's PMU and not the socket level PMU.
1414

1515
On Knights Mill, the number of generic counters is 4. There is 4-way HyperThreading support.
1616
The \fBpfm_get_pmu_info()\fR function returns the maximum number of generic counters
1717
in \fBnum_cntrs\fr.
1818

1919
.SH MODIFIERS
20-
The following modifiers are supported on Intel Kinghts Mill processors:
20+
The following modifiers are supported on Intel Knights Mill processors:
2121
.TP
2222
.B u
2323
Measure at user level which includes privilege levels 1, 2, 3. This corresponds to \fBPFM_PLM3\fR.

src/libpfm4/lib/events/amd64_events_fam1ah_zen5.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,23 +1502,23 @@ static const amd64_umask_t amd64_fam1ah_zen5_l2_fill_resp_src[]={
15021502
.udesc = "Fill from L3 or different L2 in same CCX",
15031503
.ucode = 0x2,
15041504
},
1505-
{ .uname = "NEAR_FAR_CACHE_NEAR",
1505+
{ .uname = "NEAR_CACHE",
15061506
.udesc = "Fill from cache of different CCX in same node",
15071507
.ucode = 0x4,
15081508
},
15091509
{ .uname = "DRAM_IO_NEAR",
15101510
.udesc = "Fill from DRAM or IO connected to same node",
15111511
.ucode = 0x8,
15121512
},
1513-
{ .uname = "NEAR_FAR_CACHE_FAR",
1513+
{ .uname = "FAR_CACHE",
15141514
.udesc = "Fill from CCX cache in different node",
15151515
.ucode = 0x10,
15161516
},
15171517
{ .uname = "DRAM_IO_FAR",
15181518
.udesc = "Fill from DRAM or IO connected from a different node (same socket or remote)",
15191519
.ucode = 0x40,
15201520
},
1521-
{ .uname = "ALT_MEM_NEAR_FAR",
1521+
{ .uname = "ALT_MEM",
15221522
.udesc = "Fill from Extension Memory",
15231523
.ucode = 0x80,
15241524
},
@@ -2170,16 +2170,16 @@ static const amd64_entry_t amd64_fam1ah_zen5_pe[]={
21702170
.code = 0x165,
21712171
.flags = 0,
21722172
.ngrp = 1,
2173-
.numasks = LIBPFM_ARRAY_SIZE(amd64_fam1ah_zen5_l2_prefetch_hit_l2),
2174-
.umasks = amd64_fam1ah_zen5_l2_prefetch_hit_l2, /* shared */
2173+
.numasks = LIBPFM_ARRAY_SIZE(amd64_fam1ah_zen5_l2_fill_resp_src),
2174+
.umasks = amd64_fam1ah_zen5_l2_fill_resp_src,
21752175
},
21762176
{ .name = "L2_PREFETCH_MISS_L3",
21772177
.desc = "Number of L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches",
21782178
.modmsk = AMD64_FAM1AH_ATTRS,
21792179
.code = 0x72,
21802180
.flags = 0,
21812181
.ngrp = 1,
2182-
.numasks = LIBPFM_ARRAY_SIZE(amd64_fam1ah_zen5_l2_fill_resp_src),
2183-
.umasks = amd64_fam1ah_zen5_l2_fill_resp_src,
2182+
.numasks = LIBPFM_ARRAY_SIZE(amd64_fam1ah_zen5_l2_prefetch_hit_l2),
2183+
.umasks = amd64_fam1ah_zen5_l2_prefetch_hit_l2, /* shared */
21842184
},
21852185
};

src/libpfm4/lib/pfmlib_arm.c

Lines changed: 91 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -41,53 +41,89 @@ const pfmlib_attr_desc_t arm_mods[]={
4141
};
4242

4343
pfm_arm_config_t pfm_arm_cfg = {
44-
.implementer = -1,
45-
.architecture = -1,
46-
.part = -1,
44+
.init_cpuinfo_done = 0,
4745
};
4846

49-
#ifdef CONFIG_PFMLIB_OS_LINUX
47+
#define MAX_ARM_CPUIDS 8
48+
49+
static arm_cpuid_t arm_cpuids[MAX_ARM_CPUIDS];
50+
static int num_arm_cpuids;
51+
52+
static int pfmlib_find_arm_cpuid(arm_cpuid_t *attr, arm_cpuid_t *match_attr)
53+
{
54+
int i;
55+
56+
if (attr == NULL)
57+
return PFM_ERR_NOTFOUND;
58+
59+
for (i=0; i < num_arm_cpuids; i++) {
60+
#if 0
5061
/*
51-
* helper function to retrieve one value from /proc/cpuinfo
52-
* for internal libpfm use only
53-
* attr: the attribute (line) to look for
54-
* ret_buf: a buffer to store the value of the attribute (as a string)
55-
* maxlen : number of bytes of capacity in ret_buf
56-
*
57-
* ret_buf is null terminated.
58-
*
59-
* Return:
60-
* 0 : attribute found, ret_buf populated
61-
* -1: attribute not found
62+
* disabled due to issues with expected arch vs. reported
63+
* arch by the Linux kernel cpuinfo
6264
*/
65+
if (arm_cpuids[i].arch != attr->arch)
66+
continue;
67+
#endif
68+
if (arm_cpuids[i].impl != attr->impl)
69+
continue;
70+
if (arm_cpuids[i].part != attr->part)
71+
continue;
72+
if (match_attr)
73+
*match_attr = arm_cpuids[i];
74+
return PFM_SUCCESS;
75+
}
76+
return PFM_ERR_NOTSUPP;
77+
}
6378

79+
#ifdef CONFIG_PFMLIB_OS_LINUX
80+
/*
81+
* Function populates the arm_cpuidsp[] table with each unique
82+
* core identifications found on the host. In the case of hybrids
83+
* that number is greater than 1
84+
*/
6485
static int
65-
pfmlib_getcpuinfo_attr(const char *attr, char *ret_buf, size_t maxlen)
86+
pfmlib_init_cpuids(void)
6687
{
88+
arm_cpuid_t attr = {0, };
6789
FILE *fp = NULL;
6890
int ret = -1;
69-
size_t attr_len, buf_len = 0;
91+
size_t buf_len = 0;
7092
char *p, *value = NULL;
7193
char *buffer = NULL;
94+
int nattrs = 0;
7295

73-
if (attr == NULL || ret_buf == NULL || maxlen < 1)
74-
return -1;
75-
76-
attr_len = strlen(attr);
96+
if (pfm_arm_cfg.init_cpuinfo_done == 1)
97+
return PFM_SUCCESS;
7798

78-
fp = fopen("/proc/cpuinfo", "r");
79-
if (fp == NULL)
80-
return -1;
99+
fp = fopen(pfm_cfg.proc_cpuinfo, "r");
100+
if (fp == NULL) {
101+
DPRINT("pfmlib_init_cpuids: cannot open %s\n", pfm_cfg.proc_cpuinfo);
102+
return PFM_ERR_NOTFOUND;
103+
}
81104

82105
while(pfmlib_getl(&buffer, &buf_len, fp) != -1){
106+
if (nattrs == ARM_NUM_ATTR_FIELDS) {
107+
if (pfmlib_find_arm_cpuid(&attr, NULL) != PFM_SUCCESS) {
108+
/* must add */
109+
if (num_arm_cpuids == MAX_ARM_CPUIDS) {
110+
DPRINT("pfmlib_init_cpuids: too many cpuids num_arm_cpuids=%d\n", num_arm_cpuids);
111+
ret = PFM_ERR_TOOMANY;
112+
goto error;
113+
}
114+
arm_cpuids[num_arm_cpuids++] = attr;
115+
__pfm_vbprintf("Detected ARM CPU impl=0x%x arch=%d part=0x%x\n", attr.impl, attr.arch, attr.part);
116+
}
117+
nattrs = 0;
118+
}
83119

84120
/* skip blank lines */
85-
if (*buffer == '\n')
121+
if (*buffer == '\n' || *buffer == '\r')
86122
continue;
87123

88124
p = strchr(buffer, ':');
89125
if (p == NULL)
90-
goto error;
126+
continue;
91127

92128
/*
93129
* p+2: +1 = space, +2= firt character
@@ -98,20 +134,38 @@ pfmlib_getcpuinfo_attr(const char *attr, char *ret_buf, size_t maxlen)
98134

99135
value[strlen(value)-1] = '\0';
100136

101-
if (!strncmp(attr, buffer, attr_len))
102-
break;
137+
if (!strncmp("CPU implementer", buffer, 15)) {
138+
attr.impl = strtoul(value, NULL, 0);
139+
nattrs++;
140+
continue;
141+
}
142+
if (!strncmp("CPU architecture", buffer, 16)) {
143+
attr.arch = strtoul(value, NULL, 0);
144+
nattrs++;
145+
continue;
146+
}
147+
if (!strncmp("CPU part", buffer, 8)) {
148+
attr.part = strtoul(value, NULL, 0);
149+
nattrs++;
150+
continue;
151+
}
103152
}
104-
strncpy(ret_buf, value, maxlen-1);
105-
ret_buf[maxlen-1] = '\0';
106-
ret = 0;
153+
ret = PFM_SUCCESS;
154+
DPRINT("num_arm_cpuids=%d\n", num_arm_cpuids);
107155
error:
156+
for (nattrs = 0; nattrs < num_arm_cpuids; nattrs++) {
157+
DPRINT("cpuids[%d] = impl=0x%x arch=%d part=0x%x\n", nattrs, arm_cpuids[nattrs].impl, arm_cpuids[nattrs].arch, arm_cpuids[nattrs].part);
158+
}
159+
pfm_arm_cfg.init_cpuinfo_done = 1;
160+
108161
free(buffer);
109162
fclose(fp);
163+
110164
return ret;
111165
}
112166
#else
113167
static int
114-
pfmlib_getcpuinfo_attr(const char *attr, char *ret_buf, size_t maxlen)
168+
pfmlib_init_cpuids(void)
115169
{
116170
return -1;
117171
}
@@ -151,34 +205,15 @@ pfm_arm_display_reg(void *this, pfmlib_event_desc_t *e, pfm_arm_reg_t reg)
151205
}
152206

153207
int
154-
pfm_arm_detect(void *this)
208+
pfm_arm_detect(arm_cpuid_t *attr, arm_cpuid_t *match_attr)
155209
{
156-
157210
int ret;
158-
char buffer[128];
159211

160-
if (pfm_arm_cfg.implementer == -1) {
161-
ret = pfmlib_getcpuinfo_attr("CPU implementer", buffer, sizeof(buffer));
162-
if (ret == -1)
163-
return PFM_ERR_NOTSUPP;
164-
pfm_arm_cfg.implementer = strtol(buffer, NULL, 16);
165-
}
166-
167-
if (pfm_arm_cfg.part == -1) {
168-
ret = pfmlib_getcpuinfo_attr("CPU part", buffer, sizeof(buffer));
169-
if (ret == -1)
170-
return PFM_ERR_NOTSUPP;
171-
pfm_arm_cfg.part = strtol(buffer, NULL, 16);
172-
}
212+
ret = pfmlib_init_cpuids();
213+
if (ret != PFM_SUCCESS)
214+
return PFM_ERR_NOTSUPP;
173215

174-
if (pfm_arm_cfg.architecture == -1) {
175-
ret = pfmlib_getcpuinfo_attr("CPU architecture", buffer, sizeof(buffer));
176-
if (ret == -1)
177-
return PFM_ERR_NOTSUPP;
178-
pfm_arm_cfg.architecture = strtol(buffer, NULL, 16);
179-
}
180-
181-
return PFM_SUCCESS;
216+
return pfmlib_find_arm_cpuid(attr, match_attr);
182217
}
183218

184219
int

src/libpfm4/lib/pfmlib_arm_armv6.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,17 @@
3737
static int
3838
pfm_arm_detect_1176(void *this)
3939
{
40+
/* ARM 1176 */
41+
arm_cpuid_t attr = { .impl = 0x41, .arch = 7, .part = 0xb76 };
4042

41-
int ret;
42-
43-
ret = pfm_arm_detect(this);
44-
if (ret != PFM_SUCCESS)
45-
return PFM_ERR_NOTSUPP;
46-
47-
if ((pfm_arm_cfg.implementer == 0x41) && /* ARM */
48-
(pfm_arm_cfg.part==0xb76)) { /* 1176 */
49-
return PFM_SUCCESS;
50-
}
51-
return PFM_ERR_NOTSUPP;
43+
return pfm_arm_detect(&attr, NULL);
5244
}
5345

5446
/* ARM1176 support */
5547
pfmlib_pmu_t arm_1176_support={
5648
.desc = "ARM1176",
5749
.name = "arm_1176",
50+
.perf_name = "armv6_1176",
5851
.pmu = PFM_PMU_ARM_1176,
5952
.pme_count = LIBPFM_ARRAY_SIZE(arm_1176_pe),
6053
.type = PFM_PMU_TYPE_CORE,

0 commit comments

Comments
 (0)