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

Allow unsetting program log buffer after object loading #750

Open
tgnottingham opened this issue Nov 16, 2023 · 2 comments
Open

Allow unsetting program log buffer after object loading #750

tgnottingham opened this issue Nov 16, 2023 · 2 comments

Comments

@tgnottingham
Copy link

I'd like to be able to free the memory allocated for program log buffers after loading an object. I assume that's safe to do, but I noticed that bpf_program__set_log_buf returns -EBUSY if the object has been loaded, which makes me wonder if it's safe to free the buffers after all.

At what point is it safe to free these buffers? What's the reason bpf_program__set_log_buf doesn't allow setting the log buffer after the object has been loaded? Would it be possible to allow setting the buffer to null to give some reasonable assurance that libbpf isn't holding onto a pointer to the log buffer, so that I can free it?

@anakryiko
Copy link
Member

It should be safe to free the buffer, libbpf doesn't use this buffer after BPF object is loaded. But it's probably also good to improve bpf_program__set_log_buf() to allow to set buffer to NULL even after bpf_object is loaded. Do you care to submit patch upstream to kernel mailing list?

@tgnottingham
Copy link
Author

Sure, will do. Thanks!

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

No branches or pull requests

2 participants