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

[Xen-changelog] [linux-2.6.18-xen] widen use of (and introduce further) MULTI_* helpers


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-linux-2.6.18-xen <patchbot@xxxxxxx>
  • Date: Mon, 04 Jun 2012 09:11:03 +0000
  • Delivery-date: Mon, 04 Jun 2012 09:11:32 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1338800100 -7200
# Node ID b72a53f5d7563ac9b1d8e13723c5a5bc9b08e19d
# Parent  07b22ab8d245b2485ae524de8c5888e327445175
widen use of (and introduce further) MULTI_* helpers

This includes folding an MMU update and a grant table operation into a
multicall in gnttab_copy_grant_page()

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---


diff -r 07b22ab8d245 -r b72a53f5d756 drivers/xen/core/gnttab.c
--- a/drivers/xen/core/gnttab.c Mon Jun 04 10:38:05 2012 +0200
+++ b/drivers/xen/core/gnttab.c Mon Jun 04 10:55:00 2012 +0200
@@ -607,13 +607,9 @@ static void gnttab_page_free(struct page
 int gnttab_copy_grant_page(grant_ref_t ref, struct page **pagep)
 {
        struct gnttab_unmap_and_replace unmap;
-       mmu_update_t mmu;
-       struct page *page;
-       struct page *new_page;
-       void *new_addr;
-       void *addr;
-       paddr_t pfn;
-       maddr_t mfn;
+       struct page *page, *new_page;
+       void *addr, *new_addr;
+       unsigned long pfn;
        maddr_t new_mfn;
        int err;
 
@@ -631,7 +627,6 @@ int gnttab_copy_grant_page(grant_ref_t r
        copy_page(new_addr, addr);
 
        pfn = page_to_pfn(page);
-       mfn = pfn_to_mfn(pfn);
        new_mfn = virt_to_mfn(new_addr);
 
        write_seqlock(&gnttab_dma_lock);
@@ -647,28 +642,33 @@ int gnttab_copy_grant_page(grant_ref_t r
                goto out;
        }
 
-       if (!xen_feature(XENFEAT_auto_translated_physmap))
-               set_phys_to_machine(pfn, new_mfn);
-
        gnttab_set_replace_op(&unmap, (unsigned long)addr,
                              (unsigned long)new_addr, ref);
 
-       err = HYPERVISOR_grant_table_op(GNTTABOP_unmap_and_replace,
-                                       &unmap, 1);
+       if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+               multicall_entry_t mc[2];
+               mmu_update_t mmu;
+
+               set_phys_to_machine(pfn, new_mfn);
+               set_phys_to_machine(page_to_pfn(new_page), INVALID_P2M_ENTRY);
+
+               MULTI_grant_table_op(&mc[0], GNTTABOP_unmap_and_replace,
+                                    &unmap, 1);
+
+               mmu.ptr = (new_mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
+               mmu.val = pfn;
+               MULTI_mmu_update(&mc[1], &mmu, 1, NULL, DOMID_SELF);
+
+               err = HYPERVISOR_multicall_check(mc, 2, NULL);
+       } else
+               err = HYPERVISOR_grant_table_op(GNTTABOP_unmap_and_replace,
+                                               &unmap, 1);
+
        BUG_ON(err);
        BUG_ON(unmap.status != GNTST_okay);
 
        write_sequnlock(&gnttab_dma_lock);
 
-       if (!xen_feature(XENFEAT_auto_translated_physmap)) {
-               set_phys_to_machine(page_to_pfn(new_page), INVALID_P2M_ENTRY);
-
-               mmu.ptr = (new_mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
-               mmu.val = pfn;
-               err = HYPERVISOR_mmu_update(&mmu, 1, NULL, DOMID_SELF);
-               BUG_ON(err);
-       }
-
        new_page->mapping = page->mapping;
        new_page->index = page->index;
        set_bit(PG_foreign, &new_page->flags);
diff -r 07b22ab8d245 -r b72a53f5d756 drivers/xen/netback/netback.c
--- a/drivers/xen/netback/netback.c     Mon Jun 04 10:38:05 2012 +0200
+++ b/drivers/xen/netback/netback.c     Mon Jun 04 10:55:00 2012 +0200
@@ -644,29 +644,21 @@ static void net_rx_action(unsigned long 
                BUG_ON(mcl[-1].op != __HYPERVISOR_update_va_mapping);
                mcl[-1].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_ALL;
 
-               mcl->op = __HYPERVISOR_mmu_update;
-               mcl->args[0] = (unsigned long)rx_mmu;
-               mcl->args[1] = npo.mmu_prod;
-               mcl->args[2] = 0;
-               mcl->args[3] = DOMID_SELF;
+               MULTI_mmu_update(mcl, rx_mmu, npo.mmu_prod, 0, DOMID_SELF);
        }
 
        if (npo.trans_prod) {
                BUG_ON(npo.trans_prod > ARRAY_SIZE(grant_trans_op));
-               mcl = npo.mcl + npo.mcl_prod++;
-               mcl->op = __HYPERVISOR_grant_table_op;
-               mcl->args[0] = GNTTABOP_transfer;
-               mcl->args[1] = (unsigned long)grant_trans_op;
-               mcl->args[2] = npo.trans_prod;
+               MULTI_grant_table_op(npo.mcl + npo.mcl_prod++,
+                                    GNTTABOP_transfer, grant_trans_op,
+                                    npo.trans_prod);
        }
 
        if (npo.copy_prod) {
                BUG_ON(npo.copy_prod > ARRAY_SIZE(grant_copy_op));
-               mcl = npo.mcl + npo.mcl_prod++;
-               mcl->op = __HYPERVISOR_grant_table_op;
-               mcl->args[0] = GNTTABOP_copy;
-               mcl->args[1] = (unsigned long)grant_copy_op;
-               mcl->args[2] = npo.copy_prod;
+               MULTI_grant_table_op(npo.mcl + npo.mcl_prod++,
+                                    GNTTABOP_copy, grant_copy_op,
+                                    npo.copy_prod);
        }
 
        /* Nothing to do? */
diff -r 07b22ab8d245 -r b72a53f5d756 drivers/xen/netfront/netfront.c
--- a/drivers/xen/netfront/netfront.c   Mon Jun 04 10:38:05 2012 +0200
+++ b/drivers/xen/netfront/netfront.c   Mon Jun 04 10:55:00 2012 +0200
@@ -841,9 +841,9 @@ no_skb:
                                UVMF_TLB_FLUSH|UVMF_ALL;
 
                        /* Give away a batch of pages. */
-                       np->rx_mcl[i].op = __HYPERVISOR_memory_op;
-                       np->rx_mcl[i].args[0] = XENMEM_decrease_reservation;
-                       np->rx_mcl[i].args[1] = (unsigned long)&reservation;
+                       MULTI_memory_op(np->rx_mcl + i,
+                                       XENMEM_decrease_reservation,
+                                       &reservation);
 
                        /* Zap PTEs and give away pages in one big
                         * multicall. */
@@ -1326,7 +1326,6 @@ static int netif_poll(struct net_device 
        struct netif_rx_response *rx = &rinfo.rx;
        struct netif_extra_info *extras = rinfo.extras;
        RING_IDX i, rp;
-       struct multicall_entry *mcl;
        int work_done, budget, more_to_do = 1, accel_more_to_do = 1;
        struct sk_buff_head rxq;
        struct sk_buff_head errq;
@@ -1453,12 +1452,9 @@ err:
 
                /* Do all the remapping work and M2P updates. */
                if (!xen_feature(XENFEAT_auto_translated_physmap)) {
-                       mcl = np->rx_mcl + pages_flipped;
-                       mcl->op = __HYPERVISOR_mmu_update;
-                       mcl->args[0] = (unsigned long)np->rx_mmu;
-                       mcl->args[1] = pages_flipped;
-                       mcl->args[2] = 0;
-                       mcl->args[3] = DOMID_SELF;
+                       MULTI_mmu_update(np->rx_mcl + pages_flipped,
+                                        np->rx_mmu, pages_flipped, 0,
+                                        DOMID_SELF);
                        err = HYPERVISOR_multicall_check(np->rx_mcl,
                                                         pages_flipped + 1,
                                                         NULL);
@@ -1623,14 +1619,10 @@ static void netif_release_rx_bufs_flip(s
 
                if (!xen_feature(XENFEAT_auto_translated_physmap)) {
                        /* Do all the remapping work and M2P updates. */
-                       mcl->op = __HYPERVISOR_mmu_update;
-                       mcl->args[0] = (unsigned long)np->rx_mmu;
-                       mcl->args[1] = mmu - np->rx_mmu;
-                       mcl->args[2] = 0;
-                       mcl->args[3] = DOMID_SELF;
-                       mcl++;
+                       MULTI_mmu_update(mcl, np->rx_mmu, mmu - np->rx_mmu,
+                                        0, DOMID_SELF);
                        rc = HYPERVISOR_multicall_check(
-                               np->rx_mcl, mcl - np->rx_mcl, NULL);
+                               np->rx_mcl, mcl + 1 - np->rx_mcl, NULL);
                        BUG_ON(rc);
                }
        }
diff -r 07b22ab8d245 -r b72a53f5d756 include/asm-i386/mach-xen/asm/hypervisor.h
--- a/include/asm-i386/mach-xen/asm/hypervisor.h        Mon Jun 04 10:38:05 
2012 +0200
+++ b/include/asm-i386/mach-xen/asm/hypervisor.h        Mon Jun 04 10:55:00 
2012 +0200
@@ -243,6 +243,26 @@ MULTI_update_va_mapping(
 }
 
 static inline void
+MULTI_mmu_update(multicall_entry_t *mcl, mmu_update_t *req,
+                unsigned int count, unsigned int *success_count,
+                domid_t domid)
+{
+    mcl->op = __HYPERVISOR_mmu_update;
+    mcl->args[0] = (unsigned long)req;
+    mcl->args[1] = count;
+    mcl->args[2] = (unsigned long)success_count;
+    mcl->args[3] = domid;
+}
+
+static inline void
+MULTI_memory_op(multicall_entry_t *mcl, unsigned int cmd, void *arg)
+{
+       mcl->op = __HYPERVISOR_memory_op;
+       mcl->args[0] = cmd;
+       mcl->args[1] = (unsigned long)arg;
+}
+
+static inline void
 MULTI_grant_table_op(multicall_entry_t *mcl, unsigned int cmd,
                     void *uop, unsigned int count)
 {
@@ -255,8 +275,15 @@ MULTI_grant_table_op(multicall_entry_t *
 #else /* !defined(CONFIG_XEN) */
 
 /* Multicalls not supported for HVM guests. */
-#define MULTI_update_va_mapping(a,b,c,d) ((void)0)
-#define MULTI_grant_table_op(a,b,c,d) ((void)0)
+static inline void MULTI_bug(multicall_entry_t *mcl, ...)
+{
+       BUG_ON(mcl);
+}
+
+#define MULTI_update_va_mapping        MULTI_bug
+#define MULTI_mmu_update       MULTI_bug
+#define MULTI_memory_op                MULTI_bug
+#define MULTI_grant_table_op   MULTI_bug
 
 #endif
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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