Commit 924a2215 authored by Shawn M. Chapla's avatar Shawn M. Chapla Committed by Arnaldo Carvalho de Melo

perf data convert: Prefer sampled CPU when exporting JSON

When CPU has been explicitly sampled (via --sample-cpu), prefer this
sampled value over the thread CPU value when exporting to JSON.
Signed-off-by: default avatarShawn M. Chapla <schapla@codeweavers.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220526201506.2028281-1-schapla@codeweavers.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 399bd66e
...@@ -149,6 +149,7 @@ static int process_sample_event(struct perf_tool *tool, ...@@ -149,6 +149,7 @@ static int process_sample_event(struct perf_tool *tool,
struct convert_json *c = container_of(tool, struct convert_json, tool); struct convert_json *c = container_of(tool, struct convert_json, tool);
FILE *out = c->out; FILE *out = c->out;
struct addr_location al, tal; struct addr_location al, tal;
u64 sample_type = __evlist__combined_sample_type(evsel->evlist);
u8 cpumode = PERF_RECORD_MISC_USER; u8 cpumode = PERF_RECORD_MISC_USER;
if (machine__resolve(machine, &al, sample) < 0) { if (machine__resolve(machine, &al, sample) < 0) {
...@@ -168,7 +169,9 @@ static int process_sample_event(struct perf_tool *tool, ...@@ -168,7 +169,9 @@ static int process_sample_event(struct perf_tool *tool,
output_json_key_format(out, true, 3, "pid", "%i", al.thread->pid_); output_json_key_format(out, true, 3, "pid", "%i", al.thread->pid_);
output_json_key_format(out, true, 3, "tid", "%i", al.thread->tid); output_json_key_format(out, true, 3, "tid", "%i", al.thread->tid);
if (al.thread->cpu >= 0) if ((sample_type & PERF_SAMPLE_CPU))
output_json_key_format(out, true, 3, "cpu", "%i", sample->cpu);
else if (al.thread->cpu >= 0)
output_json_key_format(out, true, 3, "cpu", "%i", al.thread->cpu); output_json_key_format(out, true, 3, "cpu", "%i", al.thread->cpu);
output_json_key_string(out, true, 3, "comm", thread__comm_str(al.thread)); output_json_key_string(out, true, 3, "comm", thread__comm_str(al.thread));
......
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