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

[Xen-changelog] [xen-unstable] linux: remove {lock, unlock}_vm_area(). Instead use vmalloc_sync_all()



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1171625050 0
# Node ID c4ed5b740a8db26a54425cdd252527aef4a9d234
# Parent  cd03d7c23aa7e8e1e8598f06cbe55f647f2a4c9b
linux: remove {lock,unlock}_vm_area(). Instead use vmalloc_sync_all()
in alloc_vm_area().
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/arch/ia64/xen/util.c                       |   12 ----
 linux-2.6-xen-sparse/drivers/xen/blkback/interface.c            |   14 +---
 linux-2.6-xen-sparse/drivers/xen/blktap/interface.c             |   14 +---
 linux-2.6-xen-sparse/drivers/xen/netback/interface.c            |   26 ++------
 linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c            |   14 +---
 linux-2.6-xen-sparse/drivers/xen/util.c                         |   29 
+---------
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c |   16 ++---
 linux-2.6-xen-sparse/include/xen/driver_util.h                  |    4 -
 8 files changed, 31 insertions(+), 98 deletions(-)

diff -r cd03d7c23aa7 -r c4ed5b740a8d linux-2.6-xen-sparse/arch/ia64/xen/util.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/util.c Fri Feb 16 09:57:25 2007 +0000
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/util.c Fri Feb 16 11:24:10 2007 +0000
@@ -95,18 +95,6 @@ void free_vm_area(struct vm_struct *area
 }
 EXPORT_SYMBOL_GPL(free_vm_area);
 
