Signed-off-by: Steven Smith <steven.smith@xxxxxxxxxx>
---
drivers/xen/netback/netback.c | 31 ++++++++++++++++++++++++++-----
1 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/drivers/xen/netback/netback.c b/drivers/xen/netback/netback.c
index fe6eff7..76641b1 100644
--- a/drivers/xen/netback/netback.c
+++ b/drivers/xen/netback/netback.c
@@ -37,6 +37,7 @@
#include "common.h"
#include <xen/balloon.h>
#include <xen/interface/memory.h>
+#include <xen/live_maps.h>
#include <linux/kthread.h>
/*define NETBE_DEBUG_INTERRUPT*/
@@ -133,6 +134,8 @@ typedef unsigned int PEND_RING_IDX;
static PEND_RING_IDX pending_prod, pending_cons;
#define NR_PENDING_REQS (MAX_PENDING_REQS - pending_prod + pending_cons)
+static struct page_foreign_tracker *foreign_page_tracker;
+
/* Freed TX SKBs get batched on this ring before return to pending_ring. */
static u16 dealloc_ring[MAX_PENDING_REQS];
static PEND_RING_IDX dealloc_prod, dealloc_cons;
@@ -438,16 +441,14 @@ static void netbk_gop_frag_copy(netif_t *netif,
{
gnttab_copy_t *copy_gop;
struct netbk_rx_meta *meta;
- int idx = netif_page_index(page);
meta = npo->meta + npo->meta_prod - 1;
copy_gop = npo->copy + npo->copy_prod++;
copy_gop->flags = GNTCOPY_dest_gref;
- if (idx > -1) {
- struct pending_tx_info *src_pend = &pending_tx_info[idx];
- copy_gop->source.domid = src_pend->netif->domid;
- copy_gop->source.u.ref = src_pend->req.gref;
+ if (page_is_tracked(page)) {
+ lookup_tracker_page(page, ©_gop->source.domid,
+ ©_gop->source.u.ref);
copy_gop->flags |= GNTCOPY_source_gref;
} else {
copy_gop->source.domid = DOMID_SELF;
@@ -1081,6 +1082,8 @@ inline static void net_tx_action_dealloc(void)
if (!phys_to_machine_mapping_valid(pfn))
continue;
+ stop_tracking_page(mmap_pages[pending_idx]);
+
gnttab_set_unmap_op(gop, idx_to_kaddr(pending_idx),
GNTMAP_host_map,
grant_tx_handle[pending_idx]);
@@ -1219,6 +1222,13 @@ static gnttab_map_grant_ref_t
*netbk_get_requests(netif_t *netif,
netif_get(netif);
pending_tx_info[pending_idx].netif = netif;
frags[i].page = (void *)pending_idx;
+
+ start_tracking_page(foreign_page_tracker,
+ mmap_pages[pending_idx],
+ netif->domid,
+ pending_tx_info[pending_idx].req.gref,
+ pending_idx,
+ NULL);
}
return mop;
@@ -1526,6 +1536,13 @@ static void net_tx_action(void)
txreq.gref, netif->domid);
mop++;
+ start_tracking_page(foreign_page_tracker,
+ mmap_pages[pending_idx],
+ netif->domid,
+ txreq.gref,
+ pending_idx,
+ NULL);
+
memcpy(&pending_tx_info[pending_idx].req,
&txreq, sizeof(txreq));
pending_tx_info[pending_idx].netif = netif;
@@ -1804,9 +1821,13 @@ static int __init netback_init(void)
netbk_tx_pending_timer.data = 0;
netbk_tx_pending_timer.function = netbk_tx_pending_timeout;
+ foreign_page_tracker = alloc_page_foreign_tracker(MAX_PENDING_REQS);
+ if (!foreign_page_tracker)
+ return -ENOMEM;
mmap_pages = alloc_empty_pages_and_pagevec(MAX_PENDING_REQS);
if (mmap_pages == NULL) {
printk("%s: out of memory\n", __FUNCTION__);
+ free_page_foreign_tracker(foreign_page_tracker);
return -ENOMEM;
}
--
1.6.3.1
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|