GithubHelp home page GithubHelp logo

JIT stack allocation about ubpf HOT 8 CLOSED

iovisor avatar iovisor commented on July 3, 2024
JIT stack allocation

from ubpf.

Comments (8)

simon-jouet avatar simon-jouet commented on July 3, 2024 1

@xuanyue0 The code for the map relocation isn't the cleanest but I will push it on the fork I've got of ubpf so you can have a look. Regarding the map themselves, I've got two implementations for the time being, one where the kernel maps are called but in that case the prototype has to be slightly different (the data is copied back and forth user-space and kernel space, it's not the fastest ...) And a second implementation where I just brought the maps (array and hashtable) in userspace so it got nothing to do with the kernel anymore. The code will be on github at some point relatively soon, but I can't right now for some reasons

@rlane I will make a pull request for the stack fix later on today

from ubpf.

xuanyue0 avatar xuanyue0 commented on July 3, 2024

First thing is the C code I'm using (compiled to bpf with clang). I modified the loader to do the map relocation from the elf and also added both map functions to the vm.

@simon-jouet That looks like code many of us will need 😃
Would you be willing to contribute it back?

/cc @rlane

from ubpf.

rlane avatar rlane commented on July 3, 2024

Sorry I missed this before. Please send a pull request if you have a chance.

from ubpf.

xuanyue0 avatar xuanyue0 commented on July 3, 2024

The code for the map relocation isn't the cleanest but I will push it on the fork I've got of ubpf so you can have a look.

Thanks!

Regarding the map themselves, I've got two implementations for the time being, one where the kernel maps are called but in that case the prototype has to be slightly different (the data is copied back and forth user-space and kernel space, it's not the fastest ...)

You probably can't share the details but why do need kernel maps if the BPF VM is in userspace??

from ubpf.

simon-jouet avatar simon-jouet commented on July 3, 2024

You probably can't share the details but why do need kernel maps if the BPF VM is in userspace??

You don't, it was just an easy way to bring the maps in without having to recode them. The proper way to do it is the second way I did it by bringing the code in userspace but it requires slightly more dev. effort :). If you're interested I can discuss what I'm doing in private, just not here for the time being.

from ubpf.

xuanyue0 avatar xuanyue0 commented on July 3, 2024

@simon-jouet Sure, I'm xuanyue0 on freenode (I'm usually on the #github chan). You can also join me by mail.

from ubpf.

xuanyue0 avatar xuanyue0 commented on July 3, 2024

And a second implementation where I just brought the maps (array and hashtable) in userspace so it got nothing to do with the kernel anymore. The code will be on github at some point relatively soon, but I can't right now for some reasons

@simon-jouet Do you know if you will be able to publish this soon? I have implemented the map relocations and am currently finishing the implementation of the arrays. If I can avoid reimplementing the hash tables from scratch, that'd be 👍

from ubpf.

simon-jouet avatar simon-jouet commented on July 3, 2024

Hi @xuanyue0, hopefully in a month (I know it's quite a while but not much I can do about it). For the hash table implementation there isn't much point re-implementing it from scratch.

You can't really just reuse the hashtable from the kernel implementation because AFAIK the data structure is not available in userspace, but it's fairly trivial to use an existing hashtable implementation and write the few functions to deal with the lookup/insert ...

The only thing to deal with is the file descriptor, by default every kernel ebpf table is associated a file descriptor which doesn't make sense in a userspace application so you need to have some global index that points to the different instantiated tables.

from ubpf.

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.