All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Bader <stefan.bader@canonical.com>
To: Ian Campbell <ian.campbell@citrix.com>
Cc: netdev@vger.kernel.org, xen-devel@lists.xen.org,
	Eric Dumazet <edumazet@google.com>,
	Konrad Rzeszutek Wilk <konrad@kernel.org>,
	ANNIE LI <annie.li@oracle.com>,
	Sander Eikelenboom <linux@eikelenboom.it>
Subject: Re: [PATCH] xen/netfront: handle compound page fragments on transmit
Date: Tue, 20 Nov 2012 14:30:54 +0100	[thread overview]
Message-ID: <50AB860E.3090106@canonical.com> (raw)
In-Reply-To: <1353411606-15940-1-git-send-email-ian.campbell@citrix.com>

[-- Attachment #1: Type: text/plain, Size: 3619 bytes --]

Aside from Jans comments about error handling, I tried below patch and it seems
to solve the problem with transfers out of the domU for me (though only shallow
testing done, otoh 5 times is more than getting stuck the first time).

-Stefan

On 20.11.2012 12:40, Ian Campbell wrote:
> An SKB paged fragment can consist of a compound page with order > 0.
> However the netchannel protocol deals only in PAGE_SIZE frames.
> 
> Handle this in xennet_make_frags by iterating over the frames which
> make up the page.
> 
> This is the netfront equivalent to 6a8ed462f16b for netback.
> 
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> Cc: netdev@vger.kernel.org
> Cc: xen-devel@lists.xen.org
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Konrad Rzeszutek Wilk <konrad@kernel.org>
> Cc: ANNIE LI <annie.li@oracle.com>
> Cc: Sander Eikelenboom <linux@eikelenboom.it>
> Cc: Stefan Bader <stefan.bader@canonical.com>
Tested-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>  drivers/net/xen-netfront.c |   58 +++++++++++++++++++++++++++++++++----------
>  1 files changed, 44 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
> index caa0110..a12b99a 100644
> --- a/drivers/net/xen-netfront.c
> +++ b/drivers/net/xen-netfront.c
> @@ -452,24 +452,54 @@ static void xennet_make_frags(struct sk_buff *skb, struct net_device *dev,
>  	/* Grant backend access to each skb fragment page. */
>  	for (i = 0; i < frags; i++) {
>  		skb_frag_t *frag = skb_shinfo(skb)->frags + i;
> +		struct page *page = skb_frag_page(frag);
> +		unsigned long size = skb_frag_size(frag);
> +		unsigned long offset = frag->page_offset;
>  
> -		tx->flags |= XEN_NETTXF_more_data;
> +		/* Data must not cross a page boundary. */
> +		BUG_ON(size + offset > PAGE_SIZE<<compound_order(page));
>  
> -		id = get_id_from_freelist(&np->tx_skb_freelist, np->tx_skbs);
> -		np->tx_skbs[id].skb = skb_get(skb);
> -		tx = RING_GET_REQUEST(&np->tx, prod++);
> -		tx->id = id;
> -		ref = gnttab_claim_grant_reference(&np->gref_tx_head);
> -		BUG_ON((signed short)ref < 0);
> +		/* Skip unused frames from start of page */
> +		page += offset >> PAGE_SHIFT;
> +		offset &= ~PAGE_MASK;
>  
> -		mfn = pfn_to_mfn(page_to_pfn(skb_frag_page(frag)));
> -		gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id,
> -						mfn, GNTMAP_readonly);
> +		while (size > 0) {
> +			unsigned long bytes;
>  
> -		tx->gref = np->grant_tx_ref[id] = ref;
> -		tx->offset = frag->page_offset;
> -		tx->size = skb_frag_size(frag);
> -		tx->flags = 0;
> +			BUG_ON(offset >= PAGE_SIZE);
> +
> +			bytes = PAGE_SIZE - offset;
> +			if (bytes > size)
> +				bytes = size;
> +
> +			tx->flags |= XEN_NETTXF_more_data;
> +
> +			id = get_id_from_freelist(&np->tx_skb_freelist, np->tx_skbs);
> +			np->tx_skbs[id].skb = skb_get(skb);
> +			tx = RING_GET_REQUEST(&np->tx, prod++);
> +			tx->id = id;
> +			ref = gnttab_claim_grant_reference(&np->gref_tx_head);
> +			BUG_ON((signed short)ref < 0);
> +
> +			mfn = pfn_to_mfn(page_to_pfn(page));
> +			gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id,
> +							mfn, GNTMAP_readonly);
> +
> +			tx->gref = np->grant_tx_ref[id] = ref;
> +			tx->offset = offset;
> +			tx->size = bytes;
> +			tx->flags = 0;
> +
> +			offset += bytes;
> +			size -= bytes;
> +
> +			/* Next frame */
> +			if (offset == PAGE_SIZE && size) {
> +				BUG_ON(!PageCompound(page));
> +				page++;
> +				offset = 0;
> +			}
> +		}
>  	}
>  
>  	np->tx.req_prod_pvt = prod;
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 897 bytes --]

  parent reply	other threads:[~2012-11-20 13:31 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-09 13:47 compound skb frag pages appearing in start_xmit Ian Campbell
2012-10-09 13:54 ` Eric Dumazet
2012-10-09 14:01   ` Eric Dumazet
2012-10-09 14:01   ` Eric Dumazet
2012-10-09 14:23     ` Ian Campbell
2012-10-09 14:23     ` Ian Campbell
2012-10-09 14:33       ` Eric Dumazet
2012-10-09 14:33       ` Eric Dumazet
2012-10-09 14:54         ` Ian Campbell
2012-10-09 14:54         ` Ian Campbell
2012-10-09 14:17   ` Ian Campbell
2012-10-09 14:17   ` Ian Campbell
2012-10-09 14:27     ` Eric Dumazet
2012-10-09 14:40       ` Ian Campbell
2012-10-09 14:51         ` Eric Dumazet
2012-10-09 14:51         ` Eric Dumazet
2012-10-10 10:13         ` Ian Campbell
2012-10-10 10:13         ` [Xen-devel] " Ian Campbell
2012-10-10 12:24           ` Sander Eikelenboom
2012-10-10 12:29             ` [Xen-devel] " Ian Campbell
2012-10-10 13:31               ` Sander Eikelenboom
2012-10-10 13:31               ` Sander Eikelenboom
2012-10-10 12:29             ` Ian Campbell
2012-10-10 13:09           ` [Xen-devel] " Ian Campbell
2012-10-10 14:49             ` Sander Eikelenboom
2012-10-11  8:02               ` Ian Campbell
2012-10-11 10:00                 ` Sander Eikelenboom
2012-10-11 10:05                   ` Eric Dumazet
2012-10-11 10:14                     ` Ian Campbell
2012-10-11 10:20                       ` Sander Eikelenboom
2012-10-11 10:20                       ` Sander Eikelenboom
2012-11-15  2:31                       ` [Xen-devel] " ANNIE LI
2012-11-19 15:43                         ` Sander Eikelenboom
2012-11-20  8:30                           ` [Xen-devel] " Stefan Bader
2012-11-20  9:21                             ` Ian Campbell
2012-11-20 11:36                               ` [Xen-devel] " Ian Campbell
2012-11-21  2:42                                 ` ANNIE LI
2012-11-21  2:42                                 ` [Xen-devel] " ANNIE LI
2012-11-20 11:36                               ` Ian Campbell
2012-11-20 11:40                               ` [PATCH] xen/netfront: handle compound page fragments on transmit Ian Campbell
2012-11-20 12:28                                 ` Jan Beulich
2012-11-20 12:28                                 ` [Xen-devel] " Jan Beulich
2012-11-20 13:35                                   ` Ian Campbell
2012-11-20 13:35                                   ` [Xen-devel] " Ian Campbell
2012-11-20 13:51                                     ` Jan Beulich
2012-11-20 14:14                                       ` Ian Campbell
2012-11-20 14:32                                         ` Jan Beulich
2012-11-20 15:06                                           ` Ian Campbell
2012-11-20 15:06                                           ` [Xen-devel] " Ian Campbell
2012-11-20 15:28                                             ` Eric Dumazet
2012-11-20 15:54                                               ` Ian Campbell
2012-11-20 15:54                                               ` [Xen-devel] " Ian Campbell
2012-11-20 16:04                                                 ` netchannel vs MAX_SKB_FRAGS (Was: Re: [PATCH] xen/netfront: handle compound page fragments on transmit) Ian Campbell
2012-11-23  1:30                                                   ` ANNIE LI
2012-11-23  2:10                                                     ` James Harper
2012-11-23  6:49                                                       ` ANNIE LI
2012-11-23  9:22                                                       ` Paul Durrant
2012-11-23  9:26                                                         ` James Harper
2012-11-23  9:34                                                           ` Ian Campbell
2012-11-23  9:18                                                     ` Ian Campbell
2012-11-23 15:08                                                       ` annie li
2012-11-20 15:28                                             ` [PATCH] xen/netfront: handle compound page fragments on transmit Eric Dumazet
2012-11-20 15:44                                             ` Jan Beulich
2012-11-20 15:44                                             ` [Xen-devel] " Jan Beulich
2012-11-20 16:14                                               ` Eric Dumazet
2012-11-20 14:32                                         ` Jan Beulich
2012-11-20 14:14                                       ` Ian Campbell
2012-11-20 13:51                                     ` Jan Beulich
2012-11-20 13:30                                 ` Stefan Bader [this message]
2012-11-20 13:45                                   ` Sander Eikelenboom
2012-11-20 13:45                                   ` Sander Eikelenboom
2012-11-20 13:30                                 ` Stefan Bader
2012-11-20 14:45                                 ` Eric Dumazet
2012-11-20 15:05                                   ` Ian Campbell
2012-11-20 15:05                                   ` Ian Campbell
2012-11-20 14:45                                 ` Eric Dumazet
2012-11-21  2:52                                 ` ANNIE LI
2012-11-21 11:09                                   ` Ian Campbell
2012-11-21 11:09                                   ` Ian Campbell
2012-11-21  2:52                                 ` ANNIE LI
2012-11-20 11:40                               ` Ian Campbell
2012-11-20  8:30                           ` compound skb frag pages appearing in start_xmit Stefan Bader
2012-11-15  2:31                       ` ANNIE LI
2012-10-11 10:14                     ` Ian Campbell
2012-10-11 10:05                   ` Eric Dumazet
2012-10-11 10:00                 ` Sander Eikelenboom
2012-10-11  8:02               ` Ian Campbell
2012-10-10 14:49             ` Sander Eikelenboom
2012-10-10 13:09           ` Ian Campbell
2012-10-09 14:40       ` Ian Campbell
2012-10-09 14:27     ` Eric Dumazet
2012-10-09 13:54 ` 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=50AB860E.3090106@canonical.com \
    --to=stefan.bader@canonical.com \
    --cc=annie.li@oracle.com \
    --cc=edumazet@google.com \
    --cc=ian.campbell@citrix.com \
    --cc=konrad@kernel.org \
    --cc=linux@eikelenboom.it \
    --cc=netdev@vger.kernel.org \
    --cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.