From: Alexander Lobakin <alobakin@pm.me>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: Eric Dumazet <edumazet@google.com>,
Edward Cree <ecree.xilinx@gmail.com>,
Jonathan Lemon <jonathan.lemon@gmail.com>,
Willem de Bruijn <willemb@google.com>,
Miaohe Lin <linmiaohe@huawei.com>,
Alexander Lobakin <alobakin@pm.me>,
Steffen Klassert <steffen.klassert@secunet.com>,
Guillaume Nault <gnault@redhat.com>,
Yadu Kishore <kyk.segfault@gmail.com>,
Al Viro <viro@zeniv.linux.org.uk>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 net-next 1/3] skbuff: open-code __build_skb() inside __napi_alloc_skb()
Date: Wed, 13 Jan 2021 13:36:54 +0000 [thread overview]
Message-ID: <20210113133635.39402-1-alobakin@pm.me> (raw)
In-Reply-To: <20210113133523.39205-1-alobakin@pm.me>
In preparation for skbuff_heads caching and reusing, open-code
__build_skb() inside __napi_alloc_skb() with factoring out
the skbbuff_head allocation itself.
Note that the return value of __build_skb_around() is not checked
since it never returns anything except the given skb.
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
---
net/core/skbuff.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 7626a33cce59..dc3300dc2ac4 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -485,6 +485,11 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len,
}
EXPORT_SYMBOL(__netdev_alloc_skb);
+static struct sk_buff *napi_skb_cache_get(struct napi_alloc_cache *nc)
+{
+ return kmem_cache_alloc(skbuff_head_cache, GFP_ATOMIC);
+}
+
/**
* __napi_alloc_skb - allocate skbuff for rx in a specific NAPI instance
* @napi: napi instance this buffer was allocated for
@@ -525,12 +530,15 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, unsigned int len,
if (unlikely(!data))
return NULL;
- skb = __build_skb(data, len);
+ skb = napi_skb_cache_get(nc);
if (unlikely(!skb)) {
skb_free_frag(data);
return NULL;
}
+ memset(skb, 0, offsetof(struct sk_buff, tail));
+ __build_skb_around(skb, data, len);
+
if (nc->page.pfmemalloc)
skb->pfmemalloc = 1;
skb->head_frag = 1;
--
2.30.0
next prev parent reply other threads:[~2021-01-13 13:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-13 13:35 [PATCH v2 net-next 0/3] skbuff: introduce skbuff_heads reusing and bulking Alexander Lobakin
2021-01-13 13:36 ` Alexander Lobakin [this message]
2021-01-13 13:37 ` [PATCH v2 net-next 2/3] skbuff: (re)use NAPI skb cache on allocation path Alexander Lobakin
2021-01-13 14:36 ` Eric Dumazet
2021-01-14 11:41 ` Alexander Lobakin
2021-01-14 11:47 ` Dmitry Vyukov
2021-01-14 12:44 ` Alexander Lobakin
2021-01-14 12:50 ` Dmitry Vyukov
2021-01-14 12:51 ` Dmitry Vyukov
2021-01-14 13:06 ` Alexander Lobakin
2021-01-14 13:00 ` Alexander Lobakin
2021-01-14 13:01 ` Dmitry Vyukov
2021-01-13 13:37 ` [PATCH v2 net-next 3/3] skbuff: recycle GRO_MERGED_FREE skbs into NAPI skb cache Alexander Lobakin
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=20210113133635.39402-1-alobakin@pm.me \
--to=alobakin@pm.me \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=gnault@redhat.com \
--cc=jonathan.lemon@gmail.com \
--cc=kuba@kernel.org \
--cc=kyk.segfault@gmail.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willemb@google.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).