From: Miaohe Lin <linmiaohe@huawei.com>
To: <davem@davemloft.net>, <kuba@kernel.org>,
<martin.varghese@nokia.com>, <fw@strlen.de>, <pshelar@ovn.org>,
<dcaratti@redhat.com>, <edumazet@google.com>,
<steffen.klassert@secunet.com>, <pabeni@redhat.com>,
<shmulik@metanetworks.com>, <kyk.segfault@gmail.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linmiaohe@huawei.com>
Subject: [PATCH] net: Relax the npages test against MAX_SKB_FRAGS
Date: Tue, 18 Aug 2020 07:57:12 -0400 [thread overview]
Message-ID: <20200818115712.36497-1-linmiaohe@huawei.com> (raw)
The npages test against MAX_SKB_FRAGS can be relaxed if we succeed to
allocate high order pages as the note in comment said.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
net/core/skbuff.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2f7dd689bccc..ca432bbfd90b 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5758,13 +5758,6 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len,
struct page *page;
int i;
- *errcode = -EMSGSIZE;
- /* Note this test could be relaxed, if we succeed to allocate
- * high order pages...
- */
- if (npages > MAX_SKB_FRAGS)
- return NULL;
-
*errcode = -ENOBUFS;
skb = alloc_skb(header_len, gfp_mask);
if (!skb)
@@ -5775,6 +5768,10 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len,
for (i = 0; npages > 0; i++) {
int order = max_page_order;
+ if (unlikely(i >= MAX_SKB_FRAGS)) {
+ *errcode = -EMSGSIZE;
+ goto failure;
+ }
while (order) {
if (npages >= 1 << order) {
page = alloc_pages((gfp_mask & ~__GFP_DIRECT_RECLAIM) |
--
2.19.1
next reply other threads:[~2020-08-18 11:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-18 11:57 Miaohe Lin [this message]
2020-08-18 14:15 ` Eric Dumazet
2020-08-19 1:48 linmiaohe
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=20200818115712.36497-1-linmiaohe@huawei.com \
--to=linmiaohe@huawei.com \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kuba@kernel.org \
--cc=kyk.segfault@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.varghese@nokia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pshelar@ovn.org \
--cc=shmulik@metanetworks.com \
--cc=steffen.klassert@secunet.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
all inboxes | Powered by JetHome®