|
@@ -93,6 +93,7 @@ enum perf_output_field {
|
|
|
PERF_OUTPUT_PHYS_ADDR = 1U << 26,
|
|
|
PERF_OUTPUT_UREGS = 1U << 27,
|
|
|
PERF_OUTPUT_METRIC = 1U << 28,
|
|
|
+ PERF_OUTPUT_MISC = 1U << 29,
|
|
|
};
|
|
|
|
|
|
struct output_option {
|
|
@@ -128,6 +129,7 @@ struct output_option {
|
|
|
{.str = "synth", .field = PERF_OUTPUT_SYNTH},
|
|
|
{.str = "phys_addr", .field = PERF_OUTPUT_PHYS_ADDR},
|
|
|
{.str = "metric", .field = PERF_OUTPUT_METRIC},
|
|
|
+ {.str = "misc", .field = PERF_OUTPUT_MISC},
|
|
|
};
|
|
|
|
|
|
enum {
|
|
@@ -594,7 +596,8 @@ static int perf_sample__fprintf_uregs(struct perf_sample *sample,
|
|
|
|
|
|
static int perf_sample__fprintf_start(struct perf_sample *sample,
|
|
|
struct thread *thread,
|
|
|
- struct perf_evsel *evsel, FILE *fp)
|
|
|
+ struct perf_evsel *evsel,
|
|
|
+ u32 type, FILE *fp)
|
|
|
{
|
|
|
struct perf_event_attr *attr = &evsel->attr;
|
|
|
unsigned long secs;
|
|
@@ -624,6 +627,47 @@ static int perf_sample__fprintf_start(struct perf_sample *sample,
|
|
|
printed += fprintf(fp, "[%03d] ", sample->cpu);
|
|
|
}
|
|
|
|
|
|
+ if (PRINT_FIELD(MISC)) {
|
|
|
+ int ret = 0;
|
|
|
+
|
|
|
+ #define has(m) \
|
|
|
+ (sample->misc & PERF_RECORD_MISC_##m) == PERF_RECORD_MISC_##m
|
|
|
+
|
|
|
+ if (has(KERNEL))
|
|
|
+ ret += fprintf(fp, "K");
|
|
|
+ if (has(USER))
|
|
|
+ ret += fprintf(fp, "U");
|
|
|
+ if (has(HYPERVISOR))
|
|
|
+ ret += fprintf(fp, "H");
|
|
|
+ if (has(GUEST_KERNEL))
|
|
|
+ ret += fprintf(fp, "G");
|
|
|
+ if (has(GUEST_USER))
|
|
|
+ ret += fprintf(fp, "g");
|
|
|
+
|
|
|
+ switch (type) {
|
|
|
+ case PERF_RECORD_MMAP:
|
|
|
+ case PERF_RECORD_MMAP2:
|
|
|
+ if (has(MMAP_DATA))
|
|
|
+ ret += fprintf(fp, "M");
|
|
|
+ break;
|
|
|
+ case PERF_RECORD_COMM:
|
|
|
+ if (has(COMM_EXEC))
|
|
|
+ ret += fprintf(fp, "E");
|
|
|
+ break;
|
|
|
+ case PERF_RECORD_SWITCH:
|
|
|
+ case PERF_RECORD_SWITCH_CPU_WIDE:
|
|
|
+ if (has(SWITCH_OUT))
|
|
|
+ ret += fprintf(fp, "S");
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ #undef has
|
|
|
+
|
|
|
+ ret += fprintf(fp, "%*s", 6 - ret, " ");
|
|
|
+ printed += ret;
|
|
|
+ }
|
|
|
+
|
|
|
if (PRINT_FIELD(TIME)) {
|
|
|
nsecs = sample->time;
|
|
|
secs = nsecs / NSEC_PER_SEC;
|
|
@@ -1502,7 +1546,7 @@ static void script_print_metric(void *ctx, const char *color,
|
|
|
if (!fmt)
|
|
|
return;
|
|
|
perf_sample__fprintf_start(mctx->sample, mctx->thread, mctx->evsel,
|
|
|
- mctx->fp);
|
|
|
+ PERF_RECORD_SAMPLE, mctx->fp);
|
|
|
fputs("\tmetric: ", mctx->fp);
|
|
|
if (color)
|
|
|
color_fprintf(mctx->fp, color, fmt, val);
|
|
@@ -1516,7 +1560,7 @@ static void script_new_line(void *ctx)
|
|
|
struct metric_ctx *mctx = ctx;
|
|
|
|
|
|
perf_sample__fprintf_start(mctx->sample, mctx->thread, mctx->evsel,
|
|
|
- mctx->fp);
|
|
|
+ PERF_RECORD_SAMPLE, mctx->fp);
|
|
|
fputs("\tmetric: ", mctx->fp);
|
|
|
}
|
|
|
|
|
@@ -1584,7 +1628,8 @@ static void process_event(struct perf_script *script,
|
|
|
|
|
|
++es->samples;
|
|
|
|
|
|
- perf_sample__fprintf_start(sample, thread, evsel, fp);
|
|
|
+ perf_sample__fprintf_start(sample, thread, evsel,
|
|
|
+ PERF_RECORD_SAMPLE, fp);
|
|
|
|
|
|
if (PRINT_FIELD(PERIOD))
|
|
|
fprintf(fp, "%10" PRIu64 " ", sample->period);
|
|
@@ -1833,7 +1878,8 @@ static int process_comm_event(struct perf_tool *tool,
|
|
|
sample->tid = event->comm.tid;
|
|
|
sample->pid = event->comm.pid;
|
|
|
}
|
|
|
- perf_sample__fprintf_start(sample, thread, evsel, stdout);
|
|
|
+ perf_sample__fprintf_start(sample, thread, evsel,
|
|
|
+ PERF_RECORD_COMM, stdout);
|
|
|
perf_event__fprintf(event, stdout);
|
|
|
ret = 0;
|
|
|
out:
|
|
@@ -1868,7 +1914,8 @@ static int process_namespaces_event(struct perf_tool *tool,
|
|
|
sample->tid = event->namespaces.tid;
|
|
|
sample->pid = event->namespaces.pid;
|
|
|
}
|
|
|
- perf_sample__fprintf_start(sample, thread, evsel, stdout);
|
|
|
+ perf_sample__fprintf_start(sample, thread, evsel,
|
|
|
+ PERF_RECORD_NAMESPACES, stdout);
|
|
|
perf_event__fprintf(event, stdout);
|
|
|
ret = 0;
|
|
|
out:
|
|
@@ -1901,7 +1948,8 @@ static int process_fork_event(struct perf_tool *tool,
|
|
|
sample->tid = event->fork.tid;
|
|
|
sample->pid = event->fork.pid;
|
|
|
}
|
|
|
- perf_sample__fprintf_start(sample, thread, evsel, stdout);
|
|
|
+ perf_sample__fprintf_start(sample, thread, evsel,
|
|
|
+ PERF_RECORD_FORK, stdout);
|
|
|
perf_event__fprintf(event, stdout);
|
|
|
thread__put(thread);
|
|
|
|
|
@@ -1930,7 +1978,8 @@ static int process_exit_event(struct perf_tool *tool,
|
|
|
sample->tid = event->fork.tid;
|
|
|
sample->pid = event->fork.pid;
|
|
|
}
|
|
|
- perf_sample__fprintf_start(sample, thread, evsel, stdout);
|
|
|
+ perf_sample__fprintf_start(sample, thread, evsel,
|
|
|
+ PERF_RECORD_EXIT, stdout);
|
|
|
perf_event__fprintf(event, stdout);
|
|
|
|
|
|
if (perf_event__process_exit(tool, event, sample, machine) < 0)
|
|
@@ -1965,7 +2014,8 @@ static int process_mmap_event(struct perf_tool *tool,
|
|
|
sample->tid = event->mmap.tid;
|
|
|
sample->pid = event->mmap.pid;
|
|
|
}
|
|
|
- perf_sample__fprintf_start(sample, thread, evsel, stdout);
|
|
|
+ perf_sample__fprintf_start(sample, thread, evsel,
|
|
|
+ PERF_RECORD_MMAP, stdout);
|
|
|
perf_event__fprintf(event, stdout);
|
|
|
thread__put(thread);
|
|
|
return 0;
|
|
@@ -1996,7 +2046,8 @@ static int process_mmap2_event(struct perf_tool *tool,
|
|
|
sample->tid = event->mmap2.tid;
|
|
|
sample->pid = event->mmap2.pid;
|
|
|
}
|
|
|
- perf_sample__fprintf_start(sample, thread, evsel, stdout);
|
|
|
+ perf_sample__fprintf_start(sample, thread, evsel,
|
|
|
+ PERF_RECORD_MMAP2, stdout);
|
|
|
perf_event__fprintf(event, stdout);
|
|
|
thread__put(thread);
|
|
|
return 0;
|
|
@@ -2022,7 +2073,8 @@ static int process_switch_event(struct perf_tool *tool,
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- perf_sample__fprintf_start(sample, thread, evsel, stdout);
|
|
|
+ perf_sample__fprintf_start(sample, thread, evsel,
|
|
|
+ PERF_RECORD_SWITCH, stdout);
|
|
|
perf_event__fprintf(event, stdout);
|
|
|
thread__put(thread);
|
|
|
return 0;
|