summary refs log tree commit diff
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorAlexander Lobakin <alobakin@pm.me>2021-02-18 20:50:31 +0000
committerDaniel Borkmann <daniel@iogearbox.net>2021-02-25 00:56:34 +0100
commit3914d88f7608e6c2e80e344474fa289370c32451 (patch)
treee7d6818896d0d6b633c2e72ec2108e46df4c79d1 /kernel/fork.c
parentab5bd583b9289666e918f9e5f672d33ccdfd49b2 (diff)
downloadlinux-3914d88f7608e6c2e80e344474fa289370c32451.tar.gz
xsk: Respect device's headroom and tailroom on generic xmit path
xsk_generic_xmit() allocates a new skb and then queues it for
xmitting. The size of new skb's headroom is desc->len, so it comes
to the driver/device with no reserved headroom and/or tailroom.
Lots of drivers need some headroom (and sometimes tailroom) to
prepend (and/or append) some headers or data, e.g. CPU tags,
device-specific headers/descriptors (LSO, TLS etc.), and if case
of no available space skb_cow_head() will reallocate the skb.
Reallocations are unwanted on fast-path, especially when it comes
to XDP, so generic XSK xmit should reserve the spaces declared in
dev->needed_headroom and dev->needed tailroom to avoid them.

Note on max(NET_SKB_PAD, L1_CACHE_ALIGN(dev->needed_headroom)):

Usually, output functions reserve LL_RESERVED_SPACE(dev), which
consists of dev->hard_header_len + dev->needed_headroom, aligned
by 16.

However, on XSK xmit hard header is already here in the chunk, so
hard_header_len is not needed. But it'd still be better to align
data up to cacheline, while reserving no less than driver requests
for headroom. NET_SKB_PAD here is to double-insure there will be
no reallocations even when the driver advertises no needed_headroom,
but in fact need it (not so rare case).

Fixes: 35fcde7f8deb ("xsk: support for Tx")
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20210218204908.5455-5-alobakin@pm.me
Diffstat (limited to 'kernel/fork.c')
0 files changed, 0 insertions, 0 deletions