Commit f6343be9 authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'perf-urgent-for-mingo-20160329' of...

Merge tag 'perf-urgent-for-mingo-20160329' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fix from Arnaldo Carvalho de Melo:

 - Add missing initialization of perf_sample.cpumode in synthesized samples,
   affects jitdump, records for pre-existing threads and records synthesized
   from processor trace data, noticed while testing intel_pt events with
   'perf script' (Arnaldo Carvalho de Melo)
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 5dc10373 3ea223ad
...@@ -56,13 +56,22 @@ const char *perf_event__name(unsigned int id) ...@@ -56,13 +56,22 @@ const char *perf_event__name(unsigned int id)
return perf_event__names[id]; return perf_event__names[id];
} }
static struct perf_sample synth_sample = { static int perf_tool__process_synth_event(struct perf_tool *tool,
union perf_event *event,
struct machine *machine,
perf_event__handler_t process)
{
struct perf_sample synth_sample = {
.pid = -1, .pid = -1,
.tid = -1, .tid = -1,
.time = -1, .time = -1,
.stream_id = -1, .stream_id = -1,
.cpu = -1, .cpu = -1,
.period = 1, .period = 1,
.cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK,
};
return process(tool, event, &synth_sample, machine);
}; };
/* /*
...@@ -186,7 +195,7 @@ pid_t perf_event__synthesize_comm(struct perf_tool *tool, ...@@ -186,7 +195,7 @@ pid_t perf_event__synthesize_comm(struct perf_tool *tool,
if (perf_event__prepare_comm(event, pid, machine, &tgid, &ppid) != 0) if (perf_event__prepare_comm(event, pid, machine, &tgid, &ppid) != 0)
return -1; return -1;
if (process(tool, event, &synth_sample, machine) != 0) if (perf_tool__process_synth_event(tool, event, machine, process) != 0)
return -1; return -1;
return tgid; return tgid;
...@@ -218,7 +227,7 @@ static int perf_event__synthesize_fork(struct perf_tool *tool, ...@@ -218,7 +227,7 @@ static int perf_event__synthesize_fork(struct perf_tool *tool,
event->fork.header.size = (sizeof(event->fork) + machine->id_hdr_size); event->fork.header.size = (sizeof(event->fork) + machine->id_hdr_size);
if (process(tool, event, &synth_sample, machine) != 0) if (perf_tool__process_synth_event(tool, event, machine, process) != 0)
return -1; return -1;
return 0; return 0;
...@@ -344,7 +353,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool, ...@@ -344,7 +353,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
event->mmap2.pid = tgid; event->mmap2.pid = tgid;
event->mmap2.tid = pid; event->mmap2.tid = pid;
if (process(tool, event, &synth_sample, machine) != 0) { if (perf_tool__process_synth_event(tool, event, machine, process) != 0) {
rc = -1; rc = -1;
break; break;
} }
...@@ -402,7 +411,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool, ...@@ -402,7 +411,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool,
memcpy(event->mmap.filename, pos->dso->long_name, memcpy(event->mmap.filename, pos->dso->long_name,
pos->dso->long_name_len + 1); pos->dso->long_name_len + 1);
if (process(tool, event, &synth_sample, machine) != 0) { if (perf_tool__process_synth_event(tool, event, machine, process) != 0) {
rc = -1; rc = -1;
break; break;
} }
...@@ -472,7 +481,7 @@ static int __event__synthesize_thread(union perf_event *comm_event, ...@@ -472,7 +481,7 @@ static int __event__synthesize_thread(union perf_event *comm_event,
/* /*
* Send the prepared comm event * Send the prepared comm event
*/ */
if (process(tool, comm_event, &synth_sample, machine) != 0) if (perf_tool__process_synth_event(tool, comm_event, machine, process) != 0)
break; break;
rc = 0; rc = 0;
...@@ -701,7 +710,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, ...@@ -701,7 +710,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
event->mmap.len = map->end - event->mmap.start; event->mmap.len = map->end - event->mmap.start;
event->mmap.pid = machine->pid; event->mmap.pid = machine->pid;
err = process(tool, event, &synth_sample, machine); err = perf_tool__process_synth_event(tool, event, machine, process);
free(event); free(event);
return err; return err;
......
...@@ -279,6 +279,7 @@ static int intel_bts_synth_branch_sample(struct intel_bts_queue *btsq, ...@@ -279,6 +279,7 @@ static int intel_bts_synth_branch_sample(struct intel_bts_queue *btsq,
event.sample.header.misc = PERF_RECORD_MISC_USER; event.sample.header.misc = PERF_RECORD_MISC_USER;
event.sample.header.size = sizeof(struct perf_event_header); event.sample.header.size = sizeof(struct perf_event_header);
sample.cpumode = PERF_RECORD_MISC_USER;
sample.ip = le64_to_cpu(branch->from); sample.ip = le64_to_cpu(branch->from);
sample.pid = btsq->pid; sample.pid = btsq->pid;
sample.tid = btsq->tid; sample.tid = btsq->tid;
......
...@@ -979,6 +979,7 @@ static int intel_pt_synth_branch_sample(struct intel_pt_queue *ptq) ...@@ -979,6 +979,7 @@ static int intel_pt_synth_branch_sample(struct intel_pt_queue *ptq)
if (!pt->timeless_decoding) if (!pt->timeless_decoding)
sample.time = tsc_to_perf_time(ptq->timestamp, &pt->tc); sample.time = tsc_to_perf_time(ptq->timestamp, &pt->tc);
sample.cpumode = PERF_RECORD_MISC_USER;
sample.ip = ptq->state->from_ip; sample.ip = ptq->state->from_ip;
sample.pid = ptq->pid; sample.pid = ptq->pid;
sample.tid = ptq->tid; sample.tid = ptq->tid;
...@@ -1035,6 +1036,7 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq) ...@@ -1035,6 +1036,7 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq)
if (!pt->timeless_decoding) if (!pt->timeless_decoding)
sample.time = tsc_to_perf_time(ptq->timestamp, &pt->tc); sample.time = tsc_to_perf_time(ptq->timestamp, &pt->tc);
sample.cpumode = PERF_RECORD_MISC_USER;
sample.ip = ptq->state->from_ip; sample.ip = ptq->state->from_ip;
sample.pid = ptq->pid; sample.pid = ptq->pid;
sample.tid = ptq->tid; sample.tid = ptq->tid;
...@@ -1092,6 +1094,7 @@ static int intel_pt_synth_transaction_sample(struct intel_pt_queue *ptq) ...@@ -1092,6 +1094,7 @@ static int intel_pt_synth_transaction_sample(struct intel_pt_queue *ptq)
if (!pt->timeless_decoding) if (!pt->timeless_decoding)
sample.time = tsc_to_perf_time(ptq->timestamp, &pt->tc); sample.time = tsc_to_perf_time(ptq->timestamp, &pt->tc);
sample.cpumode = PERF_RECORD_MISC_USER;
sample.ip = ptq->state->from_ip; sample.ip = ptq->state->from_ip;
sample.pid = ptq->pid; sample.pid = ptq->pid;
sample.tid = ptq->tid; sample.tid = ptq->tid;
......
...@@ -417,6 +417,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) ...@@ -417,6 +417,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr)
* use first address as sample address * use first address as sample address
*/ */
memset(&sample, 0, sizeof(sample)); memset(&sample, 0, sizeof(sample));
sample.cpumode = PERF_RECORD_MISC_USER;
sample.pid = pid; sample.pid = pid;
sample.tid = tid; sample.tid = tid;
sample.time = id->time; sample.time = id->time;
...@@ -505,6 +506,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr) ...@@ -505,6 +506,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr)
* use first address as sample address * use first address as sample address
*/ */
memset(&sample, 0, sizeof(sample)); memset(&sample, 0, sizeof(sample));
sample.cpumode = PERF_RECORD_MISC_USER;
sample.pid = pid; sample.pid = pid;
sample.tid = tid; sample.tid = tid;
sample.time = id->time; sample.time = id->time;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment