From: Alexander Duyck <alexander.h.duyck@intel.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>,
David Miller <davem@davemloft.net>,
amirv@mellanox.com, netdev@vger.kernel.org, idos@mellanox.com,
jeffrey.t.kirsher@intel.com, jesse.brandeburg@intel.com,
bruce.w.allan@intel.com, carolyn.wyborny@intel.com,
donald.c.skidmore@intel.com, gregory.v.rose@intel.com,
john.ronciak@intel.com, mitch.a.williams@intel.com,
yevgenyp@mellanox.com, ogerlitz@mellanox.com
Subject: Re: [PATCH net-next 1/2] net: Expose header length compution function
Date: Wed, 21 May 2014 09:45:03 -0700 [thread overview]
Message-ID: <537CD80F.2090909@intel.com> (raw)
In-Reply-To: <1400687469.5367.152.camel@edumazet-glaptop2.roam.corp.google.com>
On 05/21/2014 08:51 AM, Eric Dumazet wrote:
> On Wed, 2014-05-21 at 08:03 -0700, Alexander Duyck wrote:
>
>> So it looks like you did kind of what I expected you would, only you
>> allocated a temporary sk_buff on the stack and then pointed the head to
>> the start of the page. I'm not really a fan of this approach though it
>> does give me a couple ideas.
>>
>> One thought I just had though, what if we were to do something like
>> create an eth_build_skb function?
> Well, it all depends if you use napi_get_frags() / napi_gro_frags(),
> which are normally the way to get very fast GRO processing, since
> you don't even have to allocate memory for the skbs at all, since
> skb will likely be recycled in napi_reuse_skb()
Another thought would be to possibly look into a GRO type approach.
Something where we could place the length parsing functions in the
offload_callbacks. If we could do that then we could just integrate the
functionality with GRO and make use of those callbacks. Basically it
would require doing the parsing as a part of napi_frags_skb() so that
when we do the pull we get the full header length in one shot so that
the entire frame is linear right from the start.
Actually the more I think about this now the more it makes sense. We
could probably pull out all the skb_gro_header_hard/skb_gro_header_slow
length bits from the existing gro_receive functions and place them in
another piece of the code.
>> It would essentially be a cross
>> between eth_type_trans, your new eth_frame_headlen function, and
>> build_skb. It would allow us to avoid the unnecessary allocation of an
>> skb on the stack and avoid any unnecessary data duplication since we
>> already would be doing a number of the eth_type_trans steps in your
>> eth_frame_headlen function. The one limitation is that we would need to
>> allocate a block of memory for the head, but that would be done after we
>> figure out what the size of the header is.
> 'Allocating' an skb on stack has no cost. Exactly 0 added instructions.
>
> It only increases the size of stack, and at this point we are before all
> the networking stacks, so it is safe.
>
> Have you seen the eBPF stuff adding more stack usage than this ?
>
> #define MAX_BPF_STACK 512
We have had stack smashing issues in the past with the ixgbe interrupt
handlers and it wasn't consuming much memory on the stack as I recall.
I prefer to err on the side of caution.
Also the more I think about it I am not really comfortable putting a
partially initialized sk_buff through any function calls. It seems like
it is setting somebody up for a failure because if at some point the
code changes and needs some other field out of the skb it won't be
initialized here unless they catch this tricky bit of code.
next prev parent reply other threads:[~2014-05-21 16:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 12:50 [PATCH net-next 0/2] net, igb, mlx4: Copy exact header to SKB linear buffer Amir Vadai
2014-05-08 12:50 ` [PATCH net-next 1/2] net: Expose header length compution function Amir Vadai
2014-05-08 15:18 ` Alexander Duyck
2014-05-09 20:24 ` David Miller
2014-05-10 17:12 ` Alexander Duyck
2014-05-10 17:49 ` Eric Dumazet
2014-05-10 21:53 ` Alexander Duyck
2014-05-19 21:01 ` Eric Dumazet
2014-05-21 15:03 ` Alexander Duyck
2014-05-21 15:51 ` Eric Dumazet
2014-05-21 16:45 ` Alexander Duyck [this message]
2014-05-21 17:41 ` Eric Dumazet
2014-05-08 12:50 ` [PATCH net-next 2/2] net/mlx4_en: Copy exact header to SKB linear part Amir Vadai
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=537CD80F.2090909@intel.com \
--to=alexander.h.duyck@intel.com \
--cc=alexander.duyck@gmail.com \
--cc=amirv@mellanox.com \
--cc=bruce.w.allan@intel.com \
--cc=carolyn.wyborny@intel.com \
--cc=davem@davemloft.net \
--cc=donald.c.skidmore@intel.com \
--cc=eric.dumazet@gmail.com \
--cc=gregory.v.rose@intel.com \
--cc=idos@mellanox.com \
--cc=jeffrey.t.kirsher@intel.com \
--cc=jesse.brandeburg@intel.com \
--cc=john.ronciak@intel.com \
--cc=mitch.a.williams@intel.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=yevgenyp@mellanox.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).