Re: Configurable XDP Generic Packet Headroom to avoid SKB re-allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Til Kaiser <mail@xxxxxxxx>
Date: Wed, 18 Jun 2025 17:03:49 +0200

> Hello,
> 
> While investigating performance issues with XDP in generic mode, I
> noticed frequent SKB re-allocations due to insufficient headroom, an
> issue also discussed in earlier proposals such as [1] and [2].
> Currently, netif_receive_generic_xdp() checks against a fixed
> XDP_PACKET_HEADROOM (256 Bytes) [3].

Every more or less serious driver implements driver-side XDP and the
generic one is not performance-oriented due to being generic and how it
does work.

> 
> I would like to propose making the generic XDP headroom configurable per
> interface via a new member in struct net_device, e.g.,
> xdp_generic_headroom initialized to XDP_PACKET_HEADROOM at device
> allocation. The user can change its value via Netlink and/or sysfs
> before the XDP Generic program is attached to the interface, and
> netif_receive_generic_xdp() then uses this instead of the hardcoded
> headroom. When the XDP Generic program is detached, it is automatically
> reset to the default XDP_PACKET_HEADROOM value to avoid conflicts with
> future programs.
> 
> This would allow users to avoid unnecessary SKB re-allocations if they
> know their program’s headroom requirements in advance.
> Would this be a viable alternative? I’d be happy to prototype a patch.

What I also thought of:

1. Can we notify the drivers that the user installed an XDP prog, so
   that the driver could adjust its headroom even in case of generic
   XDP?
2. Can we maybe extract the needed headroom from the program itself in
   the verifier?

> 
> Kind regards
> Til
> 
> [1] https://patchwork.kernel.org/project/netdevbpf/
> patch/039064e87f19f93e0d0347fc8e5c692c789774e6.1647630686.git.lorenzo@xxxxxxxxxx
> [2] https://patchwork.kernel.org/project/netdevbpf/
> patch/20220314102210.92329-1-nbd@xxxxxxxx
> [3] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
> tree/net/core/dev.c?h=v6.15.2#n5279

Thanks,
Olek




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux