Skip to content

Map type BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE

v4.20

This is a specialized map, the per-CPU variant of BPF_MAP_TYPE_CGROUP_STORAGE. This map type stores data keyed on a cGroup. The user can't create or delete entries in this map directly, only read and update keys for existing cGroups. When a cGroup is deleted, all entries for that cGroup are automatically removed.

This map type can only be used with BPF_PROG_TYPE_CGROUP_* program types. Upon attaching a BPF program with a cGroup storage map, the cGroup becomes associated with that map. Userspace can only read or set values for cGroups associated with the map. BPF programs can use the bpf_get_local_storage helper function to access the map value for the cGroup the program is attached to. Due to these limitations, this map type has been deprecated in favor of the BPF_MAP_TYPE_CGRP_STORAGE map type.

Attributes

The key_size must be 12 bytes and has the following type:

struct bpf_cgroup_storage_key {
        __u64 cgroup_inode_id;
        __u32 attach_type;
};
After v5.9 the key_size may also be 8 bytes, which will be interpreted as just the cgroup_inode_id.

The value_size of the map may be any size within the limits of the kernel. max_entries must be 0, as the number of entries is determined by the number of cgroups on the system.

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_NUMA_NODE

v4.14

When set, the numa_node attribute is respected during map creation.

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.