• Maciej Fijalkowski's avatar
    ice: work on pre-XDP prog frag count · ad2047cf
    Maciej Fijalkowski authored
    Fix an OOM panic in XDP_DRV mode when a XDP program shrinks a
    multi-buffer packet by 4k bytes and then redirects it to an AF_XDP
    socket.
    
    Since support for handling multi-buffer frames was added to XDP, usage
    of bpf_xdp_adjust_tail() helper within XDP program can free the page
    that given fragment occupies and in turn decrease the fragment count
    within skb_shared_info that is embedded in xdp_buff struct. In current
    ice driver codebase, it can become problematic when page recycling logic
    decides not to reuse the page. In such case, __page_frag_cache_drain()
    is used with ice_rx_buf::pagecnt_bias that was not adjusted after
    refcount of page was changed by XDP prog which in turn does not drain
    the refcount to 0 and page is never freed.
    
    To address this, let us store the count of frags before the XDP program
    was executed on Rx ring struct. This will be used to compare with
    current frag count from skb_shared_info embedded in xdp_buff. A smaller
    value in the latter indicates that XDP prog freed frag(s). Then, for
    given delta decrement pagecnt_bias for XDP_DROP verdict.
    
    While at it, let us also handle the EOP frag within
    ice_set_rx_bufs_act() to make our life easier, so all of the adjustments
    needed to be applied against freed frags are performed in the single
    place.
    
    Fixes: 2fba7dc5 ("ice: Add support for XDP multi-buffer on Rx side")
    Acked-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
    Signed-off-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
    Link: https://lore.kernel.org/r/20240124191602.566724-5-maciej.fijalkowski@intel.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    ad2047cf
ice_txrx.h 14.5 KB