Comments (14)
I think the current plan would be to have our API return the value for each CPU as well then.
from ebpf-for-windows.
In PR #15, @Alan-Jowett states:
Long term goal would be to switch to using generic-ebpf library, but due to generic-ebpf dependency on concurrency kit (which only builds with GCC), we can't use generic-ebpf yet.
from ebpf-for-windows.
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.
from ebpf-for-windows.
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.
from ebpf-for-windows.
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.
// In eBPF program
elem = bpf_map_lookup_elem(&k); // hash map
// User space program or other eBPF program deletes the element in here
elem->counter++; // use after free
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.
from ebpf-for-windows.
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:
- Every thread and/or CPU captures the epoch it's executing in.
- On free, memory is tagged with the epoch it was freed in.
- Memory is released back to the system when there are no more threads or CPU's on that epoch.
from ebpf-for-windows.
Description of how the epoch tracker works is here:
from ebpf-for-windows.
Ah, sorry I was missing that code. Thanks for your explanation!
from ebpf-for-windows.
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).
from ebpf-for-windows.
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?
from ebpf-for-windows.
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 bpf_map_lookup_elem
helper. Maybe it is out of the scope of this project?
from ebpf-for-windows.
@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.
from ebpf-for-windows.
Unfortunately, I don't have...
from ebpf-for-windows.
Closing for now due to no progress or immediate way to make progress on this.
Fine to reopen if/when a possible way forward is known.
from ebpf-for-windows.
Related Issues (20)
- Set errno for bpf_object__find_map_by_name API HOT 1
- need unit tests for program data validation
- Workflow failed - user_mode_multi_threaded_stress HOT 7
- Add support for string helper functions HOT 1
- ioctl: allow common operations without allocations HOT 1
- bpf2c.exe doesn't do conversion with absolute paths
- Workflow failed - km_mt_stress_tests HOT 2
- Make `bpf()` wrapper ABI compatible with Linux HOT 9
- Add test to validate older native module (< 0.18) does not get loaded if the extension requires implicit context.
- XDP header declarations belong in XDP-for-Windows repo, not eBPF-for-Windows HOT 3
- Pinning semantics are different than on Linux HOT 1
- Scheduled eBPF release is due HOT 2
- sock_ops extension must override bpf_get_pid_tgid helper function
- bpf object load - NMR Attach failing with attach guid all zeroes HOT 2
- bpf() shim don't follow upstream error conventions HOT 1
- Group dependabot requests
- `setup-ebpf.ps1 -Uninstall` fails after recompilation HOT 1
- eBPF external extensions missing extensions HOT 1
- Print compartment ID in `connect_redirect` hook traces
- ebpf_epoch_initiate fails on systems with KeQueryMaximumProcessorCountEx > KeQueryActiveProcessorCountEx HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ebpf-for-windows.