-
Notifications
You must be signed in to change notification settings - Fork 245
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
bpf2c and eBPF-for-Windows should support global variables in BPF programs (aka platform variables) as defined in 5.4 of BPF ISA #3958
Comments
Question: Are these global variables compile time constants? |
On Linux, the use case for this feature is to be able to modify a "compile time constant" at load time of a BPF program. For example being able to change ETH_HLEN to accomodate VLAN tagging or similar. The verifier will then inline the constant into the BPF instruction stream before JITing. This makes this essentially free in terms of performance. Roughly how it works from user space (I think this is type 0x2 in the list above):
|
More information: // Copyright (c) Prevail Verifier contributors.
// SPDX-License-Identifier: MIT
#include "bpf.h"
static volatile uint32_t global_var = 0;
static volatile uint32_t global_var_2 = 0;
int func(void* ctx) {
global_var ++;
global_var_2 += 2;
return 0;
} translated BPF byte code:
This shows that all global variables are translated into a single global map. |
As per today's brainstorming discussion in eBPF-for-Windows Office hours, the dependency of order in fixes:
This issue aims to reduce the number of map lookups (map_lookup_elem) performed by user-mode programs on the same key/value (e.g., Observability: Fields enabled or disabled to track metrics/debugs). |
The BPF ISA defines additional 64bit immediate load instructions. eBPF-for-Windows should add support for type 3 at a minimum. This support can improve the performance of certain BPF programs by eliminating the need to perform map lookups.
The text was updated successfully, but these errors were encountered: