libbpf-rs: Addressed API code review#1
Conversation
|
cc @anakryiko . One thing I'm wondering is if we want an Not sure if that would be necessary for |
| unimplemented!(); | ||
| } | ||
|
|
||
| pub fn poll(&mut self, _timeout: Duration) { |
There was a problem hiding this comment.
can fail, also doesn't need mutable reference, probably
There was a problem hiding this comment.
If callbacks receive a mutable ref to PerfBuffer, I think it makes sense to keep this as mutable.
There was a problem hiding this comment.
do callbacks need mutable reference? what for?
There was a problem hiding this comment.
Do we need a reference back to the PerfBuffer at all? We don't currently have any properties that can really be changed after construction.
If we wanna add it later we can easily add a poll_mut() or poll_ref() method. But TBH I can't see a use case.
There was a problem hiding this comment.
yeah, I don't have specific use case to have any kind of references, but it's usually a good idea to have reference to an "object" that's calling a callback function. E.g., just in case someone has multiple PerfBuffers, but the same callback. Having reference to PerfBuffer would allow to differentiate between them, if necessary.
But I think we are talking about different things here. PerfBuffer::poll needs &self -- I don't think PerfBuffer needs to be modified as a result of poll operation. What I was describing above is what should be passed to user-provided callback. There, I think, having PerfBuffer reference is useful.
I think unloading unconditionally. Map and Program are owned by Object, they can't leave outside of Object. libbpf doesn't do anything special here, when object is closed/destroyed, all map and program FDs are closed (see bpf_object__unload()). If map is referenced from some other program, it will be kept around by kernel.
|
Ok. We can make |
|
I'm gonna merge this and start implementing everything. Feel free to leave more comments on here if you see anything later. I'll put up a PR for the implementation as well. |
|
@danobi, sounds good, I think currently it looks good. You'll probably find some inconsistencies or missing things along the way, but nothing is set in stone and we can adjust and revisit as needed. Thanks for working on this! |
See: libbpf/libbpf-sys#64 The "static" feature will now get libbpf-sys to do all the static compilation of the libraries required by libbpf rather than the application developer statically compiling these libraries themselves, or relying on the distribution to provide static versions. The default feature will no longer link libbpf statically. All libbpf libraries, including libbpf, will now be dynamically linked to distribution provided shared libraries CHANGELOG NOTE libbpf#1: feature "static" allows libelf and zlib to be statically linked. Completely static binaries can now be compiled via the command `RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-unknown-linux-gnu`. CHANGELOG NOTE libbpf#2: "static" feature will not work with musl. Signed-off-by: Michael Mullin <mmullin@halcyon.ai>
See: libbpf/libbpf-sys#64 The "static" feature will now get libbpf-sys to do all the static compilation of the libraries required by libbpf rather than the application developer statically compiling these libraries themselves, or relying on the distribution to provide static versions. The default feature will no longer link libbpf statically. All libbpf libraries, including libbpf, will now be dynamically linked to distribution provided shared libraries CHANGELOG NOTE libbpf#1: feature "static" allows libelf and zlib to be statically linked. Completely static binaries can now be compiled via the command `RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-unknown-linux-gnu`. CHANGELOG NOTE libbpf#2: "static" feature will not work with musl. Signed-off-by: Michael Mullin <mmullin@halcyon.ai>
All items in the "High level workflow" are labeled #1. While they appear correct in the rendered documentation, it is confusing when reading the source code. Number them correctly. Signed-off-by: Daniel Müller <deso@posteo.net>
No description provided.