Skip to content

Conversation

@linrl3
Copy link
Contributor

@linrl3 linrl3 commented Oct 5, 2025

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)

@linrl3 linrl3 force-pushed the bootstrap-legacy branch 4 times, most recently from ed28460 to f88fabb Compare October 5, 2025 03:36
@linrl3
Copy link
Contributor Author

linrl3 commented Oct 7, 2025

@anakryiko Please take a look, thanks.

Copy link
Member

@anakryiko anakryiko left a 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!

{
struct task_struct *task;
unsigned fname_off;
struct event *e = &(struct event){};
Copy link
Member

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;
...

?

Copy link
Contributor Author

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.

__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
__uint(key_size, sizeof(u32));
__uint(value_size, sizeof(u32));
} pe SEC(".maps");
Copy link
Member

Choose a reason for hiding this comment

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

nit: call it "perfbuf"?

Copy link
Contributor Author

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

int handle_exit(struct trace_event_raw_sched_process_template *ctx)
{
struct task_struct *task;
struct event *e = &(struct event){};
Copy link
Member

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

@linrl3 linrl3 requested a review from anakryiko October 13, 2025 23:56
@anakryiko anakryiko merged commit 5b747b7 into libbpf:master Oct 14, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants