perf tools: Add cpumode to struct perf_sample
To avoid parsing event->header.misc in many locations. This will also allow setting perf.sample.{ip,cpumode} in a single place, from tracepoint fields, as needed by 'perf kvm' with PPC guests, where the guest hardware counters is not available at the host. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Hemant Kumar <hemant@linux.vnet.ibm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-qp3yradhyt6q3wl895b1aat0@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
@@ -28,7 +28,6 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct addr_location al;
|
||||
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
|
||||
struct thread *thread = machine__findnew_thread(machine, sample->pid,
|
||||
sample->tid);
|
||||
|
||||
@@ -38,7 +37,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
|
||||
return -1;
|
||||
}
|
||||
|
||||
thread__find_addr_map(thread, cpumode, MAP__FUNCTION, sample->ip, &al);
|
||||
thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, sample->ip, &al);
|
||||
|
||||
if (al.map != NULL)
|
||||
al.map->dso->hit = 1;
|
||||
|
@@ -1295,12 +1295,11 @@ void thread__find_addr_location(struct thread *thread,
|
||||
* Callers need to drop the reference to al->thread, obtained in
|
||||
* machine__findnew_thread()
|
||||
*/
|
||||
int perf_event__preprocess_sample(const union perf_event *event,
|
||||
int perf_event__preprocess_sample(const union perf_event *event __maybe_unused,
|
||||
struct machine *machine,
|
||||
struct addr_location *al,
|
||||
struct perf_sample *sample)
|
||||
{
|
||||
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
|
||||
struct thread *thread = machine__findnew_thread(machine, sample->pid,
|
||||
sample->tid);
|
||||
|
||||
@@ -1315,11 +1314,11 @@ int perf_event__preprocess_sample(const union perf_event *event,
|
||||
* events, but for older perf.data files there was no such thing, so do
|
||||
* it now.
|
||||
*/
|
||||
if (cpumode == PERF_RECORD_MISC_KERNEL &&
|
||||
if (sample->cpumode == PERF_RECORD_MISC_KERNEL &&
|
||||
machine__kernel_map(machine) == NULL)
|
||||
machine__create_kernel_maps(machine);
|
||||
|
||||
thread__find_addr_map(thread, cpumode, MAP__FUNCTION, sample->ip, al);
|
||||
thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, sample->ip, al);
|
||||
dump_printf(" ...... dso: %s\n",
|
||||
al->map ? al->map->dso->long_name :
|
||||
al->level == 'H' ? "[hypervisor]" : "<not found>");
|
||||
@@ -1395,16 +1394,14 @@ bool sample_addr_correlates_sym(struct perf_event_attr *attr)
|
||||
return false;
|
||||
}
|
||||
|
||||
void perf_event__preprocess_sample_addr(union perf_event *event,
|
||||
void perf_event__preprocess_sample_addr(union perf_event *event __maybe_unused,
|
||||
struct perf_sample *sample,
|
||||
struct thread *thread,
|
||||
struct addr_location *al)
|
||||
{
|
||||
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
|
||||
|
||||
thread__find_addr_map(thread, cpumode, MAP__FUNCTION, sample->addr, al);
|
||||
thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, sample->addr, al);
|
||||
if (!al->map)
|
||||
thread__find_addr_map(thread, cpumode, MAP__VARIABLE,
|
||||
thread__find_addr_map(thread, sample->cpumode, MAP__VARIABLE,
|
||||
sample->addr, al);
|
||||
|
||||
al->cpu = sample->cpu;
|
||||
|
@@ -192,6 +192,7 @@ struct perf_sample {
|
||||
u64 data_src;
|
||||
u32 flags;
|
||||
u16 insn_len;
|
||||
u8 cpumode;
|
||||
void *raw_data;
|
||||
struct ip_callchain *callchain;
|
||||
struct branch_stack *branch_stack;
|
||||
|
@@ -1643,6 +1643,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
|
||||
data->stream_id = data->id = data->time = -1ULL;
|
||||
data->period = evsel->attr.sample_period;
|
||||
data->weight = 0;
|
||||
data->cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
|
||||
|
||||
if (event->header.type != PERF_RECORD_SAMPLE) {
|
||||
if (!evsel->attr.sample_id_all)
|
||||
|
@@ -1301,9 +1301,8 @@ out_problem:
|
||||
|
||||
int machine__process_mmap2_event(struct machine *machine,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample __maybe_unused)
|
||||
struct perf_sample *sample)
|
||||
{
|
||||
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
|
||||
struct thread *thread;
|
||||
struct map *map;
|
||||
enum map_type type;
|
||||
@@ -1312,8 +1311,8 @@ int machine__process_mmap2_event(struct machine *machine,
|
||||
if (dump_trace)
|
||||
perf_event__fprintf_mmap2(event, stdout);
|
||||
|
||||
if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
|
||||
cpumode == PERF_RECORD_MISC_KERNEL) {
|
||||
if (sample->cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
|
||||
sample->cpumode == PERF_RECORD_MISC_KERNEL) {
|
||||
ret = machine__process_kernel_mmap_event(machine, event);
|
||||
if (ret < 0)
|
||||
goto out_problem;
|
||||
@@ -1355,9 +1354,8 @@ out_problem:
|
||||
}
|
||||
|
||||
int machine__process_mmap_event(struct machine *machine, union perf_event *event,
|
||||
struct perf_sample *sample __maybe_unused)
|
||||
struct perf_sample *sample)
|
||||
{
|
||||
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
|
||||
struct thread *thread;
|
||||
struct map *map;
|
||||
enum map_type type;
|
||||
@@ -1366,8 +1364,8 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
|
||||
if (dump_trace)
|
||||
perf_event__fprintf_mmap(event, stdout);
|
||||
|
||||
if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
|
||||
cpumode == PERF_RECORD_MISC_KERNEL) {
|
||||
if (sample->cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
|
||||
sample->cpumode == PERF_RECORD_MISC_KERNEL) {
|
||||
ret = machine__process_kernel_mmap_event(machine, event);
|
||||
if (ret < 0)
|
||||
goto out_problem;
|
||||
|
@@ -1107,12 +1107,11 @@ static struct machine *machines__find_for_cpumode(struct machines *machines,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample)
|
||||
{
|
||||
const u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
|
||||
struct machine *machine;
|
||||
|
||||
if (perf_guest &&
|
||||
((cpumode == PERF_RECORD_MISC_GUEST_KERNEL) ||
|
||||
(cpumode == PERF_RECORD_MISC_GUEST_USER))) {
|
||||
((sample->cpumode == PERF_RECORD_MISC_GUEST_KERNEL) ||
|
||||
(sample->cpumode == PERF_RECORD_MISC_GUEST_USER))) {
|
||||
u32 pid;
|
||||
|
||||
if (event->header.type == PERF_RECORD_MMAP
|
||||
|
Reference in New Issue
Block a user