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
Make maps implementation be cross-platform #21
Comments
In PR #15, @Alan-Jowett states:
|
Goal of this project is to only support Windows. Any code that could be generic should be moved to a more generic project and pulled in via a sub-module. |
Hi, here's the author of generic-ebpf. Let me left some comments based on my implementation experience. I’m appreciate if it can help you. |
Seems like current map implementation is using in-place spinlock to get map element. Is there any plan to move this on to RCU or EBR/QSBR implementation? Otherwide I think it will cause the use-after-free with some scenario like this.
Actually, I did exactly the same thing before. Linux eBPF program is basically assumed to be run inside the RCU critical section, so they can delay the reclamation of the memory to after all of the eBPF program finish using it. This is why the generic-ebpf kernel implementations depend on the Epoch or RCU. |
We had planned on using generic-ebpf, but the issue is that concurrency kit depends on a lot of GCC specific compiler features that aren't present in the MSVC compiler. Porting concurrencykit seems too risky. Our map implementation relies on our own version of epoch tracking:
Which then uses: ebpf-for-windows/libs/platform/ebpf_epoch.c Line 263 in c476179
Our epoch tracker works like this:
|
Description of how the epoch tracker works is here:
|
Ah, sorry I was missing that code. Thanks for your explanation! |
Do you have any plan to implement per-cpu variants of the maps? If yes, I'm interested in how you guys trying to implement it in user space (I couldn't come up with the way to implement it in preemptable environment). |
Yes, we are planning to add per-cpu variants. Our goal is to maintain parity with the libbpf API's, so we are planning to match the behavior of bpf_map_lookup_elem. Do you happen to know what bpf_map_lookup_elem does for per-CPU maps? |
Yes, in Linux, from bpf(2), it fetches all elements for each CPUs at once. What I was mentioning here is the case the eBPF program running on userspace calls the |
I think the current plan would be to have our API return the value for each CPU as well then. |
@YutaroHayakawa do you happen to have any contact with the ConcurrencyKit team? If we could get a port of CK to Windows/Visual Studio, then I think we can get closer to adopting generic-ebpf map implementation. |
Unfortunately, I don't have... |
Closing for now due to no progress or immediate way to make progress on this. |
This is to track making the core maps implementation in src/ebpf/libs/maps/ebpf_maps.c not be Windows specific, so the same code can be used on Windows, Linux, etc. This might entail upstreaming it to the generic-ebpf project for example.
The text was updated successfully, but these errors were encountered: