Skip to content



The CPU map is a specialized map type that holds references to logical CPUs.


This map type can be used to redirect incoming packets to a different logical CPU. To do so, this map is used in combination with the bpf_redirect_map helper function.

This feature can for example be used to implement a form of Receive Side Scaling (RSS). This might be especially useful when dealing with network protocols for which Network Interface Cards, network drivers and/or the kernel have sub-optimal support.

Another theoretical example might be a multi tenancy situation where a set of logical CPUs is dedicated to a tenant. By redirecting traffic to its CPUs at the XDP level, the system can ensure heavy network load for one tenant does not impact others on the same system.

When packets are redirected, they are placed on a queue associated with each logical CPU. Initially the value of this map was just a single __u32 representing the size of this queue. Writing a value of 0 disables that kv pair. The maximum queue size is 16384.

After v5.9, it becomes possible to add a secondary XDP program to the map entry which will be executed on the redirected packet on the new CPU. The new C structure of the map value look like this:

struct bpf_cpumap_val {
    __u32 qsize;    /* queue size to remote target CPU */
    union {
        int   fd;   /* prog fd on map write */
        __u32 id;   /* prog id on map read */
    } bpf_prog;


Only programs which have been loaded with the BPF_XDP_CPUMAP expected attach type can be added to the fd/id.


The value_size can be 4 or 8 depending on kernel version and optional secondary program support. The key_size must always be 4. The max_entries must be smaller or equal to the amount of logical CPUs on the host.

Syscall commands

The following syscall commands work with this map type:

Helper functions




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