Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

How to use perf_event_open() function exposed by linux kernel to obtain "Intel Iyy Bridge-EP IMC0-7 uncore" events

LY
Beginner
1,415 Views

Dear All,

I wanna use perf_event_open function to get the iMC Performance Monitoring Events, but I don't know how to set up the parameters. I tried to set up it but the result I get is inconsistent with the results obtained by perf commands. The function is 

int perf_event_open(struct perf_event_attr *attr,
                           pid_t pid, int cpu, int group_fd,
                           unsigned long flags);

For this event

- CAS_COUNT
• Title: DRAM RD_CAS and WR_CAS Commands.

• Category: PRE Events

• Event Code: 0x04

• Max. Inc/Cyc:. 1, Register Restrictions: 0-3

• Definition: DRAM RD_CAS and WR_CAS Commands

I wanna evaluate the subevents RD and WR which umask is 0x03 and 0x0c. But what I know is this is socket-level event monitoring. However, in perf_event_open's parameters, there is no way to set up cpumask for socket-level monitoring (just per-cpu monitoring maybe). Have someone come across the same problems with me? I didn't find useful parameters in perf_event_attr to set up socket-level monitoring.

Thanks.

0 Kudos
3 Replies
Alexey_B_Intel
Employee
1,415 Views

Hi Lingyan,

To understand how perf tool programs iMC events collection over perf_event_open system call you may run this command:

perf stat -vv -a -e mem_loads,mem_stores

It will give you detailed content of perf_event_attr structutres and how they are mapped to CPUs.

Regards,

Alexey

0 Kudos
LY
Beginner
1,415 Views

AMAZING!!! I just found I was one step away from this! Very useful!

But here is another thing. since the read_format is 0x03, so how do I read it? The result I read using 

ioctl(fds, PERF_EVENT_IOC_ENABLE, 0);

ret = read(fds, val, sz);

is odd. ret is 24 meaning it has three uint64_t numbers. The first one is 0, the two left are equal to each other. Could you please tell me how to read the counters?

 

Alexey Budankov (Intel) wrote:

Hi Lingyan,

To understand how perf tool programs iMC events collection over perf_event_open system call you may run this command:

perf stat -vv -a -e mem_loads,mem_stores

It will give you detailed content of perf_event_attr structutres and how they are mapped to CPUs.

Regards,

Alexey

 

0 Kudos
LY
Beginner
1,415 Views

I have solved this! Thanks!

0 Kudos
Reply