All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Harper <ryanh@us.ibm.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH 3/6] xen: modify memory ops to be NUMA-aware
Date: Tue, 11 Jul 2006 10:36:41 -0500	[thread overview]
Message-ID: <20060711153641.GI1694@us.ibm.com> (raw)

This patch modifies three memory operations to be NUMA-aware:

increase_reservation
populate_physmap
memory_exchange

These three operations request memory from the domain heap and have been
modified to distribute the request across the physical cpus of the
target domain evenly.  This make memory local to the physical cpus
within the domain available for the guest.

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
diffstat output:
 memory.c |   42 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 34 insertions(+), 8 deletions(-)

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
---
diff -r ac0a7a5a6425 xen/common/memory.c
--- a/xen/common/memory.c	Mon Jul  3 17:12:37 2006
+++ b/xen/common/memory.c	Sat Jul  8 12:27:19 2006
@@ -40,6 +40,12 @@
     struct page_info *page;
     unsigned long i;
     xen_pfn_t mfn;
+    int max_vcpu_id = 0;
+    struct vcpu *v;
+
+    for_each_vcpu (d, v) 
+        if ( v->vcpu_id > max_vcpu_id )
+            max_vcpu_id = v->vcpu_id;
 
     if ( !guest_handle_is_null(extent_list) &&
          !guest_handle_okay(extent_list, nr_extents) )
@@ -56,9 +62,11 @@
             *preempted = 1;
             return i;
         }
-
-        if ( unlikely((page = alloc_domheap_pages(
-            d, extent_order, memflags)) == NULL) )
+        /* spread each allocation across the total number of 
+         * vcpus allocated to this domain */
+        if ( unlikely((page = __alloc_domheap_pages( d, 
+            (d->vcpu[i % (max_vcpu_id+1)])->processor,
+            extent_order, memflags )) == NULL) ) 
         {
             DPRINTK("Could not allocate order=%d extent: "
                     "id=%d memflags=%x (%ld of %d)\n",
@@ -91,6 +99,12 @@
     unsigned long i, j;
     xen_pfn_t gpfn;
     xen_pfn_t mfn;
+    int max_vcpu_id = 0;
+    struct vcpu *v;
+
+    for_each_vcpu (d, v) 
+        if ( v->vcpu_id > max_vcpu_id )
+            max_vcpu_id = v->vcpu_id;
 
     if ( !guest_handle_okay(extent_list, nr_extents) )
         return 0;
@@ -110,8 +124,11 @@
         if ( unlikely(__copy_from_guest_offset(&gpfn, extent_list, i, 1)) )
             goto out;
 
-        if ( unlikely((page = alloc_domheap_pages(
-            d, extent_order, memflags)) == NULL) )
+        /* spread each allocation across the total number of 
+         * vcpus allocated to this domain */
+        if ( unlikely((page = __alloc_domheap_pages( d, 
+            (d->vcpu[i % (max_vcpu_id+1)])->processor,
+            extent_order, memflags )) == NULL) ) 
         {
             DPRINTK("Could not allocate order=%d extent: "
                     "id=%d memflags=%x (%ld of %d)\n",
@@ -293,10 +310,11 @@
     unsigned long in_chunk_order, out_chunk_order;
     xen_pfn_t     gpfn, gmfn, mfn;
     unsigned long i, j, k;
-    unsigned int  memflags = 0;
+    unsigned int  memflags = 0, max_vcpu_id = 0;
     long          rc = 0;
     struct domain *d;
     struct page_info *page;
+    struct vcpu *v;
 
     if ( copy_from_guest(&exch, arg, 1) )
         return -EFAULT;
@@ -367,6 +385,11 @@
     }
     d = current->domain;
 
+    /* calc max_vcpu_id */
+    for_each_vcpu (d, v) 
+        if ( v->vcpu_id > max_vcpu_id )
+            max_vcpu_id = v->vcpu_id;
+
     for ( i = 0; i < (exch.in.nr_extents >> in_chunk_order); i++ )
     {
         if ( hypercall_preempt_check() )
@@ -412,8 +435,11 @@
         /* Allocate a chunk's worth of anonymous output pages. */
         for ( j = 0; j < (1UL << out_chunk_order); j++ )
         {
-            page = alloc_domheap_pages(
-                NULL, exch.out.extent_order, memflags);
+            /* spread each allocation across the total number of 
+             * vcpus allocated to this domain */
+            page = __alloc_domheap_pages( NULL, 
+                  (d->vcpu[j % (max_vcpu_id+1)])->processor,
+                  exch.out.extent_order, memflags);
             if ( unlikely(page == NULL) )
             {
                 rc = -ENOMEM;
ryanh@us.ibm.com

             reply	other threads:[~2006-07-11 15:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-11 15:36 Ryan Harper [this message]
2006-07-17 17:16 ` [PATCH 3/6] xen: modify memory ops to be NUMA-aware Ryan Harper
  -- strict thread matches above, loose matches on Subject: below --
2006-07-31 19:10 Ryan Harper
2006-08-17 22:42 ` Ryan Harper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060711153641.GI1694@us.ibm.com \
    --to=ryanh@us.ibm.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.