Skip to content

Commit

Permalink
net/packet: change packet_alloc_skb() to allow bigger paged allocations
Browse files Browse the repository at this point in the history
packet_alloc_skb() is currently calling sock_alloc_send_pskb()
forcing order-0 page allocations.

Switch to PAGE_ALLOC_COSTLY_ORDER, to increase max size by 8x.

Also add logic to increase the linear part if needed.

Signed-off-by: Eric Dumazet <[email protected]>
Cc: Tahsin Erdogan <[email protected]>
Reviewed-by: Willem de Bruijn <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Eric Dumazet authored and kuba-moo committed Aug 3, 2023
1 parent ce7c7fe commit ae6db08
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -2927,8 +2927,10 @@ static struct sk_buff *packet_alloc_skb(struct sock *sk, size_t prepad,
if (prepad + len < PAGE_SIZE || !linear)
linear = len;

if (len - linear > MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER))
linear = len - MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER);
skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
err, 0);
err, PAGE_ALLOC_COSTLY_ORDER);
if (!skb)
return NULL;

Expand Down

0 comments on commit ae6db08

Please sign in to comment.