-
Notifications
You must be signed in to change notification settings - Fork 249
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
Closing the last program fd will detach a link #4135
Comments
There is an additional wrinkle here that I just discovered:
If userspace doesnt hold on to prog2 and prog3 somehow the entries are removed from the map and the tail call fails. The semantics on Linux are that holding on to a prog_array will keep the refcount on programs alive. Losing the last user refcount on the prog_array triggers dropping the refcount on prog2 and prog3. To put it another way, you need to hold on to prog1 and prog_array in user space (or via pinning) for things to work. Not sure we want to replicate this 100% but user space shouldn't have to hold onto prog2 and prog3 imo. |
So, we had this design earlier where prog_array map takes a reference on the program object when the prog is inserted in the prog array map, but that causes issue of circular references. Hence the design was changed later to have "weak references" from prog_array_map --> prog. Example of circular reference: Can you confirm once if Linux also has the issue of circular references? |
@saxena-anurag Linux has the same issue, but chose to fix it differently. For program arrays, user references and kernel references are tracked individually. Once the last uref goes away the map is cleared. Details are in the commit message: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c9da161c6517ba12154059d3b965c2cbaf16f90f |
Just to confirm -- so the user app needs to either keep the FD to the prog array map open or pin the prog array map? |
Describe the bug
Closing the last reference to a program acts like an implicit link detach. See
ebpf-for-windows/tests/end_to_end/end_to_end.cpp
Lines 1547 to 1551 in 13cadc6
This is the opposite of what happens on Linux: a live link (pinned or otherwise) will keep the program alive until either the last reference is closed or the link is explicitly detached.
According to @saxena-anurag the ownership in the runtime is currently from program to link, while it should probably be the link holding on to a refcount on the program.
OS information
No response
Steps taken to reproduce bug
Expected behavior
The attachment should persist until the link is closed / detached / unpinned.
Actual outcome
The attachment is torn down.
Additional details
No response
The text was updated successfully, but these errors were encountered: