Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf script: Handle missing fields with -F +..

When using -F + syntax to add a field the existing defaults are
currently all marked user_set. This can cause errors when some field is
missing in the perf.data

This patch tracks the actually user set fields separately, so that we don't
error out in this case.

Before:

% perf record true
% perf script -F +metric
Samples for 'cycles:ppp' event do not have CPU attribute set. Cannot print 'cpu' field.
%

After:

5 perf record true
% perf script -F +metric
perf 28936 278636.237688: 1 cycles:ppp: ffffffff8117da99 perf_event_exec+0x59 (/lib/modules/4.20.0-odilo/build/vmlinux)
...
%

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20190224153722.27020-2-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Andi Kleen and committed by
Arnaldo Carvalho de Melo
4b6ac811 eb617670

+7 -3
+7 -3
tools/perf/builtin-script.c
··· 149 149 unsigned int print_ip_opts; 150 150 u64 fields; 151 151 u64 invalid_fields; 152 + u64 user_set_fields; 152 153 } output[OUTPUT_TYPE_MAX] = { 153 154 154 155 [PERF_TYPE_HARDWARE] = { ··· 346 345 if (attr->sample_type & sample_type) 347 346 return 0; 348 347 349 - if (output[type].user_set) { 348 + if (output[type].user_set_fields & field) { 350 349 if (allow_user_set) 351 350 return 0; 352 351 evname = perf_evsel__name(evsel); ··· 2633 2632 pr_warning("\'%s\' not valid for %s events. Ignoring.\n", 2634 2633 all_output_options[i].str, event_type(j)); 2635 2634 } else { 2636 - if (change == REMOVE) 2635 + if (change == REMOVE) { 2637 2636 output[j].fields &= ~all_output_options[i].field; 2638 - else 2637 + output[j].user_set_fields &= ~all_output_options[i].field; 2638 + } else { 2639 2639 output[j].fields |= all_output_options[i].field; 2640 + output[j].user_set_fields |= all_output_options[i].field; 2641 + } 2640 2642 output[j].user_set = true; 2641 2643 output[j].wildcard_set = true; 2642 2644 }