WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] numa: Extend MEMOP_ allocation functions

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] numa: Extend MEMOP_ allocation functions to take a node argument.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 06 Jul 2008 14:00:12 -0700
Delivery-date: Sun, 06 Jul 2008 14:00:22 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1215265417 -3600
# Node ID 4bdc3de246c3d9660187db9bf7ec328668771d4b
# Parent  5b7e60d70394db5541100ae5d88829415b04509d
numa: Extend MEMOP_ allocation functions to take a node argument.

The address_bits field will be limited to 8 bits and is now embedded
in the mem_flags member, which additionally contains the node number
(limited to 8 bit).

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/ioemu/vl.c                  |    5 +++--
 tools/libxc/xc_domain.c           |   22 +++++++++++-----------
 tools/libxc/xc_private.c          |    2 +-
 tools/libxc/xenctrl.h             |    4 ++--
 tools/python/xen/lowlevel/xc/xc.c |   34 ----------------------------------
 xen/common/memory.c               |   31 ++++++++++++++++---------------
 xen/common/page_alloc.c           |    3 +++
 xen/include/public/memory.h       |   26 ++++++++++++++++++++------
 xen/include/public/xen-compat.h   |    2 +-
 9 files changed, 57 insertions(+), 72 deletions(-)

diff -r 5b7e60d70394 -r 4bdc3de246c3 tools/ioemu/vl.c
--- a/tools/ioemu/vl.c  Sat Jul 05 14:42:08 2008 +0100
+++ b/tools/ioemu/vl.c  Sat Jul 05 14:43:37 2008 +0100
@@ -7044,8 +7044,9 @@ int set_mm_mapping(int xc_handle, uint32
 {
     int err = 0;
 
-    err = xc_domain_memory_populate_physmap(xc_handle, domid, nr_pages, 0,
-                                            address_bits, extent_start);
+    err = xc_domain_memory_populate_physmap(
+        xc_handle, domid, nr_pages, 0,
+        XENMEMF_address_bits(address_bits), extent_start);
     if (err) {
         fprintf(stderr, "Failed to populate physmap\n");
         return -1;
diff -r 5b7e60d70394 -r 4bdc3de246c3 tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Sat Jul 05 14:42:08 2008 +0100
+++ b/tools/libxc/xc_domain.c   Sat Jul 05 14:43:37 2008 +0100
@@ -438,14 +438,14 @@ int xc_domain_memory_increase_reservatio
                                           uint32_t domid,
                                           unsigned long nr_extents,
                                           unsigned int extent_order,
-                                          unsigned int address_bits,
+                                          unsigned int mem_flags,
                                           xen_pfn_t *extent_start)
 {
     int err;
     struct xen_memory_reservation reservation = {
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
-        .address_bits = address_bits,
+        .mem_flags    = mem_flags,
         .domid        = domid
     };
 
@@ -459,8 +459,8 @@ int xc_domain_memory_increase_reservatio
     if ( err >= 0 )
     {
         DPRINTF("Failed allocation for dom %d: "
-                "%ld extents of order %d, addr_bits %d\n",
-                domid, nr_extents, extent_order, address_bits);
+                "%ld extents of order %d, mem_flags %x\n",
+                domid, nr_extents, extent_order, mem_flags);
         errno = ENOMEM;
         err = -1;
     }
@@ -478,7 +478,7 @@ int xc_domain_memory_decrease_reservatio
     struct xen_memory_reservation reservation = {
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
-        .address_bits = 0,
+        .mem_flags    = 0,
         .domid        = domid
     };
 
@@ -507,17 +507,17 @@ int xc_domain_memory_decrease_reservatio
 }
 
 int xc_domain_memory_populate_physmap(int xc_handle,
-                                          uint32_t domid,
-                                          unsigned long nr_extents,
-                                          unsigned int extent_order,
-                                          unsigned int address_bits,
-                                          xen_pfn_t *extent_start)
+                                      uint32_t domid,
+                                      unsigned long nr_extents,
+                                      unsigned int extent_order,
+                                      unsigned int mem_flags,
+                                      xen_pfn_t *extent_start)
 {
     int err;
     struct xen_memory_reservation reservation = {
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
-        .address_bits = address_bits,
+        .mem_flags    = mem_flags,
         .domid        = domid
     };
     set_xen_guest_handle(reservation.extent_start, extent_start);
diff -r 5b7e60d70394 -r 4bdc3de246c3 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Sat Jul 05 14:42:08 2008 +0100
+++ b/tools/libxc/xc_private.c  Sat Jul 05 14:43:37 2008 +0100
@@ -501,7 +501,7 @@ unsigned long xc_make_page_below_4G(
     }
 
     if ( xc_domain_memory_increase_reservation(
-        xc_handle, domid, 1, 0, 32, &new_mfn) != 0 )
+        xc_handle, domid, 1, 0, XENMEMF_address_bits(32), &new_mfn) != 0 )
     {
         DPRINTF("xc_make_page_below_4G increase failed. mfn=%lx\n",mfn);
         return 0;
diff -r 5b7e60d70394 -r 4bdc3de246c3 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Sat Jul 05 14:42:08 2008 +0100
+++ b/tools/libxc/xenctrl.h     Sat Jul 05 14:43:37 2008 +0100
@@ -611,7 +611,7 @@ int xc_domain_memory_increase_reservatio
                                           uint32_t domid,
                                           unsigned long nr_extents,
                                           unsigned int extent_order,
-                                          unsigned int address_bits,
+                                          unsigned int mem_flags,
                                           xen_pfn_t *extent_start);
 
 int xc_domain_memory_decrease_reservation(int xc_handle,
@@ -624,7 +624,7 @@ int xc_domain_memory_populate_physmap(in
                                       uint32_t domid,
                                       unsigned long nr_extents,
                                       unsigned int extent_order,
-                                      unsigned int address_bits,
+                                      unsigned int mem_flags,
                                       xen_pfn_t *extent_start);
 
 int xc_domain_ioport_permission(int xc_handle,
diff -r 5b7e60d70394 -r 4bdc3de246c3 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Sat Jul 05 14:42:08 2008 +0100
+++ b/tools/python/xen/lowlevel/xc/xc.c Sat Jul 05 14:43:37 2008 +0100
@@ -1317,33 +1317,6 @@ static PyObject *pyxc_domain_set_memmap_
     return zero;
 }
 
-static PyObject *pyxc_domain_memory_increase_reservation(XcObject *self,
-                                                         PyObject *args,
-                                                         PyObject *kwds)
-{
-    uint32_t dom;
-    unsigned long mem_kb;
-    unsigned int extent_order = 0 , address_bits = 0;
-    unsigned long nr_extents;
-
-    static char *kwd_list[] = { "domid", "mem_kb", "extent_order", 
"address_bits", NULL };
-
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "il|ii", kwd_list, 
-                                      &dom, &mem_kb, &extent_order, 
&address_bits) )
-        return NULL;
-
-    /* round down to nearest power of 2. Assume callers using extent_order>0
-       know what they are doing */
-    nr_extents = (mem_kb / (XC_PAGE_SIZE/1024)) >> extent_order;
-    if ( xc_domain_memory_increase_reservation(self->xc_handle, dom, 
-                                               nr_extents, extent_order, 
-                                               address_bits, NULL) )
-        return pyxc_error_to_exception();
-    
-    Py_INCREF(zero);
-    return zero;
-}
-
 static PyObject *pyxc_domain_ioport_permission(XcObject *self,
                                                PyObject *args,
                                                PyObject *kwds)
