Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf intel-pt: Synthesize iflag event

Synthesize an attribute event and sample events for changes to the
interrupt flag represented by the MODE.Exec packet.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/r/20220124084201.2699795-16-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
069ca70e ef3b2ba9

+52
+52
tools/perf/util/intel-pt.c
··· 124 124 u64 evt_sample_type; 125 125 u64 evt_id; 126 126 127 + u64 iflag_chg_sample_type; 128 + u64 iflag_chg_id; 129 + 127 130 u64 tsc_bit; 128 131 u64 mtc_bit; 129 132 u64 mtc_freq_bits; ··· 2212 2209 pt->evt_sample_type); 2213 2210 } 2214 2211 2212 + static int intel_pt_synth_iflag_chg_sample(struct intel_pt_queue *ptq) 2213 + { 2214 + struct intel_pt *pt = ptq->pt; 2215 + union perf_event *event = ptq->event_buf; 2216 + struct perf_sample sample = { .ip = 0, }; 2217 + struct perf_synth_intel_iflag_chg raw; 2218 + 2219 + if (intel_pt_skip_event(pt)) 2220 + return 0; 2221 + 2222 + intel_pt_prep_p_sample(pt, ptq, event, &sample); 2223 + 2224 + sample.id = ptq->pt->iflag_chg_id; 2225 + sample.stream_id = ptq->pt->iflag_chg_id; 2226 + 2227 + raw.flags = 0; 2228 + raw.iflag = ptq->state->to_iflag; 2229 + 2230 + if (ptq->state->type & INTEL_PT_BRANCH) { 2231 + raw.via_branch = 1; 2232 + raw.branch_ip = ptq->state->to_ip; 2233 + } else { 2234 + sample.addr = 0; 2235 + } 2236 + sample.flags = ptq->flags; 2237 + 2238 + sample.raw_size = perf_synth__raw_size(raw); 2239 + sample.raw_data = perf_synth__raw_data(&raw); 2240 + 2241 + return intel_pt_deliver_synth_event(pt, event, &sample, 2242 + pt->iflag_chg_sample_type); 2243 + } 2244 + 2215 2245 static int intel_pt_synth_error(struct intel_pt *pt, int code, int cpu, 2216 2246 pid_t pid, pid_t tid, u64 ip, u64 timestamp) 2217 2247 { ··· 2354 2318 if (pt->synth_opts.intr_events) { 2355 2319 if (state->type & INTEL_PT_EVT) { 2356 2320 err = intel_pt_synth_events_sample(ptq); 2321 + if (err) 2322 + return err; 2323 + } 2324 + if (state->type & INTEL_PT_IFLAG_CHG) { 2325 + err = intel_pt_synth_iflag_chg_sample(ptq); 2357 2326 if (err) 2358 2327 return err; 2359 2328 } ··· 3569 3528 pt->evt_sample_type = attr.sample_type; 3570 3529 pt->evt_id = id; 3571 3530 intel_pt_set_event_name(evlist, id, "evt"); 3531 + id += 1; 3532 + } 3533 + 3534 + if (pt->synth_opts.intr_events && pt->cap_event_trace) { 3535 + attr.config = PERF_SYNTH_INTEL_IFLAG_CHG; 3536 + err = intel_pt_synth_event(session, "iflag", &attr, id); 3537 + if (err) 3538 + return err; 3539 + pt->iflag_chg_sample_type = attr.sample_type; 3540 + pt->iflag_chg_id = id; 3541 + intel_pt_set_event_name(evlist, id, "iflag"); 3572 3542 id += 1; 3573 3543 } 3574 3544