• Stephane Eranian's avatar
    perf stat: Fix CSV mode column output for non-cgroup events · 52ed1f4c
    Stephane Eranian authored
    [ Upstream commit bc4da38a ]
    
    When using the -x option, perf stat prints CSV-style output with one
    event per line.  For each event, it prints the count, the unit, the
    event name, the cgroup, and a bunch of other event specific fields (such
    as insn per cycles).
    
    When you use CSV-style mode, you expect a normalized output where each
    event is printed with the same number of fields regardless of what it is
    so it can easily be imported into a spreadsheet or parsed.
    
    For instance, if an event does not have a unit, then print an empty
    field for it.
    
    Although this approach was implemented for the unit, it was not for the
    cgroup.
    
    When mixing cgroup and non-cgroup events, then non-cgroup events would
    not show an empty field, instead the next field was printed, make
    columns not line up correctly.
    
    This patch fixes the cgroup output issues by forcing an empty field
    for non-cgroup events as soon as one event has cgroup.
    
    Before:
    
      <not counted> @ @cycles @foo    @ 0    @100.00@@
      2531614       @ @cycles @6420922@100.00@    @
    
    foo cgroup lines up with time_running!
    
    After:
    
      <not counted> @ @cycles @foo @0       @100.00@@
      2594834       @ @cycles @    @5287372 @100.00@@
    
    Fields line up.
    Signed-off-by: 's avatarStephane Eranian <eranian@google.com>
    Acked-by: 's avatarJiri Olsa <jolsa@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: http://lkml.kernel.org/r/1541587845-9150-1-git-send-email-eranian@google.comSigned-off-by: 's avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: 's avatarSasha Levin <sashal@kernel.org>
    52ed1f4c
Name
Last commit
Last update
..
accounting Loading commit data...
arch Loading commit data...
bpf Loading commit data...
build Loading commit data...
cgroup Loading commit data...
crypto Loading commit data...
firewire Loading commit data...
gpio Loading commit data...
hv Loading commit data...
iio Loading commit data...
include Loading commit data...
kvm/kvm_stat Loading commit data...
laptop Loading commit data...
leds Loading commit data...
lib Loading commit data...
memory-model Loading commit data...
nfsd Loading commit data...
objtool Loading commit data...
pci Loading commit data...
pcmcia Loading commit data...
perf Loading commit data...
power Loading commit data...
scripts Loading commit data...
spi Loading commit data...
testing Loading commit data...
thermal/tmon Loading commit data...
time Loading commit data...
usb Loading commit data...
virtio Loading commit data...
vm Loading commit data...
wmi Loading commit data...
Makefile Loading commit data...