]> git.itanic.dy.fi Git - linux-stable/commitdiff
veth: try harder when allocating queue memory
authorJakub Kicinski <kuba@kernel.org>
Fri, 23 Feb 2024 23:59:08 +0000 (15:59 -0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 27 Feb 2024 12:56:54 +0000 (13:56 +0100)
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>
drivers/net/veth.c

index a786be805709c1c78c4047c4fc9f23a05882cfcb..cd4a6fe458f95d7bbc3c468ae8585d06cf0ac097 100644 (file)
@@ -1461,7 +1461,8 @@ static int veth_alloc_queues(struct net_device *dev)
        struct veth_priv *priv = netdev_priv(dev);
        int i;
 
-       priv->rq = kcalloc(dev->num_rx_queues, sizeof(*priv->rq), GFP_KERNEL_ACCOUNT);
+       priv->rq = kvcalloc(dev->num_rx_queues, sizeof(*priv->rq),
+                           GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL);
        if (!priv->rq)
                return -ENOMEM;
 
@@ -1477,7 +1478,7 @@ static void veth_free_queues(struct net_device *dev)
 {
        struct veth_priv *priv = netdev_priv(dev);
 
-       kfree(priv->rq);
+       kvfree(priv->rq);
 }
 
 static int veth_dev_init(struct net_device *dev)