• Alexander Lobakin's avatar
    ice: Robustify cleaning/completing XDP Tx buffers · aa1d3faf
    Alexander Lobakin authored
    When queueing frames from a Page Pool for redirecting to a device backed
    by the ice driver, `perf top` shows heavy load on page_alloc() and
    page_frag_free(), despite that on a properly working system it must be
    fully or at least almost zero-alloc. The problem is in fact a bit deeper
    and raises from how ice cleans up completed Tx buffers.
    
    The story so far: when cleaning/freeing the resources related to
    a particular completed Tx frame (skbs, DMA mappings etc.), ice uses some
    heuristics only without setting any type explicitly (except for dummy
    Flow Director packets, which are marked via ice_tx_buf::tx_flags).
    This kinda works, but only up to some point. For example, currently ice
    assumes that each frame coming to __ice_xmit_xdp_ring(), is backed by
    either plain order-0 page or plain page frag, while it may also be
    backed by Page Pool or any other possible memory models introduced in
    future. This means any &xdp_frame must be freed properly via
    xdp_return_frame() family with no assumptions.
    
    In order to do that, the whole heuristics must be replaced with setting
    the Tx buffer/frame type explicitly, just how it's always been done via
    an enum. Let us reuse 16 bits from ::tx_flags -- 1 bit-and instr won't
    hurt much -- especially given that sometimes there was a check for
    %ICE_TX_FLAGS_DUMMY_PKT, which is now turned from a flag to an enum
    member. The rest of the changes is straightforward and most of it is
    just a conversion to rely now on the type set in &ice_tx_buf rather than
    to some secondary properties.
    For now, no functional changes intended, the change only prepares the
    ground for starting freeing XDP frames properly next step. And it must
    be done atomically/synchronously to not break stuff.
    Signed-off-by: default avatarAlexander Lobakin <alexandr.lobakin@intel.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    Acked-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
    Link: https://lore.kernel.org/bpf/20230210170618.1973430-5-alexandr.lobakin@intel.com
    aa1d3faf
ice_xsk.c 27.6 KB