All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: David Vrabel <david.vrabel@citrix.com>,
	<xen-devel@lists.xenproject.org>,
	"David S. Miller" <davem@davemloft.net>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Jenny Herbert <jennifer.herbert@citrix.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [Xen-devel] [PATCH 08/14] xen-netback: use foreign page information from the pages themselves
Date: Tue, 13 Jan 2015 14:43:39 +0000	[thread overview]
Message-ID: <54B52F1B.8040408@citrix.com> (raw)
In-Reply-To: <1421077417-7162-9-git-send-email-david.vrabel@citrix.com>

On 12/01/15 15:43, David Vrabel wrote:
> From: Jenny Herbert <jenny.herbert@citrix.com>
> 
> Use the foreign page flag in netback to get the domid and grant ref
> needed for the grant copy.  This signficiantly simplifies the netback
> code and makes netback work with foreign pages from other backends
> (e.g., blkback).
> 
> This allows blkback to use iSCSI disks provided by domUs running on
> the same host.

Dave,

This depends on several xen changes.  It's been Acked-by: Ian Campbell
<ian.campbell@citrix.com>

Are you happy for me to merge this via the xen tree in 3.20?

David

> Signed-off-by: Jenny Herbert <jennifer.herbert@citrix.com>
> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
> ---
>  drivers/net/xen-netback/netback.c |  100 ++++---------------------------------
>  1 file changed, 9 insertions(+), 91 deletions(-)
> 
> diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
> index 6441318..ae3ab37 100644
> --- a/drivers/net/xen-netback/netback.c
> +++ b/drivers/net/xen-netback/netback.c
> @@ -314,9 +314,7 @@ static struct xenvif_rx_meta *get_next_rx_buffer(struct xenvif_queue *queue,
>  static void xenvif_gop_frag_copy(struct xenvif_queue *queue, struct sk_buff *skb,
>  				 struct netrx_pending_operations *npo,
>  				 struct page *page, unsigned long size,
> -				 unsigned long offset, int *head,
> -				 struct xenvif_queue *foreign_queue,
> -				 grant_ref_t foreign_gref)
> +				 unsigned long offset, int *head)
>  {
>  	struct gnttab_copy *copy_gop;
>  	struct xenvif_rx_meta *meta;
> @@ -333,6 +331,8 @@ static void xenvif_gop_frag_copy(struct xenvif_queue *queue, struct sk_buff *skb
>  	offset &= ~PAGE_MASK;
>  
>  	while (size > 0) {
> +		struct xen_page_foreign *foreign;
> +
>  		BUG_ON(offset >= PAGE_SIZE);
>  		BUG_ON(npo->copy_off > MAX_BUFFER_OFFSET);
>  
> @@ -361,9 +361,10 @@ static void xenvif_gop_frag_copy(struct xenvif_queue *queue, struct sk_buff *skb
>  		copy_gop->flags = GNTCOPY_dest_gref;
>  		copy_gop->len = bytes;
>  
> -		if (foreign_queue) {
> -			copy_gop->source.domid = foreign_queue->vif->domid;
> -			copy_gop->source.u.ref = foreign_gref;
> +		foreign = xen_page_foreign(page);
> +		if (foreign) {
> +			copy_gop->source.domid = foreign->domid;
> +			copy_gop->source.u.ref = foreign->gref;
>  			copy_gop->flags |= GNTCOPY_source_gref;
>  		} else {
>  			copy_gop->source.domid = DOMID_SELF;
> @@ -406,35 +407,6 @@ static void xenvif_gop_frag_copy(struct xenvif_queue *queue, struct sk_buff *skb
>  }
>  
>  /*
> - * Find the grant ref for a given frag in a chain of struct ubuf_info's
> - * skb: the skb itself
> - * i: the frag's number
> - * ubuf: a pointer to an element in the chain. It should not be NULL
> - *
> - * Returns a pointer to the element in the chain where the page were found. If
> - * not found, returns NULL.
> - * See the definition of callback_struct in common.h for more details about
> - * the chain.
> - */
> -static const struct ubuf_info *xenvif_find_gref(const struct sk_buff *const skb,
> -						const int i,
> -						const struct ubuf_info *ubuf)
> -{
> -	struct xenvif_queue *foreign_queue = ubuf_to_queue(ubuf);
> -
> -	do {
> -		u16 pending_idx = ubuf->desc;
> -
> -		if (skb_shinfo(skb)->frags[i].page.p ==
> -		    foreign_queue->mmap_pages[pending_idx])
> -			break;
> -		ubuf = (struct ubuf_info *) ubuf->ctx;
> -	} while (ubuf);
> -
> -	return ubuf;
> -}
> -
> -/*
>   * Prepare an SKB to be transmitted to the frontend.
>   *
>   * This function is responsible for allocating grant operations, meta
> @@ -459,8 +431,6 @@ static int xenvif_gop_skb(struct sk_buff *skb,
>  	int head = 1;
>  	int old_meta_prod;
>  	int gso_type;
> -	const struct ubuf_info *ubuf = skb_shinfo(skb)->destructor_arg;
> -	const struct ubuf_info *const head_ubuf = ubuf;
>  
>  	old_meta_prod = npo->meta_prod;
>  
> @@ -507,68 +477,16 @@ static int xenvif_gop_skb(struct sk_buff *skb,
>  			len = skb_tail_pointer(skb) - data;
>  
>  		xenvif_gop_frag_copy(queue, skb, npo,
> -				     virt_to_page(data), len, offset, &head,
> -				     NULL,
> -				     0);
> +				     virt_to_page(data), len, offset, &head);
>  		data += len;
>  	}
>  
>  	for (i = 0; i < nr_frags; i++) {
> -		/* This variable also signals whether foreign_gref has a real
> -		 * value or not.
> -		 */
> -		struct xenvif_queue *foreign_queue = NULL;
> -		grant_ref_t foreign_gref;
> -
> -		if ((skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) &&
> -			(ubuf->callback == &xenvif_zerocopy_callback)) {
> -			const struct ubuf_info *const startpoint = ubuf;
> -
> -			/* Ideally ubuf points to the chain element which
> -			 * belongs to this frag. Or if frags were removed from
> -			 * the beginning, then shortly before it.
> -			 */
> -			ubuf = xenvif_find_gref(skb, i, ubuf);
> -
> -			/* Try again from the beginning of the list, if we
> -			 * haven't tried from there. This only makes sense in
> -			 * the unlikely event of reordering the original frags.
> -			 * For injected local pages it's an unnecessary second
> -			 * run.
> -			 */
> -			if (unlikely(!ubuf) && startpoint != head_ubuf)
> -				ubuf = xenvif_find_gref(skb, i, head_ubuf);
> -
> -			if (likely(ubuf)) {
> -				u16 pending_idx = ubuf->desc;
> -
> -				foreign_queue = ubuf_to_queue(ubuf);
> -				foreign_gref =
> -					foreign_queue->pending_tx_info[pending_idx].req.gref;
> -				/* Just a safety measure. If this was the last
> -				 * element on the list, the for loop will
> -				 * iterate again if a local page were added to
> -				 * the end. Using head_ubuf here prevents the
> -				 * second search on the chain. Or the original
> -				 * frags changed order, but that's less likely.
> -				 * In any way, ubuf shouldn't be NULL.
> -				 */
> -				ubuf = ubuf->ctx ?
> -					(struct ubuf_info *) ubuf->ctx :
> -					head_ubuf;
> -			} else
> -				/* This frag was a local page, added to the
> -				 * array after the skb left netback.
> -				 */
> -				ubuf = head_ubuf;
> -		}
>  		xenvif_gop_frag_copy(queue, skb, npo,
>  				     skb_frag_page(&skb_shinfo(skb)->frags[i]),
>  				     skb_frag_size(&skb_shinfo(skb)->frags[i]),
>  				     skb_shinfo(skb)->frags[i].page_offset,
> -				     &head,
> -				     foreign_queue,
> -				     foreign_queue ? foreign_gref : UINT_MAX);
> +				     &head);
>  	}
>  
>  	return npo->meta_prod - old_meta_prod;
> 

  parent reply	other threads:[~2015-01-13 14:45 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12 15:43 [PATCHv2 00/14] xen: fix many long-standing grant mapping bugs David Vrabel
2015-01-12 15:43 ` [PATCH 01/14] mm: provide a find_page vma operation David Vrabel
2015-01-12 15:43 ` [PATCH 02/14] mm: add 'foreign' alias for the 'pinned' page flag David Vrabel
2015-01-12 15:43 ` [PATCH 03/14] xen/grant-table: pre-populate kernel unmap ops for xen_gnttab_unmap_refs() David Vrabel
2015-01-12 15:43 ` [PATCH 04/14] xen: remove scratch frames for ballooned pages and m2p override David Vrabel
2015-01-12 15:43 ` [PATCH 05/14] x86/xen: require ballooned pages for grant maps David Vrabel
2015-01-12 15:43 ` [PATCH 06/14] xen/grant-table: add helpers for allocating pages David Vrabel
2015-01-12 15:43 ` [PATCH 07/14] xen: mark grant mapped pages as foreign David Vrabel
2015-01-12 16:54   ` Ian Campbell
2015-01-12 16:56     ` David Vrabel
2015-01-13 22:46   ` Boris Ostrovsky
2015-01-12 15:43 ` [PATCH 08/14] xen-netback: use foreign page information from the pages themselves David Vrabel
2015-01-12 16:56   ` Ian Campbell
2015-01-12 17:16     ` David Vrabel
2015-01-12 17:20       ` Ian Campbell
2015-01-13 14:43   ` David Vrabel
2015-01-13 14:43   ` David Vrabel [this message]
2015-01-13 21:57     ` [Xen-devel] " David Miller
2015-01-13 21:57     ` David Miller
2015-01-12 15:43 ` [PATCH 09/14] xen/grant-table: add a mechanism to safely unmap pages that are in use David Vrabel
2015-01-13 23:31   ` Boris Ostrovsky
2015-01-19 15:27     ` David Vrabel
2015-01-12 15:43 ` [PATCH 10/14] xen/gntdev: convert priv->lock to a mutex David Vrabel
2015-01-12 15:43 ` [PATCH 11/14] xen/gntdev: safely unmap grants in case they are still in use David Vrabel
2015-01-12 15:43 ` [PATCH 12/14] xen-blkback: " David Vrabel
2015-01-14 15:17   ` Boris Ostrovsky
2015-01-14 15:47   ` Boris Ostrovsky
2015-01-14 16:00     ` David Vrabel
2015-01-14 16:22       ` Boris Ostrovsky
2015-01-14 16:33         ` David Vrabel
2015-01-12 15:43 ` [PATCH 13/14] xen/gntdev: mark userspace PTEs as special on x86 PV guests David Vrabel
2015-01-12 15:43 ` [PATCH 14/14] xen/gntdev: provide find_page VMA operation David Vrabel

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=54B52F1B.8040408@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=davem@davemloft.net \
    --cc=jennifer.herbert@citrix.com \
    --cc=netdev@vger.kernel.org \
    --cc=xen-devel@lists.xenproject.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.