]> xenbits.xensource.com Git - people/gdunlap/xen.git/commitdiff
make two memory hypercalls vNUMA-aware
authorWei Liu <wei.liu2@citrix.com>
Tue, 17 Mar 2015 10:03:29 +0000 (11:03 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 17 Mar 2015 10:03:29 +0000 (11:03 +0100)
Make XENMEM_increase_reservation and XENMEM_populate_physmap
vNUMA-aware.

That is, if guest requests Xen to allocate memory for specific vnode,
Xen can translate vnode to pnode using vNUMA information of that guest.

XENMEMF_vnode is introduced for the guest to mark the node number is in
fact virtual node number and should be translated by Xen.

XENFEAT_memory_op_vnode_supported is introduced to indicate that Xen is
able to translate virtual node to physical node.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Hand struct domain via struct memops_arg's respective field to
construct_memop_from_reservation().

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen/common/kernel.c
xen/common/memory.c
xen/include/public/features.h
xen/include/public/memory.h

index f63de10c342ddac38bfe64efe4ceaae0d01ad6d0..d8c31bc89f580681fb803334dc5e8b0e1f2e7052 100644 (file)
@@ -305,7 +305,7 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         switch ( fi.submap_idx )
         {
         case 0:
-            fi.submap = 0;
+            fi.submap = (1U << XENFEAT_memory_op_vnode_supported);
             if ( VM_ASSIST(d, VMASST_TYPE_pae_extended_cr3) )
                 fi.submap |= (1U << XENFEAT_pae_pgdir_above_4gb);
             if ( paging_mode_translate(d) )
index 60432ecaa0d799a4179de04aea357de09c593b86..063a1c52204a77e535a6fc2c0606e1b71861dd45 100644 (file)
@@ -713,9 +713,37 @@ static int construct_memop_from_reservation(
         a->memflags = MEMF_bits(address_bits);
     }
 
-    a->memflags |= MEMF_node(XENMEMF_get_node(r->mem_flags));
-    if ( r->mem_flags & XENMEMF_exact_node_request )
-        a->memflags |= MEMF_exact_node;
+    if ( r->mem_flags & XENMEMF_vnode )
+    {
+        nodeid_t vnode, pnode;
+        struct domain *d = a->domain;
+
+        read_lock(&d->vnuma_rwlock);
+        if ( d->vnuma )
+        {
+            vnode = XENMEMF_get_node(r->mem_flags);
+            if ( vnode >= d->vnuma->nr_vnodes )
+            {
+                read_unlock(&d->vnuma_rwlock);
+                return -EINVAL;
+            }
+
+            pnode = d->vnuma->vnode_to_pnode[vnode];
+            if ( pnode != NUMA_NO_NODE )
+            {
+                a->memflags |= MEMF_node(pnode);
+                if ( r->mem_flags & XENMEMF_exact_node_request )
+                    a->memflags |= MEMF_exact_node;
+            }
+        }
+        read_unlock(&d->vnuma_rwlock);
+    }
+    else
+    {
+        a->memflags |= MEMF_node(XENMEMF_get_node(r->mem_flags));
+        if ( r->mem_flags & XENMEMF_exact_node_request )
+            a->memflags |= MEMF_exact_node;
+    }
 
     return 0;
 }
@@ -745,21 +773,24 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( unlikely(start_extent >= reservation.nr_extents) )
             return start_extent;
 
+        d = rcu_lock_domain_by_any_id(reservation.domid);
+        if ( d == NULL )
+            return start_extent;
+        args.domain = d;
+
         if ( construct_memop_from_reservation(&reservation, &args) )
+        {
+            rcu_unlock_domain(d);
             return start_extent;
-        args.nr_done      = start_extent;
-        args.preempted    = 0;
+        }
 
+        args.nr_done   = start_extent;
+        args.preempted = 0;
 
         if ( op == XENMEM_populate_physmap
              && (reservation.mem_flags & XENMEMF_populate_on_demand) )
             args.memflags |= MEMF_populate_on_demand;
 
-        d = rcu_lock_domain_by_any_id(reservation.domid);
-        if ( d == NULL )
-            return start_extent;
-        args.domain = d;
-
         if ( xsm_memory_adjust_reservation(XSM_TARGET, current->domain, d) )
         {
             rcu_unlock_domain(d);
index 16d92aa8167f25a9445f6b132b2a74c587179628..2110b04554031b7bc7e6c160c5ab0f8a461b0023 100644 (file)
@@ -99,6 +99,9 @@
 #define XENFEAT_grant_map_identity        12
  */
 
+/* Guest can use XENMEMF_vnode to specify virtual node for memory op. */
+#define XENFEAT_memory_op_vnode_supported 13
+
 #define XENFEAT_NR_SUBMAPS 1
 
 #endif /* __XEN_PUBLIC_FEATURES_H__ */
index 595f953aea1528a690470558f38b9f64c82344b2..2b5206bfe2a6e9f5dc9764d270812a3e8597e688 100644 (file)
@@ -55,6 +55,8 @@
 /* Flag to request allocation only from the node specified */
 #define XENMEMF_exact_node_request  (1<<17)
 #define XENMEMF_exact_node(n) (XENMEMF_node(n) | XENMEMF_exact_node_request)
+/* Flag to indicate the node specified is virtual node */
+#define XENMEMF_vnode  (1<<18)
 #endif
 
 struct xen_memory_reservation {