[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 02/17] Use the foreign page tracking logic in netback.c. This isn't terribly useful, but will be necessary if anything else ever introduces mappings of foreign pages into the network stack.



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 d7d738e..150f4a2 100644
--- a/drivers/xen/netback/netback.c
+++ b/drivers/xen/netback/netback.c
@@ -42,6 +42,7 @@
 #include <xen/balloon.h>
 #include <xen/events.h>
 #include <xen/interface/memory.h>
+#include <xen/live_maps.h>
 
 #include <asm/xen/hypercall.h>
 #include <asm/xen/page.h>
@@ -143,6 +144,8 @@ static inline pending_ring_idx_t nr_pending_reqs(void)
        return 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 pending_ring_idx_t dealloc_prod, dealloc_cons;
@@ -385,7 +388,6 @@ static u16 netbk_gop_frag(struct xen_netif *netif, struct 
netbk_rx_meta *meta,
        struct gnttab_copy *copy_gop;
        struct xen_netif_rx_request *req;
        unsigned long old_mfn;
-       int idx = netif_page_index(page);
 
        old_mfn = virt_to_mfn(page_address(page));
 
@@ -393,10 +395,9 @@ static u16 netbk_gop_frag(struct xen_netif *netif, struct 
netbk_rx_meta *meta,
 
        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, &copy_gop->source.domid,
+                                   &copy_gop->source.u.ref);
                copy_gop->flags |= GNTCOPY_source_gref;
        } else {
                copy_gop->source.domid = DOMID_SELF;
@@ -799,6 +800,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]);
@@ -938,6 +941,13 @@ static struct gnttab_map_grant_ref 
*netbk_get_requests(struct xen_netif *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;
@@ -1276,6 +1286,13 @@ static unsigned net_tx_build_mops(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;
@@ -1554,9 +1571,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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.