perf script: Allow printing period for non freq mode groups
authorAndi Kleen <ak@linux.intel.com>
Thu, 9 Nov 2017 14:55:26 +0000 (06:55 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 16 Nov 2017 17:49:55 +0000 (14:49 -0300)
When using leader sampling the values of the not sampled but counted
events are shown by perf script in "period".

Currently printing period is only allowed when the main event has a
period, that is it is in frequency mode.

This implies that we cannot dump the values of counted events when the
leader event is not in frequency mode.

Just remove the check that the period must be set on all events. It will
just be printed as 0 instead if it's not available.

This fixes the following:

  $ perf record -c 100000 -e '{cycles,branches}:S'
  $ perf script -F event,period

Further commentary by Jiri Olsa:

The period will be the value of configured period, not 0:

int perf_evsel__parse_sample(struct ...
  ...
  data->period = evsel->attr.sample_period;

  $ perf record -c 100000
  $ perf script -F event,period | head -3
  Failed to open /tmp/perf-2048.map, continuing without symbols
      100000 cycles:ppp:
      100000 cycles:ppp:

other than that I think we can remove that check, because we will have
always sane number in period

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20171109145528.23371-4-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-script.c

index 9b43bda45a415649a06c7b9743796bff7b760dbe..ee7c7aaaae72eafaba07125df31037a4bd0f5609 100644 (file)
@@ -423,11 +423,6 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
                                           PERF_OUTPUT_CPU, allow_user_set))
                return -EINVAL;
 
-       if (PRINT_FIELD(PERIOD) &&
-               perf_evsel__check_stype(evsel, PERF_SAMPLE_PERIOD, "PERIOD",
-                                       PERF_OUTPUT_PERIOD))
-               return -EINVAL;
-
        if (PRINT_FIELD(IREGS) &&
                perf_evsel__check_stype(evsel, PERF_SAMPLE_REGS_INTR, "IREGS",
                                        PERF_OUTPUT_IREGS))