Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

veth: try harder when allocating queue memory

struct veth_rq is pretty large, 832B total without debug
options enabled. Since commit under Fixes we try to pre-allocate
enough queues for every possible CPU. Miao Wang reports that
this may lead to order-5 allocations which will fail in production.

Let the allocation fallback to vmalloc() and try harder.
These are the same flags we pass to netdev queue allocation.

Reported-and-tested-by: Miao Wang <shankerwangmiao@gmail.com>
Fixes: 9d3684c24a52 ("veth: create by default nr_possible_cpus queues")
Link: https://lore.kernel.org/all/5F52CAE2-2FB7-4712-95F1-3312FBBFA8DD@gmail.com/
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20240223235908.693010-1-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Jakub Kicinski and committed by
Paolo Abeni
1ce7d306 237274fa

+3 -2
+3 -2
drivers/net/veth.c
··· 1461 1461 struct veth_priv *priv = netdev_priv(dev); 1462 1462 int i; 1463 1463 1464 - priv->rq = kcalloc(dev->num_rx_queues, sizeof(*priv->rq), GFP_KERNEL_ACCOUNT); 1464 + priv->rq = kvcalloc(dev->num_rx_queues, sizeof(*priv->rq), 1465 + GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL); 1465 1466 if (!priv->rq) 1466 1467 return -ENOMEM; 1467 1468 ··· 1478 1477 { 1479 1478 struct veth_priv *priv = netdev_priv(dev); 1480 1479 1481 - kfree(priv->rq); 1480 + kvfree(priv->rq); 1482 1481 } 1483 1482 1484 1483 static int veth_dev_init(struct net_device *dev)