[PATCH -next v5 0/2] perf stat: Support inherit events for bperf

Tengda Wu posted 2 patches 1 month ago
tools/perf/builtin-stat.c                     |  1 +
tools/perf/tests/shell/stat_bpf_counters.sh   |  2 +-
tools/perf/util/bpf_counter.c                 | 35 +++++--
tools/perf/util/bpf_skel/bperf_follower.bpf.c | 98 +++++++++++++++++--
tools/perf/util/bpf_skel/bperf_u.h            |  5 +
tools/perf/util/target.h                      |  1 +
6 files changed, 127 insertions(+), 15 deletions(-)
[PATCH -next v5 0/2] perf stat: Support inherit events for bperf
Posted by Tengda Wu 1 month ago
Hello,

Here is the 5th version of the series to support inherit events for bperf.
This version added the `inherit` flag for struct `target` instead of
`bpf_stat_opts`, and also fixed the logic when TGID w/o inherit.


bperf (perf-stat --bpf-counter) has not supported inherit events during
fork() since it was first introduced.

This patch series tries to add this support by:
 1) adding two new bpf programs to monitor task lifecycle;
 2) recording new tasks in the filter map dynamically;
 3) reusing `accum_key` of parent task for new tasks.

Thanks,
Tengda


Changelog:
---------
v5: (Address comments from Namhyung, thanks)
 * Add the `inherit` flag for struct `target` instead of `bpf_stat_opts`
 * Fix the logic when TGID w/o inherit

v4: https://lore.kernel.org/all/20241012023225.151084-1-wutengda@huaweicloud.com/
 * Add an `inherit` flag to bperf to control inherit behavior

v3: https://lore.kernel.org/all/20240916014318.267709-1-wutengda@huaweicloud.com/
 * Use pid or tgid based on filter type in new_task prog
 * Add comments to explain pid usage for TGID type in exit_task prog

v2: https://lore.kernel.org/all/20240905115918.772234-1-wutengda@huaweicloud.com/
 * Remove the unused init_filter_entries in follower bpf, declare
   a global filter_entry_count in bpf_counter instead
 * Attach on_newtask and on_exittask progs only if the filter type
   is either PID or TGID

v1: https://lore.kernel.org/all/20240904123103.732507-1-wutengda@huaweicloud.com/


Tengda Wu (2):
  perf stat: Support inherit events during fork() for bperf
  perf test: Use sqrtloop workload to test bperf event

 tools/perf/builtin-stat.c                     |  1 +
 tools/perf/tests/shell/stat_bpf_counters.sh   |  2 +-
 tools/perf/util/bpf_counter.c                 | 35 +++++--
 tools/perf/util/bpf_skel/bperf_follower.bpf.c | 98 +++++++++++++++++--
 tools/perf/util/bpf_skel/bperf_u.h            |  5 +
 tools/perf/util/target.h                      |  1 +
 6 files changed, 127 insertions(+), 15 deletions(-)

-- 
2.34.1
Re: [PATCH -next v5 0/2] perf stat: Support inherit events for bperf
Posted by Namhyung Kim 3 weeks ago
On Mon, 21 Oct 2024 11:01:59 +0000, Tengda Wu wrote:

> Here is the 5th version of the series to support inherit events for bperf.
> This version added the `inherit` flag for struct `target` instead of
> `bpf_stat_opts`, and also fixed the logic when TGID w/o inherit.
> 
> 
> bperf (perf-stat --bpf-counter) has not supported inherit events during
> fork() since it was first introduced.
> 
> [...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung
Re: [PATCH -next v5 0/2] perf stat: Support inherit events for bperf
Posted by Tengda Wu 3 weeks ago

On 2024/11/5 1:51, Namhyung Kim wrote:
> On Mon, 21 Oct 2024 11:01:59 +0000, Tengda Wu wrote:
> 
>> Here is the 5th version of the series to support inherit events for bperf.
>> This version added the `inherit` flag for struct `target` instead of
>> `bpf_stat_opts`, and also fixed the logic when TGID w/o inherit.
>>
>>
>> bperf (perf-stat --bpf-counter) has not supported inherit events during
>> fork() since it was first introduced.
>>
>> [...]
> 
> Applied to perf-tools-next, thanks!
> 
> Best regards,
> Namhyung

You're welcome, thank you!

With Best regards,
Tengda