[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101130143720.GA6017@hmsreliant.think-freely.org>
Date: Tue, 30 Nov 2010 09:37:20 -0500
From: Neil Horman <nhorman@...driver.com>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: Changli Gao <xiaosuo@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Jiri Pirko <jpirko@...hat.com>, netdev@...r.kernel.org
Subject: Re: [PATCH 1/2] af_packet: use vmalloc_to_page() instead for the
addresss returned by vmalloc()
On Tue, Nov 30, 2010 at 03:12:21PM +0100, Eric Dumazet wrote:
> Le mardi 30 novembre 2010 à 21:56 +0800, Changli Gao a écrit :
> > The following commit causes the pgv->buffer may point to the memory
> > returned by vmalloc(). And we can't use virt_to_page() for the vmalloc
> > address.
> >
> > This patch introduces a new inline function pgv_to_page(), which calls
> > vmalloc_to_page() for the vmalloc address, and virt_to_page() for the
> > __get_free_pages address.
> >
> > commit 0e3125c755445664f00ad036e4fc2cd32fd52877
> > Author: Neil Horman <nhorman@...driver.com>
> > Date: Tue Nov 16 10:26:47 2010 -0800
> >
> > packet: Enhance AF_PACKET implementation to not require high order contiguous memory allocation (v4)
> >
>
> nice catch.
>
Ouch, yes, thanks.
> > Signed-off-by: Changli Gao <xiaosuo@...il.com>
> > ---
> > net/packet/af_packet.c | 21 ++++++++++++++-------
> > 1 file changed, 14 insertions(+), 7 deletions(-)
> > diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> > index 422705d..0171b20 100644
> > --- a/net/packet/af_packet.c
> > +++ b/net/packet/af_packet.c
> > @@ -224,6 +224,13 @@ struct packet_skb_cb {
> >
> > #define PACKET_SKB_CB(__skb) ((struct packet_skb_cb *)((__skb)->cb))
> >
> > +static inline struct page *pgv_to_page(void *addr)
> > +{
> > + if (is_vmalloc_addr(addr))
> > + return vmalloc_to_page(addr);
>
> Hmm, I am wondering if calling vmalloc_to_page(addr) several times for
> each packet is not too expensive ? I believe it is.
>
> What about caching "struct page *" pointer somewhere ?
>
> Then later we have :
>
> > - p_start = virt_to_page(h.raw);
> > - p_end = virt_to_page(h_end);
> > + p_start = pgv_to_page(h.raw);
> > + p_end = pgv_to_page(h_end);
> > while (p_start <= p_end) {
> > flush_dcache_page(p_start);
> > p_start++;
>
> This was OK before Neil patch... after vmalloc(), assumption that
> p_start can be incremented is completely wrong.
>
> To fix this, we need something else than your patch.
>
Off the top of my head, I would think that pgv_to_page could be prototyped such
that it could accept addr, offset and struct page ** arguments. That way we can
track the current page that we're mapped to, lowering the number of calls to
vmalloc_to_page, and we can still use an increment like we do above (as long as
its wrapped in a subsequent call to pgv_to_page)
Neil
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists