Skip to content

Map type BPF_MAP_TYPE_PERCPU_ARRAY

v4.6

This is the per-CPU variant of the BPF_MAP_TYPE_ARRAY map type.

This map type is a generic map type with no restrictions on the structure of the value. However the key is a numeric index between 0 and max_entries

This per-CPU version has a separate array for each logical CPU. When accessing the map using most helper function, the array assigned to the CPU the eBPF program is currently running on is accessed implicitly.

Since preemption is disabled during program execution, no other programs will be able to concurrently access the same memory. This guarantees there will never be any race conditions and improves the performance due to the lack of congestion and synchronization logic, at the cost of having a large memory footprint.

Attributes

While the value_size is essentially unrestricted, the key_size must always be 4 indicating the key is a 32-bit unsigned integer.

Syscall commands

The following syscall commands work with this map type:

Helper functions

The following helper functions work with this map type:

Flags

The following flags are supported by this map type.

BPF_F_RDONLY

v4.15

Setting this flag will make it so the map can only be read via the syscall interface, but not written to.

For details please check the generic description.

BPF_F_WRONLY

v4.15

Setting this flag will make it so the map can only be written to via the syscall interface, but not read from.

BPF_F_RDONLY_PROG

v5.2

Setting this flag will make it so the map can only be read via helper functions, but not written to.

For details please check the generic description.

BPF_F_WRONLY_PROG

v5.2

Setting this flag will make it so the map can only be written to via helper functions, but not read from.

For details please check the generic description.