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

Tengda Wu posted 2 patches 2 months, 2 weeks ago
There is a newer version of this series
tools/perf/tests/shell/stat_bpf_counters.sh   |  2 +-
tools/perf/util/bpf_counter.c                 | 32 +++++--
tools/perf/util/bpf_skel/bperf_follower.bpf.c | 87 +++++++++++++++++--
tools/perf/util/bpf_skel/bperf_u.h            |  5 ++
4 files changed, 112 insertions(+), 14 deletions(-)
[PATCH -next v3 0/2] perf stat: Support inherit events for bperf
Posted by Tengda Wu 2 months, 2 weeks ago
Hi,

Here is the 3th version of the series to support inherit events for bperf.
This version add pid or tgid selection based on filter type in new_task
prog to avoid memory waste and potential count loss.


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:
---------
v3: (Address comments from Namhyung, thanks)
 * 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/tests/shell/stat_bpf_counters.sh   |  2 +-
 tools/perf/util/bpf_counter.c                 | 32 +++++--
 tools/perf/util/bpf_skel/bperf_follower.bpf.c | 87 +++++++++++++++++--
 tools/perf/util/bpf_skel/bperf_u.h            |  5 ++
 4 files changed, 112 insertions(+), 14 deletions(-)

-- 
2.34.1
Re: [PATCH -next v3 0/2] perf stat: Support inherit events for bperf
Posted by Tengda Wu 2 months ago
Hello,

Sorry for pinging again. Is there any other suggestion with this patch set?
If there is, please let me know.

Thanks,
Tengda

On 2024/9/16 9:43, Tengda Wu wrote:
> Hi,
> 
> Here is the 3th version of the series to support inherit events for bperf.
> This version add pid or tgid selection based on filter type in new_task
> prog to avoid memory waste and potential count loss.
> 
> 
> 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:
> ---------
> v3: (Address comments from Namhyung, thanks)
>  * 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/tests/shell/stat_bpf_counters.sh   |  2 +-
>  tools/perf/util/bpf_counter.c                 | 32 +++++--
>  tools/perf/util/bpf_skel/bperf_follower.bpf.c | 87 +++++++++++++++++--
>  tools/perf/util/bpf_skel/bperf_u.h            |  5 ++
>  4 files changed, 112 insertions(+), 14 deletions(-)
>
Re: [PATCH -next v3 0/2] perf stat: Support inherit events for bperf
Posted by Namhyung Kim 2 months ago
Hello,

On Wed, Sep 25, 2024 at 10:16:16PM +0800, Tengda Wu wrote:
> Hello,
> 
> Sorry for pinging again. Is there any other suggestion with this patch set?
> If there is, please let me know.

Sorry I was traveling last week.  I think it's good now.

Song, can I get your ack?

Thanks,
Namhyung

> 
> On 2024/9/16 9:43, Tengda Wu wrote:
> > Hi,
> > 
> > Here is the 3th version of the series to support inherit events for bperf.
> > This version add pid or tgid selection based on filter type in new_task
> > prog to avoid memory waste and potential count loss.
> > 
> > 
> > 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:
> > ---------
> > v3: (Address comments from Namhyung, thanks)
> >  * 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/tests/shell/stat_bpf_counters.sh   |  2 +-
> >  tools/perf/util/bpf_counter.c                 | 32 +++++--
> >  tools/perf/util/bpf_skel/bperf_follower.bpf.c | 87 +++++++++++++++++--
> >  tools/perf/util/bpf_skel/bperf_u.h            |  5 ++
> >  4 files changed, 112 insertions(+), 14 deletions(-)
> > 
>
Re: [PATCH -next v3 0/2] perf stat: Support inherit events for bperf
Posted by Namhyung Kim 1 month, 3 weeks ago
On Wed, Sep 25, 2024 at 08:43:50PM -0700, Namhyung Kim wrote:
> Hello,
> 
> On Wed, Sep 25, 2024 at 10:16:16PM +0800, Tengda Wu wrote:
> > Hello,
> > 
> > Sorry for pinging again. Is there any other suggestion with this patch set?
> > If there is, please let me know.
> 
> Sorry I was traveling last week.  I think it's good now.
> 
> Song, can I get your ack?

He seems to be very busy.  I'll pick this up and run some tests.

Thanks,
Namhyung

> 
> > 
> > On 2024/9/16 9:43, Tengda Wu wrote:
> > > Hi,
> > > 
> > > Here is the 3th version of the series to support inherit events for bperf.
> > > This version add pid or tgid selection based on filter type in new_task
> > > prog to avoid memory waste and potential count loss.
> > > 
> > > 
> > > 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:
> > > ---------
> > > v3: (Address comments from Namhyung, thanks)
> > >  * 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/tests/shell/stat_bpf_counters.sh   |  2 +-
> > >  tools/perf/util/bpf_counter.c                 | 32 +++++--
> > >  tools/perf/util/bpf_skel/bperf_follower.bpf.c | 87 +++++++++++++++++--
> > >  tools/perf/util/bpf_skel/bperf_u.h            |  5 ++
> > >  4 files changed, 112 insertions(+), 14 deletions(-)
> > > 
> >
Re: [PATCH -next v3 0/2] perf stat: Support inherit events for bperf
Posted by Song Liu 1 month, 3 weeks ago
Hi Namhyung,

On Tue, Oct 8, 2024 at 10:21 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Wed, Sep 25, 2024 at 08:43:50PM -0700, Namhyung Kim wrote:
> > Hello,
> >
> > On Wed, Sep 25, 2024 at 10:16:16PM +0800, Tengda Wu wrote:
> > > Hello,
> > >
> > > Sorry for pinging again. Is there any other suggestion with this patch set?
> > > If there is, please let me know.
> >
> > Sorry I was traveling last week.  I think it's good now.
> >
> > Song, can I get your ack?
>
> He seems to be very busy.  I'll pick this up and run some tests.

Sorry for the late reply. I somehow missed the earlier email.

I have a question and a nitpick for 1/2. Otherwise, this looks good
to me.

Thanks,
Song
Re: [PATCH -next v3 0/2] perf stat: Support inherit events for bperf
Posted by Namhyung Kim 1 month, 2 weeks ago
Hi Song,

On Wed, Oct 09, 2024 at 10:21:05AM -0700, Song Liu wrote:
> Hi Namhyung,
> 
> On Tue, Oct 8, 2024 at 10:21 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > On Wed, Sep 25, 2024 at 08:43:50PM -0700, Namhyung Kim wrote:
> > > Hello,
> > >
> > > On Wed, Sep 25, 2024 at 10:16:16PM +0800, Tengda Wu wrote:
> > > > Hello,
> > > >
> > > > Sorry for pinging again. Is there any other suggestion with this patch set?
> > > > If there is, please let me know.
> > >
> > > Sorry I was traveling last week.  I think it's good now.
> > >
> > > Song, can I get your ack?
> >
> > He seems to be very busy.  I'll pick this up and run some tests.
> 
> Sorry for the late reply. I somehow missed the earlier email.

No worries.

> 
> I have a question and a nitpick for 1/2. Otherwise, this looks good
> to me.

Thanks for your reivew!
Namhyung