-void lock_vm_area(struct vm_struct *area)
-{
-       // nothing
-}
-EXPORT_SYMBOL_GPL(lock_vm_area);
-
-void unlock_vm_area(struct vm_struct *area)
-{
-       // nothing
-}
-EXPORT_SYMBOL_GPL(unlock_vm_area);
-
 /*
  * Local variables:
  *  c-file-style: "linux"
diff -r cd03d7c23aa7 -r c4ed5b740a8d 
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Fri Feb 16 
09:57:25 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Fri Feb 16 
11:24:10 2007 +0000
@@ -58,15 +58,12 @@ static int map_frontend_page(blkif_t *bl
 static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
 {
        struct gnttab_map_grant_ref op;
-       int ret;
 
        gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
                          GNTMAP_host_map, shared_page, blkif->domid);
 
-       lock_vm_area(blkif->blk_ring_area);
-       ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-       unlock_vm_area(blkif->blk_ring_area);
-       BUG_ON(ret);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
+               BUG();
 
        if (op.status) {
                DPRINTK(" Grant table operation failure !\n");
@@ -82,15 +79,12 @@ static void unmap_frontend_page(blkif_t 
 static void unmap_frontend_page(blkif_t *blkif)
 {
        struct gnttab_unmap_grant_ref op;
-       int ret;
 
        gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
                            GNTMAP_host_map, blkif->shmem_handle);
 
-       lock_vm_area(blkif->blk_ring_area);
-       ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-       unlock_vm_area(blkif->blk_ring_area);
-       BUG_ON(ret);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
+               BUG();
 }
 
 int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
diff -r cd03d7c23aa7 -r c4ed5b740a8d 
linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Fri Feb 16 
09:57:25 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Fri Feb 16 
11:24:10 2007 +0000
@@ -58,15 +58,12 @@ static int map_frontend_page(blkif_t *bl
 static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
 {
        struct gnttab_map_grant_ref op;
-       int ret;
 
        gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
                          GNTMAP_host_map, shared_page, blkif->domid);
 
-       lock_vm_area(blkif->blk_ring_area);
-       ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-       unlock_vm_area(blkif->blk_ring_area);
-       BUG_ON(ret);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
+               BUG();
 
        if (op.status) {
                DPRINTK(" Grant table operation failure !\n");
@@ -82,15 +79,12 @@ static void unmap_frontend_page(blkif_t 
 static void unmap_frontend_page(blkif_t *blkif)
 {
        struct gnttab_unmap_grant_ref op;
-       int ret;
 
        gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
                            GNTMAP_host_map, blkif->shmem_handle);
 
-       lock_vm_area(blkif->blk_ring_area);
-       ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-       unlock_vm_area(blkif->blk_ring_area);
-       BUG_ON(ret);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
+               BUG();
 }
 
 int tap_blkif_map(blkif_t *blkif, unsigned long shared_page, 
diff -r cd03d7c23aa7 -r c4ed5b740a8d 
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Fri Feb 16 
09:57:25 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Fri Feb 16 
11:24:10 2007 +0000
@@ -194,15 +194,12 @@ static int map_frontend_pages(
        netif_t *netif, grant_ref_t tx_ring_ref, grant_ref_t rx_ring_ref)
 {
        struct gnttab_map_grant_ref op;
-       int ret;
 
        gnttab_set_map_op(&op, (unsigned long)netif->tx_comms_area->addr,
                          GNTMAP_host_map, tx_ring_ref, netif->domid);
     
-       lock_vm_area(netif->tx_comms_area);
-       ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-       unlock_vm_area(netif->tx_comms_area);
-       BUG_ON(ret);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
+               BUG();
 
        if (op.status) { 
                DPRINTK(" Gnttab failure mapping tx_ring_ref!\n");
@@ -215,10 +212,8 @@ static int map_frontend_pages(
        gnttab_set_map_op(&op, (unsigned long)netif->rx_comms_area->addr,
                          GNTMAP_host_map, rx_ring_ref, netif->domid);
 
-       lock_vm_area(netif->rx_comms_area);
-       ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-       unlock_vm_area(netif->rx_comms_area);
-       BUG_ON(ret);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
+               BUG();
 
        if (op.status) {
                DPRINTK(" Gnttab failure mapping rx_ring_ref!\n");
@@ -234,23 +229,18 @@ static void unmap_frontend_pages(netif_t
 static void unmap_frontend_pages(netif_t *netif)
 {
        struct gnttab_unmap_grant_ref op;
-       int ret;
 
        gnttab_set_unmap_op(&op, (unsigned long)netif->tx_comms_area->addr,
                            GNTMAP_host_map, netif->tx_shmem_handle);
 
-       lock_vm_area(netif->tx_comms_area);
-       ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-       unlock_vm_area(netif->tx_comms_area);
-       BUG_ON(ret);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
+               BUG();
 
        gnttab_set_unmap_op(&op, (unsigned long)netif->rx_comms_area->addr,
                            GNTMAP_host_map, netif->rx_shmem_handle);
 
-       lock_vm_area(netif->rx_comms_area);
-       ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-       unlock_vm_area(netif->rx_comms_area);
-       BUG_ON(ret);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
+               BUG();
 }
 
 int netif_map(netif_t *netif, unsigned long tx_ring_ref,
diff -r cd03d7c23aa7 -r c4ed5b740a8d 
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Fri Feb 16 
09:57:25 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Fri Feb 16 
11:24:10 2007 +0000
@@ -79,16 +79,13 @@ tpmif_t *tpmif_find(domid_t domid, struc
 
 static int map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
 {
-       int ret;
        struct gnttab_map_grant_ref op;
 
        gnttab_set_map_op(&op, (unsigned long)tpmif->tx_area->addr,
                          GNTMAP_host_map, shared_page, tpmif->domid);
 
-       lock_vm_area(tpmif->tx_area);
-       ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-       unlock_vm_area(tpmif->tx_area);
-       BUG_ON(ret);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
+               BUG();
 
        if (op.status) {
                DPRINTK(" Grant table operation failure !\n");
@@ -104,15 +101,12 @@ static void unmap_frontend_page(tpmif_t 
 static void unmap_frontend_page(tpmif_t *tpmif)
 {
        struct gnttab_unmap_grant_ref op;
-       int ret;
 
        gnttab_set_unmap_op(&op, (unsigned long)tpmif->tx_area->addr,
                            GNTMAP_host_map, tpmif->shmem_handle);
 
-       lock_vm_area(tpmif->tx_area);
-       ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-       unlock_vm_area(tpmif->tx_area);
-       BUG_ON(ret);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
+               BUG();
 }
 
 int tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn)
diff -r cd03d7c23aa7 -r c4ed5b740a8d linux-2.6-xen-sparse/drivers/xen/util.c
--- a/linux-2.6-xen-sparse/drivers/xen/util.c   Fri Feb 16 09:57:25 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/util.c   Fri Feb 16 11:24:10 2007 +0000
@@ -30,6 +30,9 @@ struct vm_struct *alloc_vm_area(unsigned
                return NULL;
        }
 
+       /* Map page directories into every address space. */
+       vmalloc_sync_all();
+
        return area;
 }
 EXPORT_SYMBOL_GPL(alloc_vm_area);
