netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Eric Dumazet <edumazet@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>,
	"David S . Miller" <davem@davemloft.net>,
	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, 3 Feb 2023 11:47:44 -0800	[thread overview]
Message-ID: <20230203114744.153c4063@kernel.org> (raw)
In-Reply-To: <CANn89iLj8hC7jgb5jDNi01nKqikGbgKMtFvbZDxWi4Qoi1y8fw@mail.gmail.com>

On Fri, 3 Feb 2023 09:17:55 +0100 Eric Dumazet wrote:
> > 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.  
> 
> Indeed there are multiple cases explaining why SKB_SMALL_HEAD_CACHE_SIZE
> needs to be a non power of two.

Since you may need to respin would you mind spelling this out a bit
more in the comment ? Maybe: 

-/* We want SKB_SMALL_HEAD_CACHE_SIZE to not be a power of two. */
+/* We want SKB_SMALL_HEAD_CACHE_SIZE to not be a power of two.
+ * This should ensure that SKB_SMALL_HEAD_HEADROOM is a unique
+ * size, and we can differentiate heads from skb_small_head_cache
+ * vs system slabs by looking at their size (skb_end_offset()).
+ */

  reply	other threads:[~2023-02-03 19:47 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
2023-02-03  8:17     ` Eric Dumazet
2023-02-03 19:47       ` Jakub Kicinski [this message]
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=20230203114744.153c4063@kernel.org \
    --to=kuba@kernel.org \
    --cc=alexanderduyck@fb.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --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).