From: Junyeong Jeong <esrse.jeong@gmail.com>
To: kernelnewbies@kernelnewbies.org
Subject: How to make BPF program which is attached to kprobe keep working after process exits?
Date: Sat, 15 May 2021 15:55:53 +0900 [thread overview]
Message-ID: <874kf44h40.fsf@gmail.com> (raw)
Hello :)
My BPF program is loaded by `bpf_load_program_xattr` of `libbpf` and
then attached to kprobe event using `perf_event_open`,
`ioctl(PERF_EVENT_IOC_SET_BPF)` and `ioctl(PERF_EVENT_IOC_ENABLE)`.
Then the BPF program is working as I expected.
And I wanted to make the BPF program keep working even though the
userspace process exits. So I pinned it using `bpf_obj_pin()`.
But unfortunately the BPF program is never called after the userspace
process exits.
I discovered the cause of the failure. The file descriptor of perf event
is automatically closed when userspace process exits so objects related
to perf event get destroyed.
So I tried to find how to pin the fd of perf event, but I got to know
that only BPF programs, BPF maps and BPF links are subject to pin.
How can I make my BPF program which is attached to kprobe keep working
after userspace process exits?
regards,
Junyeong
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
reply other threads:[~2021-05-15 7:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874kf44h40.fsf@gmail.com \
--to=esrse.jeong@gmail.com \
--cc=kernelnewbies@kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.