• N
    perf record: Synthesize cgroup events only if needed · aa50d953
    Namhyung Kim 提交于
    It didn't check the tool->cgroup_events bit which is set when the
    --all-cgroups option is given.  Without it, samples will not have cgroup
    info so no reason to synthesize.
    
    We can check the PERF_RECORD_CGROUP records after running perf record
    *WITHOUT* the --all-cgroups option:
    
    Before:
    
      $ perf report -D | grep CGROUP
      0 0 0x8430 [0x38]: PERF_RECORD_CGROUP cgroup: 1 /
              CGROUP events:          1
              CGROUP events:          0
              CGROUP events:          0
    
    After:
    
      $ perf report -D | grep CGROUP
              CGROUP events:          0
              CGROUP events:          0
              CGROUP events:          0
    
    Committer testing:
    
    Before:
    
      # perf record -a sleep 1
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 2.208 MB perf.data (10003 samples) ]
      # perf report -D | grep "CGROUP events"
                CGROUP events:        146
                CGROUP events:          0
                CGROUP events:          0
      #
    
    After:
    
      # perf record -a sleep 1
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 2.208 MB perf.data (10448 samples) ]
      # perf report -D | grep "CGROUP events"
                CGROUP events:          0
                CGROUP events:          0
                CGROUP events:          0
      #
    
    With all-cgroups:
    
      # perf record --all-cgroups -a sleep 1
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 2.374 MB perf.data (11526 samples) ]
      # perf report -D | grep "CGROUP events"
                CGROUP events:        146
                CGROUP events:          0
                CGROUP events:          0
      #
    
    Fixes: 8fb4b679 ("perf record: Add --all-cgroups option")
    Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
    Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    Acked-by: NJiri Olsa <jolsa@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Link: http://lore.kernel.org/lkml/20201127054356.405481-1-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    aa50d953
synthetic-events.c 48.7 KB