diff options
| -rw-r--r-- | tools/perf/util/intel-bts.c | 17 | ||||
| -rw-r--r-- | tools/perf/util/intel-pt.c | 22 |
2 files changed, 25 insertions, 14 deletions
diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 3b3a3d55dca1..7b27d77306c2 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c | |||
| @@ -269,6 +269,13 @@ static int intel_bts_do_fix_overlap(struct auxtrace_queue *queue, | |||
| 269 | return 0; | 269 | return 0; |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | static inline u8 intel_bts_cpumode(struct intel_bts *bts, uint64_t ip) | ||
| 273 | { | ||
| 274 | return machine__kernel_ip(bts->machine, ip) ? | ||
| 275 | PERF_RECORD_MISC_KERNEL : | ||
| 276 | PERF_RECORD_MISC_USER; | ||
| 277 | } | ||
| 278 | |||
| 272 | static int intel_bts_synth_branch_sample(struct intel_bts_queue *btsq, | 279 | static int intel_bts_synth_branch_sample(struct intel_bts_queue *btsq, |
| 273 | struct branch *branch) | 280 | struct branch *branch) |
| 274 | { | 281 | { |
| @@ -281,12 +288,8 @@ static int intel_bts_synth_branch_sample(struct intel_bts_queue *btsq, | |||
| 281 | bts->num_events++ <= bts->synth_opts.initial_skip) | 288 | bts->num_events++ <= bts->synth_opts.initial_skip) |
| 282 | return 0; | 289 | return 0; |
| 283 | 290 | ||
| 284 | event.sample.header.type = PERF_RECORD_SAMPLE; | ||
| 285 | event.sample.header.misc = PERF_RECORD_MISC_USER; | ||
| 286 | event.sample.header.size = sizeof(struct perf_event_header); | ||
| 287 | |||
| 288 | sample.cpumode = PERF_RECORD_MISC_USER; | ||
| 289 | sample.ip = le64_to_cpu(branch->from); | 291 | sample.ip = le64_to_cpu(branch->from); |
| 292 | sample.cpumode = intel_bts_cpumode(bts, sample.ip); | ||
| 290 | sample.pid = btsq->pid; | 293 | sample.pid = btsq->pid; |
| 291 | sample.tid = btsq->tid; | 294 | sample.tid = btsq->tid; |
| 292 | sample.addr = le64_to_cpu(branch->to); | 295 | sample.addr = le64_to_cpu(branch->to); |
| @@ -298,6 +301,10 @@ static int intel_bts_synth_branch_sample(struct intel_bts_queue *btsq, | |||
| 298 | sample.insn_len = btsq->intel_pt_insn.length; | 301 | sample.insn_len = btsq->intel_pt_insn.length; |
| 299 | memcpy(sample.insn, btsq->intel_pt_insn.buf, INTEL_PT_INSN_BUF_SZ); | 302 | memcpy(sample.insn, btsq->intel_pt_insn.buf, INTEL_PT_INSN_BUF_SZ); |
| 300 | 303 | ||
| 304 | event.sample.header.type = PERF_RECORD_SAMPLE; | ||
| 305 | event.sample.header.misc = sample.cpumode; | ||
| 306 | event.sample.header.size = sizeof(struct perf_event_header); | ||
| 307 | |||
| 301 | if (bts->synth_opts.inject) { | 308 | if (bts->synth_opts.inject) { |
| 302 | event.sample.header.size = bts->branches_event_size; | 309 | event.sample.header.size = bts->branches_event_size; |
| 303 | ret = perf_event__synthesize_sample(&event, | 310 | ret = perf_event__synthesize_sample(&event, |
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index 60732213d16a..86cc9a64e982 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c | |||
| @@ -407,6 +407,13 @@ intel_pt_cache_lookup(struct dso *dso, struct machine *machine, u64 offset) | |||
| 407 | return auxtrace_cache__lookup(dso->auxtrace_cache, offset); | 407 | return auxtrace_cache__lookup(dso->auxtrace_cache, offset); |
| 408 | } | 408 | } |
| 409 | 409 | ||
| 410 | static inline u8 intel_pt_cpumode(struct intel_pt *pt, uint64_t ip) | ||
| 411 | { | ||
| 412 | return ip >= pt->kernel_start ? | ||
| 413 | PERF_RECORD_MISC_KERNEL : | ||
| 414 | PERF_RECORD_MISC_USER; | ||
| 415 | } | ||
| 416 | |||
| 410 | static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn, | 417 | static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn, |
| 411 | uint64_t *insn_cnt_ptr, uint64_t *ip, | 418 | uint64_t *insn_cnt_ptr, uint64_t *ip, |
| 412 | uint64_t to_ip, uint64_t max_insn_cnt, | 419 | uint64_t to_ip, uint64_t max_insn_cnt, |
| @@ -429,10 +436,7 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn, | |||
| 429 | if (to_ip && *ip == to_ip) | 436 | if (to_ip && *ip == to_ip) |
| 430 | goto out_no_cache; | 437 | goto out_no_cache; |
| 431 | 438 | ||
| 432 | if (*ip >= ptq->pt->kernel_start) | 439 | cpumode = intel_pt_cpumode(ptq->pt, *ip); |
| 433 | cpumode = PERF_RECORD_MISC_KERNEL; | ||
| 434 | else | ||
| 435 | cpumode = PERF_RECORD_MISC_USER; | ||
| 436 | 440 | ||
| 437 | thread = ptq->thread; | 441 | thread = ptq->thread; |
| 438 | if (!thread) { | 442 | if (!thread) { |
| @@ -1059,15 +1063,11 @@ static void intel_pt_prep_b_sample(struct intel_pt *pt, | |||
| 1059 | union perf_event *event, | 1063 | union perf_event *event, |
| 1060 | struct perf_sample *sample) | 1064 | struct perf_sample *sample) |
| 1061 | { | 1065 | { |
| 1062 | event->sample.header.type = PERF_RECORD_SAMPLE; | ||
| 1063 | event->sample.header.misc = PERF_RECORD_MISC_USER; | ||
| 1064 | event->sample.header.size = sizeof(struct perf_event_header); | ||
| 1065 | |||
| 1066 | if (!pt->timeless_decoding) | 1066 | if (!pt->timeless_decoding) |
| 1067 | sample->time = tsc_to_perf_time(ptq->timestamp, &pt->tc); | 1067 | sample->time = tsc_to_perf_time(ptq->timestamp, &pt->tc); |
| 1068 | 1068 | ||
| 1069 | sample->cpumode = PERF_RECORD_MISC_USER; | ||
| 1070 | sample->ip = ptq->state->from_ip; | 1069 | sample->ip = ptq->state->from_ip; |
| 1070 | sample->cpumode = intel_pt_cpumode(pt, sample->ip); | ||
| 1071 | sample->pid = ptq->pid; | 1071 | sample->pid = ptq->pid; |
| 1072 | sample->tid = ptq->tid; | 1072 | sample->tid = ptq->tid; |
| 1073 | sample->addr = ptq->state->to_ip; | 1073 | sample->addr = ptq->state->to_ip; |
| @@ -1076,6 +1076,10 @@ static void intel_pt_prep_b_sample(struct intel_pt *pt, | |||
| 1076 | sample->flags = ptq->flags; | 1076 | sample->flags = ptq->flags; |
| 1077 | sample->insn_len = ptq->insn_len; | 1077 | sample->insn_len = ptq->insn_len; |
| 1078 | memcpy(sample->insn, ptq->insn, INTEL_PT_INSN_BUF_SZ); | 1078 | memcpy(sample->insn, ptq->insn, INTEL_PT_INSN_BUF_SZ); |
| 1079 | |||
| 1080 | event->sample.header.type = PERF_RECORD_SAMPLE; | ||
| 1081 | event->sample.header.misc = sample->cpumode; | ||
| 1082 | event->sample.header.size = sizeof(struct perf_event_header); | ||
| 1079 | } | 1083 | } |
| 1080 | 1084 | ||
| 1081 | static int intel_pt_inject_event(union perf_event *event, | 1085 | static int intel_pt_inject_event(union perf_event *event, |
