-
Notifications
You must be signed in to change notification settings - Fork 359
examples/c: add bootstrap_legacy for compatibility with older kernels #351
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
Conversation
ed28460 to
f88fabb
Compare
|
@anakryiko Please take a look, thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just one minor issue and we should be good to go. Sorry for the delay in reviewing!
examples/c/bootstrap_legacy.bpf.c
Outdated
| { | ||
| struct task_struct *task; | ||
| unsigned fname_off; | ||
| struct event *e = &(struct event){}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually unsure what exactly does this do. Will it point e to a shared piece of memory, or each function call will get it's own copy?
Let's keep it simple and have explicit:
struct event e = {};
...
e.exit_event = false;
...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I made a change to it.
examples/c/bootstrap_legacy.bpf.c
Outdated
| __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY); | ||
| __uint(key_size, sizeof(u32)); | ||
| __uint(value_size, sizeof(u32)); | ||
| } pe SEC(".maps"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: call it "perfbuf"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed it to "perf_buffer" to make it clear
examples/c/bootstrap_legacy.bpf.c
Outdated
| int handle_exit(struct trace_event_raw_sched_process_template *ctx) | ||
| { | ||
| struct task_struct *task; | ||
| struct event *e = &(struct event){}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, please keep it simple
Signed-off-by: Runlong Lin <[email protected]>
f88fabb to
ea8d284
Compare
This PR is to solve #349.
I tested in kernel 5.4 and it works good.
$ cd examples/c $ make bootstrap_legacy $ sudo ./bootstrap_legacy TIME EVENT COMM PID PPID FILENAME/EXIT CODE 10:26:32 EXEC sh 4101543 4054526 /bin/sh 10:26:32 EXEC python 4101545 4101543 /usr/bin/python 10:26:32 EXIT python 4101545 4101543 [0] (9ms) 10:26:32 EXIT sh 4101543 4054526 [0] (10ms)