@@ -1817,13 +1790,6 @@ static PyMethodDef pyxc_methods[] = {
       " map_limitkb [int]: .\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
-    { "domain_memory_increase_reservation", 
-      (PyCFunction)pyxc_domain_memory_increase_reservation, 
-      METH_VARARGS | METH_KEYWORDS, "\n"
-      "Increase a domain's memory reservation\n"
-      " dom [int]: Identifier of domain.\n"
-      " mem_kb [long]: .\n"
-      "Returns: [int] 0 on success; -1 on error.\n" },
 #ifdef __ia64__
     { "nvram_init",
       (PyCFunction)pyxc_nvram_init,
diff -r 5b7e60d70394 -r 4bdc3de246c3 xen/common/memory.c
--- a/xen/common/memory.c       Sat Jul 05 14:42:08 2008 +0100
+++ b/xen/common/memory.c       Sat Jul 05 14:43:37 2008 +0100
@@ -44,7 +44,6 @@ static void increase_reservation(struct 
     unsigned long i;
     xen_pfn_t mfn;
     struct domain *d = a->domain;
-    unsigned int node = domain_to_node(d);
 
     if ( !guest_handle_is_null(a->extent_list) &&
          !guest_handle_subrange_okay(a->extent_list, a->nr_done,
@@ -63,8 +62,7 @@ static void increase_reservation(struct 
             goto out;
         }
 
-        page = alloc_domheap_pages(
-            d, a->extent_order, a->memflags | MEMF_node(node));
+        page = alloc_domheap_pages(d, a->extent_order, a->memflags);
         if ( unlikely(page == NULL) ) 
         {
             gdprintk(XENLOG_INFO, "Could not allocate order=%d extent: "
@@ -93,7 +91,6 @@ static void populate_physmap(struct memo
     unsigned long i, j;
     xen_pfn_t gpfn, mfn;
     struct domain *d = a->domain;
-    unsigned int node = domain_to_node(d);
 
     if ( !guest_handle_subrange_okay(a->extent_list, a->nr_done,
                                      a->nr_extents-1) )
@@ -114,8 +111,7 @@ static void populate_physmap(struct memo
         if ( unlikely(__copy_from_guest_offset(&gpfn, a->extent_list, i, 1)) )
             goto out;
 
-        page = alloc_domheap_pages(
-            d, a->extent_order, a->memflags | MEMF_node(node));
+        page = alloc_domheap_pages(d, a->extent_order, a->memflags);
         if ( unlikely(page == NULL) ) 
         {
             gdprintk(XENLOG_INFO, "Could not allocate order=%d extent: "
@@ -345,8 +341,10 @@ static long memory_exchange(XEN_GUEST_HA
     d = current->domain;
 
     memflags |= MEMF_bits(domain_clamp_alloc_bitsize(
-        d, exch.out.address_bits ? : (BITS_PER_LONG+PAGE_SHIFT)));
-    memflags |= MEMF_node(domain_to_node(d));
+        d,
+        XENMEMF_get_address_bits(exch.out.mem_flags) ? :
+        (BITS_PER_LONG+PAGE_SHIFT)));
+    memflags |= MEMF_node(XENMEMF_get_node(exch.out.mem_flags));
 
     for ( i = (exch.nr_exchanged >> in_chunk_order);
           i < (exch.in.nr_extents >> in_chunk_order);
@@ -490,6 +488,7 @@ long do_memory_op(unsigned long cmd, XEN
 {
     struct domain *d;
     int rc, op;
+    unsigned int address_bits;
     unsigned long start_extent, progress;
     struct xen_memory_reservation reservation;
     struct memop_args args;
@@ -521,14 +520,16 @@ long do_memory_op(unsigned long cmd, XEN
         args.preempted    = 0;
         args.memflags     = 0;
 
-        if ( (reservation.address_bits != 0) &&
-             (reservation.address_bits <
-              (get_order_from_pages(max_page) + PAGE_SHIFT)) )
-        {
-            if ( reservation.address_bits <= PAGE_SHIFT )
+        address_bits = XENMEMF_get_address_bits(reservation.mem_flags);
+        if ( (address_bits != 0) &&
+             (address_bits < (get_order_from_pages(max_page) + PAGE_SHIFT)) )
+        {
+            if ( address_bits <= PAGE_SHIFT )
                 return start_extent;
-            args.memflags = MEMF_bits(reservation.address_bits);
-        }
+            args.memflags = MEMF_bits(address_bits);
+        }
+
+        args.memflags |= MEMF_node(XENMEMF_get_node(reservation.mem_flags));
 
         if ( likely(reservation.domid == DOMID_SELF) )
         {
diff -r 5b7e60d70394 -r 4bdc3de246c3 xen/common/page_alloc.c
--- a/xen/common/page_alloc.c   Sat Jul 05 14:42:08 2008 +0100
+++ b/xen/common/page_alloc.c   Sat Jul 05 14:43:37 2008 +0100
@@ -792,6 +792,9 @@ struct page_info *alloc_domheap_pages(
 
     ASSERT(!in_irq());
 
+    if ( node == NUMA_NO_NODE )
+        node = domain_to_node(d);
+
     bits = domain_clamp_alloc_bitsize(d, bits ? : (BITS_PER_LONG+PAGE_SHIFT));
     if ( bits <= (PAGE_SHIFT + 1) )
         return NULL;
diff -r 5b7e60d70394 -r 4bdc3de246c3 xen/include/public/memory.h
--- a/xen/include/public/memory.h       Sat Jul 05 14:42:08 2008 +0100
+++ b/xen/include/public/memory.h       Sat Jul 05 14:43:37 2008 +0100
@@ -35,6 +35,21 @@
 #define XENMEM_increase_reservation 0
 #define XENMEM_decrease_reservation 1
 #define XENMEM_populate_physmap     6
+
+#if __XEN_INTERFACE_VERSION__ >= 0x00030209
+/*
+ * Maximum # bits addressable by the user of the allocated region (e.g., I/O 
+ * devices often have a 32-bit limitation even in 64-bit systems). If zero 
+ * then the user has no addressing restriction. This field is not used by 
+ * XENMEM_decrease_reservation.
+ */
+#define XENMEMF_address_bits(x)     (x)
+#define XENMEMF_get_address_bits(x) ((x) & 0xffu)
+/* NUMA node to allocate from. */
+#define XENMEMF_node(x)     (((x) + 1) << 8)
+#define XENMEMF_get_node(x) ((((x) >> 8) - 1) & 0xffu)
+#endif
+
 struct xen_memory_reservation {
 
     /*
@@ -53,13 +68,12 @@ struct xen_memory_reservation {
     xen_ulong_t    nr_extents;
     unsigned int   extent_order;
 
-    /*
-     * Maximum # bits addressable by the user of the allocated region (e.g., 
-     * I/O devices often have a 32-bit limitation even in 64-bit systems). If 
-     * zero then the user has no addressing restriction.
-     * This field is not used by XENMEM_decrease_reservation.
-     */
+#if __XEN_INTERFACE_VERSION__ >= 0x00030209
+    /* XENMEMF flags. */
+    unsigned int   mem_flags;
+#else
     unsigned int   address_bits;
+#endif
 
     /*
      * Domain whose reservation is being changed.
diff -r 5b7e60d70394 -r 4bdc3de246c3 xen/include/public/xen-compat.h
--- a/xen/include/public/xen-compat.h   Sat Jul 05 14:42:08 2008 +0100
+++ b/xen/include/public/xen-compat.h   Sat Jul 05 14:43:37 2008 +0100
@@ -27,7 +27,7 @@
 #ifndef __XEN_PUBLIC_XEN_COMPAT_H__
 #define __XEN_PUBLIC_XEN_COMPAT_H__
 
-#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030208
+#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030209
 
 #if defined(__XEN__) || defined(__XEN_TOOLS__)
 /* Xen is built with matching headers and implements the latest interface. */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] numa: Extend MEMOP_ allocation functions to take a node argument., Xen patchbot-unstable <=