• D
    perf sort: Use default sort if evlist is empty · 64831a21
    David Carrillo-Cisneros 提交于
    Fixes bug noted by Jiri in https://lkml.org/lkml/2017/6/13/755 and
    caused by commit d49dadea ("perf tools: Make 'trace' or
    'trace_fields' sort key default for tracepoint events") not taking into
    account that evlist is empty in pipe-mode.
    
    Before this commit, pipe mode will only show bogus "100.00%  N/A"
    instead of correct output as follows:
    
      $ perf record -o - sleep 1 | perf report -i -
      # To display the perf.data header info, please use --header/--header-only options.
      #
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 0.000 MB - ]
      #
      # Total Lost Samples: 0
      #
      # Samples: 8  of event 'cycles:ppH'
      # Event count (approx.): 145658
      #
      # Overhead  Trace output
      # ........  ............
      #
         100.00%  N/A
    
    Correct output, after patch:
    
      $ perf record -o - sleep 1 | perf report -i -
      # To display the perf.data header info, please use --header/--header-only options.
      #
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 0.000 MB - ]
      #
      # Total Lost Samples: 0
      #
      # Samples: 8  of event 'cycles:ppH'
      # Event count (approx.): 191331
      #
      # Overhead  Command  Shared Object      Symbol
      # ........  .......  .................  .................................
      #
          81.63%  sleep    libc-2.19.so       [.] _exit
          13.58%  sleep    ld-2.19.so         [.] do_lookup_x
           2.34%  sleep    [kernel.kallsyms]  [k] context_switch
           2.34%  sleep    libc-2.19.so       [.] __GI___libc_nanosleep
           0.11%  perf     [kernel.kallsyms]  [k] __intel_pmu_enable_a
    Reported-by: NJiri Olsa <jolsa@kernel.org>
    Report-Link: https://lkml.kernel.org/r/20170613185422.GA6092@kravaSigned-off-by: NDavid Carrillo-Cisneros <davidcc@google.com>
    Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Paul Turner <pjt@google.com>
    Cc: Simon Que <sque@chromium.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Wang Nan <wangnan0@huawei.com>
    Fixes: d49dadea ("perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events")
    Link: https://lkml.kernel.org/r/20170721051157.47331-1-davidcc@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    64831a21
sort.c 69.2 KB