- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I'm new to use PEBS and perf_event_open. Now, I'm trying to collect two events which are MEM_TRANS_RETIRED:LOAD_LATENCY:ldlat=3 and MEM_UOPS_RETIRED:ALL_STORES. According to http://man7.org/linux/man-pages/man2/perf_event_open.2.html, I use perf_event_open to open first event and I can get a handle, then I use this haddle as group id to open second event. But after I check result, it seems first event's result is overwrite by second event, I can only get second event's result. My code is like bellow. Can anyone give me some advice? Thanks.
struct perf_event_attr pe_attr;
memset(&pe_attr, 0, sizeof(pe_attr));
pe_attr.size = sizeof(pe_attr);
pfm_perf_encode_arg_t arg;
memset(&arg, 0, sizeof(arg));
arg.size = sizeof(pfm_perf_encode_arg_t);
arg.attr = &pe_attr;
char *fstr;
arg.fstr = &fstr;
curr_err = pfm_get_os_event_encoding(current_archi->sampling_read_event, PFM_PLM0 | PFM_PLM3, PFM_OS_PERF_EVENT, &arg);
if (curr_err != PFM_SUCCESS) {
return ERROR_PFM;
}
pe_attr.sample_period = 1000;
pe_attr.sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_ADDR | PERF_SAMPLE_DATA_SRC; //PERF_SAMPLE_WEIGHT
pe_attr.mmap = 1;
pe_attr.task = 1;
pe_attr.precise_ip = 2;
// Other parameters
pe_attr.disabled = 1;
pe_attr.exclude_kernel = 1;
pe_attr.exclude_hv = 1;
long first_event_tid = perf_event_open(&pe_attr, 0, -1, -1, 0);
if (first_event_tid == -1) {
return ERROR_PERF_EVENT_OPEN;
}
pe_attr.disabled = 0; // The group leader will start/stop us
curr_err = pfm_get_os_event_encoding(current_archi->sampling_write_event, PFM_PLM0 | PFM_PLM3, PFM_OS_PERF_EVENT, &arg);
if (curr_err != PFM_SUCCESS) {
return ERROR_PFM;
}
long second_event_fd = perf_event_open(&pe_attr_w, 0, -1, first_event_tid, 0);
if (second_event_fd == -1) {
return ERROR_PERF_EVENT_OPEN;
}
ioctl(first_event_tid, PERF_EVENT_IOC_ENABLE, 0);
Link Copied
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page