map: automatically set CPUMap MaxEntries based on possible CPUs#1627
map: automatically set CPUMap MaxEntries based on possible CPUs#1627ti-mo merged 1 commit intocilium:mainfrom
Conversation
e53f445 to
1ffca47
Compare
There was a problem hiding this comment.
Only the PossibleCPU() changes, please.
The key/val change doesn't make much sense IMO.
-
Changing the key or value size without the knowledge of the bpf program will result in the program potentially reading past the end of the value on kernels where the value is 4 bytes, resulting in a verifier error. In order to remain portable, an application (the Cilium agent, in this case) needs to target the lowest common denominator of any given feature. When support for older kernels is dropped, the 8-byte value can be used (should be fine for Cilium since we target 5.4+), unless the program is compiled specifically for the running kernel (which we're trying to get rid of in Cilium).
-
Kernel versions are meaningless in bpf land; vendors (mostly RH) backport tons of features to older kernels, while disabling others for security reasons. Reacting to the availability of certain features must be done using probes, e.g. in this case by trying to create a map of a particular size. Tests are the only exception, since we use only mainline kernels and need some way of defining when a test needs to pass and when it can be skipped.
Also, for our purposes, a simple map creation test will do with a check on Map.MaxEntries(). Don't overthink it. 😉
408e89a to
033b2d8
Compare
|
Done deal @ti-mo, thanks for the explanation! |
033b2d8 to
37d4da2
Compare
This commit automatically populates a CPUMap's MaxEntries with the amount of possible CPUs on the machine. This keeps code portable across different hosts. Signed-off-by: Ryan Drew <[email protected]>
37d4da2 to
a3d4835
Compare
This commit modifies the
MapSpec.fixupMagicFieldsmethod to support the following for the CPU map:This enables to write more portable code when utilizing the CPU map, since kernel-specific and node-specific arguments no longer have to be supplied at compile-time.