From: Paolo Abeni <pabeni@redhat.com>
To: Eric Dumazet <edumazet@google.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com,
Alexander Duyck <alexanderduyck@fb.com>,
Soheil Hassas Yeganeh <soheil@google.com>
Subject: Re: [PATCH net-next 4/4] net: add dedicated kmem_cache for typical/small skb->head
Date: Fri, 03 Feb 2023 08:59:31 +0100 [thread overview]
Message-ID: <db71bb74eb61fa09226ef5f2071747f35d67df82.camel@redhat.com> (raw)
In-Reply-To: <20230202185801.4179599-5-edumazet@google.com>
On Thu, 2023-02-02 at 18:58 +0000, Eric Dumazet wrote:
> Note: after Kees Cook patches and this one, we might
> be able to revert commit
> dbae2b062824 ("net: skb: introduce and use a single page frag cache")
> because GRO_MAX_HEAD is also small.
I guess I'll need some time to do the relevant benchmarks, but I'm not
able to schedule them very soon.
> @@ -486,6 +499,21 @@ static void *kmalloc_reserve(unsigned int *size, gfp_t flags, int node,
> void *obj;
>
> obj_size = SKB_HEAD_ALIGN(*size);
> + if (obj_size <= SKB_SMALL_HEAD_CACHE_SIZE &&
> + !(flags & KMALLOC_NOT_NORMAL_BITS)) {
> +
> + /* skb_small_head_cache has non power of two size,
> + * likely forcing SLUB to use order-3 pages.
> + * We deliberately attempt a NOMEMALLOC allocation only.
> + */
> + obj = kmem_cache_alloc_node(skb_small_head_cache,
> + flags | __GFP_NOMEMALLOC | __GFP_NOWARN,
> + node);
> + if (obj) {
> + *size = SKB_SMALL_HEAD_CACHE_SIZE;
> + goto out;
> + }
In case kmem allocation failure, should we try to skip the 2nd
__GFP_NOMEMALLOC attempt below?
I *think* non power of two size is also required to avoid an issue
plain (no GFP_DMA nor __GFP_ACCOUNT) allocations in case of fallback to
kmalloc(), to prevent skb_kfree_head() mis-interpreting skb->head as
kmem_cache allocated.
Thanks!
Paolo
next prev parent reply other threads:[~2023-02-03 8:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 18:57 [PATCH net-next 0/4] net: core: use a dedicated kmem_cache for skb head allocs Eric Dumazet
2023-02-02 18:57 ` [PATCH net-next 1/4] net: add SKB_HEAD_ALIGN() helper Eric Dumazet
2023-02-02 20:06 ` Soheil Hassas Yeganeh
2023-02-02 18:57 ` [PATCH net-next 2/4] net: remove osize variable in __alloc_skb() Eric Dumazet
2023-02-02 20:07 ` Soheil Hassas Yeganeh
2023-02-02 18:58 ` [PATCH net-next 3/4] net: factorize code in kmalloc_reserve() Eric Dumazet
2023-02-02 20:09 ` Soheil Hassas Yeganeh
2023-02-02 18:58 ` [PATCH net-next 4/4] net: add dedicated kmem_cache for typical/small skb->head Eric Dumazet
2023-02-02 20:14 ` Soheil Hassas Yeganeh
2023-02-03 5:11 ` Jakub Kicinski
2023-02-03 7:00 ` Eric Dumazet
2023-02-03 7:59 ` Paolo Abeni [this message]
2023-02-03 8:17 ` Eric Dumazet
2023-02-03 19:47 ` Jakub Kicinski
2023-02-03 19:37 ` kernel test robot
2023-02-03 19:42 ` Jakub Kicinski
2023-02-06 18:16 ` [PATCH net-next 0/4] net: core: use a dedicated kmem_cache for skb head allocs Paolo Abeni
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=db71bb74eb61fa09226ef5f2071747f35d67df82.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=alexanderduyck@fb.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=soheil@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).