Skip to content

Commit 1ce7d30

Browse files
kuba-mooPaolo Abeni
authored andcommitted
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 <[email protected]> Fixes: 9d3684c ("veth: create by default nr_possible_cpus queues") Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 237274f commit 1ce7d30

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/net/veth.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,8 @@ static int veth_alloc_queues(struct net_device *dev)
14611461
struct veth_priv *priv = netdev_priv(dev);
14621462
int i;
14631463

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);
14651466
if (!priv->rq)
14661467
return -ENOMEM;
14671468

@@ -1477,7 +1478,7 @@ static void veth_free_queues(struct net_device *dev)
14771478
{
14781479
struct veth_priv *priv = netdev_priv(dev);
14791480

1480-
kfree(priv->rq);
1481+
kvfree(priv->rq);
14811482
}
14821483

14831484
static int veth_dev_init(struct net_device *dev)

0 commit comments

Comments
 (0)