@@ -42,29 +45,3 @@ void free_vm_area(struct vm_struct *area
        kfree(area);
 }
 EXPORT_SYMBOL_GPL(free_vm_area);
-
-void lock_vm_area(struct vm_struct *area)
-{
-       unsigned long i;
-       char c;
-
-       /*
-        * Prevent context switch to a lazy mm that doesn't have this area
-        * mapped into its page tables.
-        */
-       preempt_disable();
-
-       /*
-        * Ensure that the page tables are mapped into the current mm. The
-        * page-fault path will copy the page directory pointers from init_mm.
-        */
-       for (i = 0; i < area->size; i += PAGE_SIZE)
-               (void)__get_user(c, (char __user *)area->addr + i);
-}
-EXPORT_SYMBOL_GPL(lock_vm_area);
-
-void unlock_vm_area(struct vm_struct *area)
-{
-       preempt_enable();
-}
-EXPORT_SYMBOL_GPL(unlock_vm_area);
diff -r cd03d7c23aa7 -r c4ed5b740a8d 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c   Fri Feb 
16 09:57:25 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c   Fri Feb 
16 11:24:10 2007 +0000
@@ -48,9 +48,8 @@ struct vm_struct *xenbus_map_ring_valloc
        gnttab_set_map_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
                          gnt_ref, dev->otherend_id);
        
-       lock_vm_area(area);
-       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
-       unlock_vm_area(area);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
+               BUG();
 
        if (op.status != GNTST_okay) {
                free_vm_area(area);
@@ -76,7 +75,8 @@ int xenbus_map_ring(struct xenbus_device
        
        gnttab_set_map_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
                          gnt_ref, dev->otherend_id);
-       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
+       if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
+               BUG();
 
        if (op.status != GNTST_okay) {
                xenbus_dev_fatal(dev, op.status,
@@ -98,9 +98,8 @@ int xenbus_unmap_ring_vfree(struct xenbu
        gnttab_set_unmap_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
                            (grant_handle_t)area->phys_addr);
 
-       lock_vm_area(area);
-       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
-       unlock_vm_area(area);
+       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
+               BUG();
 
        if (op.status == GNTST_okay)
                free_vm_area(area);
@@ -121,7 +120,8 @@ int xenbus_unmap_ring(struct xenbus_devi
 
        gnttab_set_unmap_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
                            handle);
-       BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
+       if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
+               BUG();
 
        if (op.status != GNTST_okay)
                xenbus_dev_error(dev, op.status,
diff -r cd03d7c23aa7 -r c4ed5b740a8d 
linux-2.6-xen-sparse/include/xen/driver_util.h
--- a/linux-2.6-xen-sparse/include/xen/driver_util.h    Fri Feb 16 09:57:25 
2007 +0000
+++ b/linux-2.6-xen-sparse/include/xen/driver_util.h    Fri Feb 16 11:24:10 
2007 +0000
@@ -9,8 +9,4 @@ extern struct vm_struct *alloc_vm_area(u
 extern struct vm_struct *alloc_vm_area(unsigned long size);
 extern void free_vm_area(struct vm_struct *area);
 
-/* Lock an area so that PTEs are accessible in the current address space. */
-extern void lock_vm_area(struct vm_struct *area);
-extern void unlock_vm_area(struct vm_struct *area);
-
 #endif /* __ASM_XEN_DRIVER_UTIL_H__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
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®.