perf auxtrace: Add machine_pid and vcpu to auxtrace_error
Add machine_pid and vcpu to struct perf_record_auxtrace_error. The existing fmt member is used to identify the new format. The new members make it possible to easily differentiate errors from guest machines. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Ian Rogers <irogers@google.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: kvm@vger.kernel.org Link: https://lore.kernel.org/r/20220711093218.10967-18-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
2273e46b98
commit
7151c1d178
@@ -279,6 +279,8 @@ struct perf_record_auxtrace_error {
|
|||||||
__u64 ip;
|
__u64 ip;
|
||||||
__u64 time;
|
__u64 time;
|
||||||
char msg[MAX_AUXTRACE_ERROR_MSG];
|
char msg[MAX_AUXTRACE_ERROR_MSG];
|
||||||
|
__u32 machine_pid;
|
||||||
|
__u32 vcpu;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct perf_record_aux {
|
struct perf_record_aux {
|
||||||
|
|||||||
@@ -1189,9 +1189,10 @@ void auxtrace_buffer__free(struct auxtrace_buffer *buffer)
|
|||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int type,
|
void auxtrace_synth_guest_error(struct perf_record_auxtrace_error *auxtrace_error, int type,
|
||||||
int code, int cpu, pid_t pid, pid_t tid, u64 ip,
|
int code, int cpu, pid_t pid, pid_t tid, u64 ip,
|
||||||
const char *msg, u64 timestamp)
|
const char *msg, u64 timestamp,
|
||||||
|
pid_t machine_pid, int vcpu)
|
||||||
{
|
{
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
@@ -1207,12 +1208,26 @@ void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int
|
|||||||
auxtrace_error->ip = ip;
|
auxtrace_error->ip = ip;
|
||||||
auxtrace_error->time = timestamp;
|
auxtrace_error->time = timestamp;
|
||||||
strlcpy(auxtrace_error->msg, msg, MAX_AUXTRACE_ERROR_MSG);
|
strlcpy(auxtrace_error->msg, msg, MAX_AUXTRACE_ERROR_MSG);
|
||||||
|
if (machine_pid) {
|
||||||
size = (void *)auxtrace_error->msg - (void *)auxtrace_error +
|
auxtrace_error->fmt = 2;
|
||||||
strlen(auxtrace_error->msg) + 1;
|
auxtrace_error->machine_pid = machine_pid;
|
||||||
|
auxtrace_error->vcpu = vcpu;
|
||||||
|
size = sizeof(*auxtrace_error);
|
||||||
|
} else {
|
||||||
|
size = (void *)auxtrace_error->msg - (void *)auxtrace_error +
|
||||||
|
strlen(auxtrace_error->msg) + 1;
|
||||||
|
}
|
||||||
auxtrace_error->header.size = PERF_ALIGN(size, sizeof(u64));
|
auxtrace_error->header.size = PERF_ALIGN(size, sizeof(u64));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int type,
|
||||||
|
int code, int cpu, pid_t pid, pid_t tid, u64 ip,
|
||||||
|
const char *msg, u64 timestamp)
|
||||||
|
{
|
||||||
|
auxtrace_synth_guest_error(auxtrace_error, type, code, cpu, pid, tid,
|
||||||
|
ip, msg, timestamp, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr,
|
int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr,
|
||||||
struct perf_tool *tool,
|
struct perf_tool *tool,
|
||||||
struct perf_session *session,
|
struct perf_session *session,
|
||||||
@@ -1662,6 +1677,9 @@ size_t perf_event__fprintf_auxtrace_error(union perf_event *event, FILE *fp)
|
|||||||
if (!e->fmt)
|
if (!e->fmt)
|
||||||
msg = (const char *)&e->time;
|
msg = (const char *)&e->time;
|
||||||
|
|
||||||
|
if (e->fmt >= 2 && e->machine_pid)
|
||||||
|
ret += fprintf(fp, " machine_pid %d vcpu %d", e->machine_pid, e->vcpu);
|
||||||
|
|
||||||
ret += fprintf(fp, " cpu %d pid %d tid %d ip %#"PRI_lx64" code %u: %s\n",
|
ret += fprintf(fp, " cpu %d pid %d tid %d ip %#"PRI_lx64" code %u: %s\n",
|
||||||
e->cpu, e->pid, e->tid, e->ip, e->code, msg);
|
e->cpu, e->pid, e->tid, e->ip, e->code, msg);
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -595,6 +595,10 @@ int auxtrace_index__process(int fd, u64 size, struct perf_session *session,
|
|||||||
bool needs_swap);
|
bool needs_swap);
|
||||||
void auxtrace_index__free(struct list_head *head);
|
void auxtrace_index__free(struct list_head *head);
|
||||||
|
|
||||||
|
void auxtrace_synth_guest_error(struct perf_record_auxtrace_error *auxtrace_error, int type,
|
||||||
|
int code, int cpu, pid_t pid, pid_t tid, u64 ip,
|
||||||
|
const char *msg, u64 timestamp,
|
||||||
|
pid_t machine_pid, int vcpu);
|
||||||
void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int type,
|
void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int type,
|
||||||
int code, int cpu, pid_t pid, pid_t tid, u64 ip,
|
int code, int cpu, pid_t pid, pid_t tid, u64 ip,
|
||||||
const char *msg, u64 timestamp);
|
const char *msg, u64 timestamp);
|
||||||
|
|||||||
@@ -1559,7 +1559,7 @@ static void python_process_auxtrace_error(struct perf_session *session __maybe_u
|
|||||||
msg = (const char *)&e->time;
|
msg = (const char *)&e->time;
|
||||||
}
|
}
|
||||||
|
|
||||||
t = tuple_new(9);
|
t = tuple_new(11);
|
||||||
|
|
||||||
tuple_set_u32(t, 0, e->type);
|
tuple_set_u32(t, 0, e->type);
|
||||||
tuple_set_u32(t, 1, e->code);
|
tuple_set_u32(t, 1, e->code);
|
||||||
@@ -1570,6 +1570,8 @@ static void python_process_auxtrace_error(struct perf_session *session __maybe_u
|
|||||||
tuple_set_u64(t, 6, tm);
|
tuple_set_u64(t, 6, tm);
|
||||||
tuple_set_string(t, 7, msg);
|
tuple_set_string(t, 7, msg);
|
||||||
tuple_set_u32(t, 8, cpumode);
|
tuple_set_u32(t, 8, cpumode);
|
||||||
|
tuple_set_s32(t, 9, e->machine_pid);
|
||||||
|
tuple_set_s32(t, 10, e->vcpu);
|
||||||
|
|
||||||
call_object(handler, t, handler_name);
|
call_object(handler, t, handler_name);
|
||||||
|
|
||||||
|
|||||||
@@ -895,6 +895,10 @@ static void perf_event__auxtrace_error_swap(union perf_event *event,
|
|||||||
event->auxtrace_error.ip = bswap_64(event->auxtrace_error.ip);
|
event->auxtrace_error.ip = bswap_64(event->auxtrace_error.ip);
|
||||||
if (event->auxtrace_error.fmt)
|
if (event->auxtrace_error.fmt)
|
||||||
event->auxtrace_error.time = bswap_64(event->auxtrace_error.time);
|
event->auxtrace_error.time = bswap_64(event->auxtrace_error.time);
|
||||||
|
if (event->auxtrace_error.fmt >= 2) {
|
||||||
|
event->auxtrace_error.machine_pid = bswap_32(event->auxtrace_error.machine_pid);
|
||||||
|
event->auxtrace_error.vcpu = bswap_32(event->auxtrace_error.vcpu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void perf_event__thread_map_swap(union perf_event *event,
|
static void perf_event__thread_map_swap(union perf_event *event,
|
||||||
|
|||||||
Reference in New Issue
Block a user