-
Notifications
You must be signed in to change notification settings - Fork 3
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
[RFC] Get values from per-cpu maps #2
base: master
Are you sure you want to change the base?
Conversation
Useful for per-cpu maps lookup implementation.
Convert tabs to spaces.
Hi! As you see there's no per-cpu support yet, I think the way to go about it would be:
the rationale for this is that right now |
@@ -315,6 +316,11 @@ Napi::Value BpfObjGet(const CallbackInfo& info) { | |||
return ToStatus(env, bpf_obj_get(path.c_str())); | |||
} | |||
|
|||
Napi::Value GetNumPossibleCPUs(const CallbackInfo& info) { | |||
Napi::Env env = info.Env(); | |||
return ToStatus(env, libbpf_num_possible_cpus()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can't use ToStatus here, the function returns the error code directly (not through errno)
Thanks, that sounds like a great plan! Unfortunately, I have to focus on some other stuff, so let me just put this on my weekend project list. |
The node_bpf packages has no support for per-cpu bpf maps yet. As a quick workaround we stick to non percpu-maps. See mildsunrise/node_bpf#2 for details.
The node_bpf packages has no support for per-cpu bpf maps yet. As a quick workaround we stick to non percpu-maps. See mildsunrise/node_bpf#2 for details.
Per-cpu maps are special, they store multiple values to a single key; a value for each CPU core. The
bpf_map_lookup_elem()
returns all these values. But when I call aget()
on a RawMap, it returns a single value only since it allocates a buffer which is as long as the map's value size. To handle per-cpu maps, I propose a newgetPerCPU()
function which returns a buffer containing all values. wdyt?