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

[Xen-devel] [PATCH 01 of 18] libxc: flask: use (un)lock pages rather than open coding m(un)lock



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1286892401 -3600
# Node ID 73a05c8f7c3ec924c7a334a8840b54fcba31c3c1
# Parent  b5ed73f6f9b57d90dd3816f20594977e240497c1
libxc: flask: use (un)lock pages rather than open coding m(un)lock.

Allows us to do away with safe_unlock and merge into unlock_pages.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r b5ed73f6f9b5 -r 73a05c8f7c3e tools/libxc/xc_flask.c
--- a/tools/libxc/xc_flask.c    Tue Oct 12 15:06:41 2010 +0100
+++ b/tools/libxc/xc_flask.c    Tue Oct 12 15:06:41 2010 +0100
@@ -44,7 +44,7 @@ int xc_flask_op(xc_interface *xch, flask
     hypercall.op     = __HYPERVISOR_xsm_op;
     hypercall.arg[0] = (unsigned long)op;
 
-    if ( mlock(op, sizeof(*op)) != 0 )
+    if ( lock_pages(op, sizeof(*op)) != 0 )
     {
         PERROR("Could not lock memory for Xen hypercall");
         goto out;
@@ -56,7 +56,7 @@ int xc_flask_op(xc_interface *xch, flask
             fprintf(stderr, "XSM operation failed!\n");
     }
 
-    safe_munlock(op, sizeof(*op));
+    unlock_pages(op, sizeof(*op));
 
  out:
     return ret;
diff -r b5ed73f6f9b5 -r 73a05c8f7c3e tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Tue Oct 12 15:06:41 2010 +0100
+++ b/tools/libxc/xc_private.c  Tue Oct 12 15:06:41 2010 +0100
@@ -218,7 +218,9 @@ void unlock_pages(void *addr, size_t len
     void *laddr = (void *)((unsigned long)addr & PAGE_MASK);
     size_t llen = (len + ((unsigned long)addr - (unsigned long)laddr) +
                    PAGE_SIZE - 1) & PAGE_MASK;
-    safe_munlock(laddr, llen);
+    int saved_errno = errno;
+    (void)munlock(laddr, llen);
+    errno = saved_errno;
 }
 
 static pthread_key_t hcall_buf_pkey;
diff -r b5ed73f6f9b5 -r 73a05c8f7c3e tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h  Tue Oct 12 15:06:41 2010 +0100
+++ b/tools/libxc/xc_private.h  Tue Oct 12 15:06:41 2010 +0100
@@ -105,13 +105,6 @@ void unlock_pages(void *addr, size_t len
 
 int hcall_buf_prep(void **addr, size_t len);
 void hcall_buf_release(void **addr, size_t len);
-
-static inline void safe_munlock(const void *addr, size_t len)
-{
-    int saved_errno = errno;
-    (void)munlock(addr, len);
-    errno = saved_errno;
-}
 
 int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall);
 

_______________________________________________
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®.