public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <erdnetdev@gmail.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Sander Eikelenboom <linux@eikelenboom.it>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	annie li <annie.li@oracle.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH] xen/netfront: improve truesize tracking
Date: Tue, 18 Dec 2012 08:35:48 -0800	[thread overview]
Message-ID: <1355848548.9380.35.camel@edumazet-glaptop> (raw)
In-Reply-To: <1355847758.14620.265.camel@zakaz.uk.xensource.com>

On Tue, 2012-12-18 at 16:22 +0000, Ian Campbell wrote:
> On Tue, 2012-12-18 at 16:13 +0000, Eric Dumazet wrote:
> > On Tue, 2012-12-18 at 15:26 +0000, Ian Campbell wrote:
> > 
> > > So actually we want += PAGE_SIZE * skb_shinfo(skb)->nr_frags ?
> > > 
> > 
> > I dont know what are the real frag sizes in your case.
> 
> I think it's a page, see xennet_alloc_rx_buffers and the alloc_page
> therein.
> 

If they are order-0 pages, then PAGE_SIZE * nr_frags  is OK.


> > Some drivers allocate a full page for an ethernet frame, others use half
> > of a page, it really depends.
> > 

> > As the frag ABI doesnt contain real size, its ok in this case to account
> > the actual frag size.
> > 
> > (skb->data_len in your driver)
> 
> I guess I'm a bit confused by what truesize means again then ;-),
> because in that case the original patch is correct although it would
> have been less confusing to do:
> 	skb->truesize += skb->data_len; 
> in xennet_poll() and then do the subtraction of
> NETFRONT_SKB_CB(skb)->pull_to in handle_incoming_queue() where we
> actually do the pull up.
> 
> Unless __pskb_pull_tail does that adjustment for us, but if it does I
> can't see where.

Thats because skb frags only contain :

a page pointer.
An offset
A size. (Exact number or used bytes in this frag)

And not the 'originally allocated size. It could be 256, 768, 2048,
4096, 65536 bytes, nobody but the driver really knows.

So when we pull X bytes from a fragment to skb->head, there is no way to
remember what was the original size of the fragment.

Only the driver allocating the frag knows its truesize.

Once skb is given to the stack, we lose this information, and rely on
skb->truesize being an accurate estimation.

  reply	other threads:[~2012-12-18 16:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-18 13:51 [PATCH] xen/netfront: improve truesize tracking Ian Campbell
2012-12-18 14:10 ` Konrad Rzeszutek Wilk
2012-12-18 14:15   ` Ian Campbell
2012-12-18 15:12 ` Eric Dumazet
2012-12-18 15:26   ` Ian Campbell
2012-12-18 16:13     ` Eric Dumazet
2012-12-18 16:22       ` Ian Campbell
2012-12-18 16:35         ` Eric Dumazet [this message]
2012-12-19 11:34     ` Sander Eikelenboom
2012-12-19 16:17       ` Eric Dumazet
2012-12-20 12:51         ` Sander Eikelenboom
2012-12-20 14:23           ` [Xen-devel] " Sander Eikelenboom
2012-12-20 14:58             ` Sander Eikelenboom
2012-12-20 15:39           ` Eric Dumazet
2012-12-21 11:21             ` Sander Eikelenboom
2012-12-21 18:33               ` Rick Jones
2013-01-03 20:40                 ` Sander Eikelenboom
2013-01-07 13:41                   ` Ian Campbell
2013-01-07 14:11                     ` Sander Eikelenboom
2013-01-07 14:22                       ` Ian Campbell
2013-01-07 15:26                         ` Eric Dumazet
2013-01-07 16:17                     ` Eric Dumazet

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=1355848548.9380.35.camel@edumazet-glaptop \
    --to=erdnetdev@gmail.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=annie.li@oracle.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux@eikelenboom.it \
    --cc=netdev@vger.kernel.org \
    --cc=xen-devel@lists.xensource.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