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

[Xen-devel] [PATCH] grant-table: don't set m2p override if kmap_ops is not set



IMHO there's no reason to set a m2p override if the mapping is done in
kernel space, so only set the m2p override when kmap_ops is set.

When kmap_ops is not set, just set the correct p2m translation, this
avoids touching the m2p lock, reducing contention around it.

Signed-off-by: Roger Pau Monnà <roger.pau@xxxxxxxxxx>
Reported-by: Matt Wilson <msw@xxxxxxxxxx>
Cc: Matt Wilson <msw@xxxxxxxxxx>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Cc: David Vrabel <david.vrabel@xxxxxxxxxx>
Cc: Boris Ostrovsky <david.vrabel@xxxxxxxxxx>
---
 drivers/xen/grant-table.c |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 04cdeb8..ebf7126 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -909,8 +909,19 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
                } else {
                        mfn = PFN_DOWN(map_ops[i].dev_bus_addr);
                }
-               ret = m2p_add_override(mfn, pages[i], kmap_ops ?
-                                      &kmap_ops[i] : NULL);
+
+               if (kmap_ops) {
+                       ret = m2p_add_override(mfn, pages[i], &kmap_ops[i]);
+               } else {
+                       /* No need to set the m2p override, just set p2m */
+                       WARN_ON(PagePrivate(pages[i]));
+                       SetPagePrivate(pages[i]);
+                       set_page_private(pages[i], mfn);
+
+                       if 
(unlikely(!set_phys_to_machine(page_to_pfn(pages[i]), FOREIGN_FRAME(mfn))))
+                               ret = -ENOMEM;
+               }
+
                if (ret)
                        return ret;
        }
@@ -942,8 +953,19 @@ int gnttab_unmap_refs(struct gnttab_unmap_grant_ref 
*unmap_ops,
        }
 
        for (i = 0; i < count; i++) {
-               ret = m2p_remove_override(pages[i], kmap_ops ?
-                                      &kmap_ops[i] : NULL);
+               if (kmap_ops) {
+                       ret = m2p_remove_override(pages[i], &kmap_ops[i]);
+               } else {
+                       /* Remove p2m entry */
+                       unsigned long mfn;
+
+                       WARN_ON(!PagePrivate(pages[i]));
+                       mfn = page_private(pages[i]);
+                       ClearPagePrivate(pages[i]);
+
+                       if 
(unlikely(!set_phys_to_machine(page_to_pfn(pages[i]), mfn)))
+                               ret = -ENOMEM;
+               }
                if (ret)
                        return ret;
        }
-- 
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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