Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tetra: Add debug progs command #2967

Merged
merged 3 commits into from
Oct 11, 2024
Merged

tetra: Add debug progs command #2967

merged 3 commits into from
Oct 11, 2024

Conversation

olsajiri
Copy link
Contributor

@olsajiri olsajiri commented Oct 1, 2024

Adding tetra debug progs command that enables bpf program stats and collects them for running programs.

The deault output looks like:

  # tetra debug progs
  2024-10-01 11:42:28.181107151 +0000 UTC m=+5.061137969

  Ovh(%)  Id      Cnt     Time            Name            Pin
   22.17  5614    647635  886904962       generic_tracepo raw-syscalls/generic_tracepoint/raw_syscalls:sys_enter/prog
    0.00  5606    1       8047            event_execve    __base__/event_execve/prog
    0.00  5603    1       5910            event_wake_up_n __base__/kprobe_pid_clear/prog
    0.00  5609    1       5255            tg_kp_bprm_comm __base__/tg_kp_bprm_committing_creds/prog
    0.00  5601    1       3185            event_exit_acct __base__/event_exit/prog

It provides several options to control timeout and repetition, all should be described in help.

TODO will add a way to dump full bpf program name

@olsajiri olsajiri added the release-note/minor This PR introduces a minor user-visible change label Oct 1, 2024
@olsajiri olsajiri force-pushed the pr/olsajiri/overhead branch 4 times, most recently from 56a83c1 to f15f209 Compare October 6, 2024 20:04
Copy link

netlify bot commented Oct 6, 2024

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit d2ad1a2
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/6706abd33502a0000817bd2f
😎 Deploy Preview https://deploy-preview-2967--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@olsajiri olsajiri force-pushed the pr/olsajiri/overhead branch 2 times, most recently from da37531 to f0033f9 Compare October 6, 2024 22:00
@olsajiri olsajiri force-pushed the pr/olsajiri/overhead branch 10 times, most recently from 55bef1e to 370530f Compare October 8, 2024 15:07
@olsajiri olsajiri marked this pull request as ready for review October 8, 2024 15:08
@olsajiri olsajiri requested review from mtardy and a team as code owners October 8, 2024 15:08
@olsajiri olsajiri force-pushed the pr/olsajiri/overhead branch 2 times, most recently from 8ecdf5f to d2ad1a2 Compare October 9, 2024 16:14
Copy link
Contributor

@lambdanis lambdanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left two comments about the details, but looks good and very useful, thanks!

flags.BoolVar(&cfg.all, "all", false, "Get all programs")
flags.StringVar(&cfg.lib, "bpf-lib", "bpf/objs/", "Location of Tetragon libs (btf and bpf files)")
flags.StringVar(&cfg.bpffs, "bpf-dir", "/sys/fs/bpf/tetragon", "Location of bpffs tetragon directory")
flags.IntVar(&cfg.timeout, "timeout", 1, "Run in one shot mode with argument of the delay in sec")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
flags.IntVar(&cfg.timeout, "timeout", 1, "Run in one shot mode with argument of the delay in sec")
flags.IntVar(&cfg.timeout, "timeout", 1, "Interval in seconds (delay in one shot mode)")

nit, the help text sounds like it automatically enabled the one shot mode

cmd/tetra/debug/progs.go Show resolved Hide resolved
@olsajiri olsajiri force-pushed the pr/olsajiri/overhead branch 4 times, most recently from 607516b to 1754996 Compare October 11, 2024 10:59
Adding tetra debug progs command that enables bpf program stats
and collects them for running programs.

The deault output looks like:

  # ./tetra debug progs --once
  2024-10-05 20:59:26.75755952 +0000 UTC m=+1.037895215

  Ovh(%)  Id      Cnt     Time    Name                            Pin
    0.00  1934    0       0       event_execve                    /sys/fs/bpf/tetragon/__base__/event_execve/prog
    0.00  1929    0       0       event_exit_acct_process         /sys/fs/bpf/tetragon/__base__/event_exit/prog
    0.00  1931    0       0       event_wake_up_new_task          /sys/fs/bpf/tetragon/__base__/kprobe_pid_clear/prog
    0.00  1937    0       0       tg_kp_bprm_committing_creds     /sys/fs/bpf/tetragon/__base__/tg_kp_bprm_committing_creds/prog

It provides several options to control timeout and repetition,
all should be described in help.

Signed-off-by: Jiri Olsa <[email protected]>
We need proper attach string or uprobe programs because they will
be part of overhead metrics.

Storing attach for standard uprobe, like:
  Attach="/home/jolsa/tetragon/contrib/tester-progs/nop main"

and uprobe multi, like:
  Attach="uprobe_multi (1 functions)"

Signed-off-by: Jiri Olsa <[email protected]>
We need that for proper overhead metrics.

Signed-off-by: Jiri Olsa <[email protected]>
@olsajiri
Copy link
Contributor Author

ugh, forgot to push the bpf prog iter bits, it's there now, sorry @lambdanis

Copy link
Contributor

@lambdanis lambdanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works on my machine, thanks

@olsajiri olsajiri merged commit 21cb4fd into main Oct 11, 2024
44 checks passed
@olsajiri olsajiri deleted the pr/olsajiri/overhead branch October 11, 2024 16:35
@olsajiri olsajiri restored the pr/olsajiri/overhead branch October 11, 2024 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/minor This PR introduces a minor user-visible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants