• Jesper Dangaard Brouer's avatar
    bpf: cpumap do bulk allocation of SKBs · 8f0504a9
    Jesper Dangaard Brouer authored
    As cpumap now batch consume xdp_frame's from the ptr_ring, it knows how many
    SKBs it need to allocate. Thus, lets bulk allocate these SKBs via
    kmem_cache_alloc_bulk() API, and use the previously introduced function
    build_skb_around().
    
    Notice that the flag __GFP_ZERO asks the slab/slub allocator to clear the
    memory for us. This does clear a larger area than needed, but my micro
    benchmarks on Intel CPUs show that this is slightly faster due to being a
    cacheline aligned area is cleared for the SKBs. (For SLUB allocator, there
    is a future optimization potential, because SKBs will with high probability
    originate from same page. If we can find/identify continuous memory areas
    then the Intel CPU memset rep stos will have a real performance gain.)
    Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
    Acked-by: default avatarSong Liu <songliubraving@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    8f0504a9
cpumap.c 19.4 KB