From: Jakub Kicinski <kuba@kernel.org>
To: Miao Wang <shankerwangmiao@gmail.com>
Cc: netdev@vger.kernel.org, pabeni@redhat.com,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [Bug report] veth cannot be created, reporting page allocation failure
Date: Wed, 21 Feb 2024 16:49:42 -0800 [thread overview]
Message-ID: <20240221164942.5af086c5@kernel.org> (raw)
In-Reply-To: <5F52CAE2-2FB7-4712-95F1-3312FBBFA8DD@gmail.com>
On Tue, 20 Feb 2024 22:38:52 +0800 Miao Wang wrote:
> I tried to bisect the kernel to find the commit that introduced the problem, but
> it would take too long to carry out the tests. However, after 4 rounds of
> bisecting, by examining the remaining commits, I'm convinced that the problem is
> caused by the following commit:
>
> 9d3684c24a5232 ("veth: create by default nr_possible_cpus queues")
>
> where changes are made to the veth module to create queues for all possbile
> cpus when not providing expected number of queues by the userland. The previous
> behavior was to create only one queue in the same condition. The memory in need
> will be large when the number of cpus is large, which is 96 * 768 = 72KB or 18
> continuous 4K pages in total, no wonder causing the allocation failure. I guess
> on certain platforms, the number of possbile cpus might be even larger, and
> larger than actual cpu cores physically installed, for several people in the
> above discussion mentioned that manually specifing nr_cpus in the boot command
> line can work around the problem.
>
> I've carried out a cross check by applying the commit on the working 5.10
> kernel, and the problem occurs. Then I reverted the commit on the 6.1 kernel,
> the problem has not occured for 27 hours.
Thank you for the very detailed report! Would you be willing to give
this patch a try and report back if it fixes the problem for you?
It won't help with the memory waste but should make the allocation
failures less likely:
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index a786be805709..cd4a6fe458f9 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -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)
next prev parent reply other threads:[~2024-02-22 0:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-20 14:38 [Bug report] veth cannot be created, reporting page allocation failure Miao Wang
2024-02-22 0:49 ` Jakub Kicinski [this message]
2024-02-22 15:47 ` Miao Wang
2024-02-23 22:37 ` Miao Wang
2024-02-24 0:06 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240221164942.5af086c5@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shankerwangmiao@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).