Giter Site home page Giter Site logo

Comments (14)

Alan-Jowett avatar Alan-Jowett commented on September 28, 2024 1

I think the current plan would be to have our API return the value for each CPU as well then.

from ebpf-for-windows.

dthaler avatar dthaler commented on September 28, 2024

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.

Alan-Jowett avatar Alan-Jowett commented on September 28, 2024

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.

YutaroHayakawa avatar YutaroHayakawa commented on September 28, 2024

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.

YutaroHayakawa avatar YutaroHayakawa commented on September 28, 2024

Seems like current map implementation is using in-place spinlock to get map element.

https://github.com/microsoft/ebpf-for-windows/blame/2b2ea62deee534ecee1bcf2a72bdc6b5964f681f/libs/execution_context/ebpf_maps.c#L251-L255

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.

Alan-Jowett avatar Alan-Jowett commented on September 28, 2024

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:

retval = ebpf_hash_table_create(

Which then uses:

ebpf_epoch_free(void* memory)

Our epoch tracker works like this:

  1. Every thread and/or CPU captures the epoch it's executing in.
  2. On free, memory is tagged with the epoch it was freed in.
  3. Memory is released back to the system when there are no more threads or CPU's on that epoch.

from ebpf-for-windows.

Alan-Jowett avatar Alan-Jowett commented on September 28, 2024

Description of how the epoch tracker works is here:

// Brief summary of how epoch tracking works.

from ebpf-for-windows.

YutaroHayakawa avatar YutaroHayakawa commented on September 28, 2024

Ah, sorry I was missing that code. Thanks for your explanation!

from ebpf-for-windows.

YutaroHayakawa avatar YutaroHayakawa commented on September 28, 2024

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.

Alan-Jowett avatar Alan-Jowett commented on September 28, 2024

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.

YutaroHayakawa avatar YutaroHayakawa commented on September 28, 2024

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.

Alan-Jowett avatar Alan-Jowett commented on September 28, 2024

@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.

YutaroHayakawa avatar YutaroHayakawa commented on September 28, 2024

Unfortunately, I don't have...

from ebpf-for-windows.

dthaler avatar dthaler commented on September 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.