• Weilin Wang's avatar
    perf stat: Fork and launch 'perf record' when 'perf stat' needs to get retire... · 8db5cabc
    Weilin Wang authored
    perf stat: Fork and launch 'perf record' when 'perf stat' needs to get retire latency value for a metric.
    
    When retire_latency value is used in a metric formula, evsel would fork
    a 'perf record' process with "-e" and "-W" options. 'perf record' will
    collect required retire_latency values in parallel while 'perf stat' is
    collecting counting values.
    
    At the point of time that 'perf stat' stops counting, evsel would stop
    'perf record' by sending sigterm signal to 'perf record' process.
    Sampled data will be processed to get retire latency value. Another
    thread is required to synchronize between 'perf stat' and 'perf record'
    when we pass data through pipe.
    
    Retire_latency evsel is not opened for 'perf stat' so that there is no
    counter wasted on it. This commit includes code suggested by Namhyung to
    adjust reading size for groups that include retire_latency evsels.
    
    In current :R parsing implementation, the parser would recognize events
    with retire_latency modifier and insert them into the evlist like a
    normal event.  Ideally, we need to avoid counting these events.
    
    In this commit, at the time when a retire_latency evsel is read, set the
    retire latency value processed from the sampled data to count value.
    This sampled retire latency value will be used for metric calculation
    and final event count print out. No special metric calculation and event
    print out code required for retire_latency events.
    Reviewed-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Signed-off-by: default avatarWeilin Wang <weilin.wang@intel.com>
    Acked-by: default avatarIan Rogers <irogers@google.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Caleb Biggers <caleb.biggers@intel.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Perry Taylor <perry.taylor@intel.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Samantha Alt <samantha.alt@intel.com>
    Link: https://lore.kernel.org/r/20240720062102.444578-4-weilin.wang@intel.com
    [ Squashed the 3rd and 4th commit in the series to keep it building patch by patch ]
    [ Constified the 'struct perf_tool' pointer in process_sample_event() ]
    [ Use perf_tool__init(&tool, false) to address a segfault I reported and Ian/Weilin diagnosed ]
    Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    8db5cabc
intel-tpebs.c 9.77 KB