From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: [RFC] truesize lies
Date: Mon, 10 Oct 2011 08:54:57 +0200 [thread overview]
Message-ID: <1318229697.21116.23.camel@edumazet-laptop> (raw)
In-Reply-To: <20111009.181023.328192272226333109.davem@davemloft.net>
Le dimanche 09 octobre 2011 à 18:10 -0400, David Miller a écrit :
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Sun, 09 Oct 2011 23:55:20 +0200
>
> > Some drivers splits a page in two (or more) pieces, so we cant know what
> > was really reserved by a driver for paged skbs.
> >
> > Only thing we could enforce at the moment is the proper accounting for
> > skb head :
> >
> > WARN_ON(skb->truesize < (skb_end_pointer(skb) - skb->head) + sizeof(sk_buff) + skb->data_len);
>
> This is partly true.
>
> Drivers that use page pools divide pages up into different pools, each
> with some specific block size. At least this is how NIU works.
>
> So NIU knows exactly how much of the block is logically part of that
> SKB yet unused.
>
> And if we really wanted to we could add a frag[].reserved field that
> keeps track of this for debugging.
Hmm, this would still be possible for a driver to lie and consume lot of
ram on 64bit arches.
How about using a "struct page" field then, since for a given page, we
can assume/enforce it was divided in equal units (kind of a negative
order) by a driver.
Instead of using alloc_page(order) a driver could use
alloc_page_truesize(gfp_t mask, int page_order, int subunit_order)
For example, an x86 driver using 4KB page splitted in two pieces would
use alloc_page_truesize(gfp, 0, 1)
To get frag[i].reserved (aka truesize), we then would do
static inline int frag_truesize(const skb_frag_t *frag)
{
return compound_head(frag->page)->truesize;
}
(Not even sure compound_head() is even necessary here, but I see NIU
uses it in niu_rbr_add_page() ?)
prev parent reply other threads:[~2011-10-10 6:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-09 19:02 [RFC] truesize lies Eric Dumazet
2011-10-09 19:25 ` Andi Kleen
2011-10-09 21:27 ` David Miller
2011-10-09 21:55 ` Eric Dumazet
2011-10-09 22:10 ` David Miller
2011-10-10 6:54 ` Eric Dumazet [this message]
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=1318229697.21116.23.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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