xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dulloor <dulloor@gmail.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH 02/11] [XEN] exact node request
Date: Sun, 4 Apr 2010 15:30:14 -0400	[thread overview]
Message-ID: <y2k940bcfd21004041230z6f0f7733p2ab82ed93043d5db@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

Currently, xen might allocate memory from other nodes (if allocation
from requested node fails) even if the memflags specifies a node. For
initial memory allocation and certain other purposes, stricter
semantics are needed. The patch implements exact_node_request flag for
this.

-dulloor

Signed-off-by: Dulloor Rao <dulloor@gatech.edu>

[-- Attachment #2: xen-02-exact-node-request.patch --]
[-- Type: text/x-patch, Size: 3008 bytes --]

diff -r dd0cdf8346df -r 9a3efacb9e39 xen/common/memory.c
--- a/xen/common/memory.c	Tue Mar 30 18:03:27 2010 -0400
+++ b/xen/common/memory.c	Tue Mar 30 18:51:31 2010 -0400
@@ -545,6 +545,8 @@
         }
 
         args.memflags |= MEMF_node(XENMEMF_get_node(reservation.mem_flags));
+        if (reservation.mem_flags & XENMEMF_exact_node_request)
+            args.memflags |= MEMF_exact_node;
 
         if ( op == XENMEM_populate_physmap
              && (reservation.mem_flags & XENMEMF_populate_on_demand) )
diff -r dd0cdf8346df -r 9a3efacb9e39 xen/common/page_alloc.c
--- a/xen/common/page_alloc.c	Tue Mar 30 18:03:27 2010 -0400
+++ b/xen/common/page_alloc.c	Tue Mar 30 18:51:31 2010 -0400
@@ -300,11 +300,16 @@
     unsigned int i, j, zone = 0;
     unsigned int num_nodes = num_online_nodes();
     unsigned long request = 1UL << order;
+    unsigned int exact_node_request;
     cpumask_t extra_cpus_mask, mask;
     struct page_info *pg;
 
-    if ( node == NUMA_NO_NODE )
+    if ( node == NUMA_NO_NODE ) {
         node = cpu_to_node(smp_processor_id());
+        exact_node_request = 0;
+    } else {
+        exact_node_request = (memflags & MEMF_exact_node); 
+    }
 
     ASSERT(node >= 0);
     ASSERT(zone_lo <= zone_hi);
@@ -342,13 +347,15 @@
                     goto found;
         } while ( zone-- > zone_lo ); /* careful: unsigned zone may wrap */
 
+        if (exact_node_request)
+            goto not_found;
         /* Pick next node, wrapping around if needed. */
         node = next_node(node, node_online_map);
         if (node == MAX_NUMNODES)
             node = first_node(node_online_map);
     }
 
- try_tmem:
+try_tmem:
     /* Try to free memory from tmem */
     if ( (pg = tmem_relinquish_pages(order,memflags)) != NULL )
     {
@@ -357,6 +364,7 @@
         return pg;
     }
 
+not_found:
     /* No suitable memory blocks. Fail the request. */
     spin_unlock(&heap_lock);
     return NULL;
diff -r dd0cdf8346df -r 9a3efacb9e39 xen/include/public/memory.h
--- a/xen/include/public/memory.h	Tue Mar 30 18:03:27 2010 -0400
+++ b/xen/include/public/memory.h	Tue Mar 30 18:51:31 2010 -0400
@@ -52,6 +52,8 @@
 #define XENMEMF_get_node(x) ((((x) >> 8) - 1) & 0xffu)
 /* Flag to populate physmap with populate-on-demand entries */
 #define XENMEMF_populate_on_demand (1<<16)
+#define XENMEMF_exact_node_request  (1 << 17)
+#define XENMEMF_exact_node(n) (XENMEMF_node(n) | XENMEMF_exact_node_request)
 #endif
 
 struct xen_memory_reservation {
diff -r dd0cdf8346df -r 9a3efacb9e39 xen/include/xen/mm.h
--- a/xen/include/xen/mm.h	Tue Mar 30 18:03:27 2010 -0400
+++ b/xen/include/xen/mm.h	Tue Mar 30 18:51:31 2010 -0400
@@ -80,6 +80,8 @@
 #define  MEMF_populate_on_demand (1U<<_MEMF_populate_on_demand)
 #define _MEMF_tmem        2
 #define  MEMF_tmem        (1U<<_MEMF_tmem)
+#define _MEMF_exact_node  3
+#define  MEMF_exact_node  (1U << _MEMF_exact_node)
 #define _MEMF_node        8
 #define  MEMF_node(n)     ((((n)+1)&0xff)<<_MEMF_node)
 #define _MEMF_bits        24

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

             reply	other threads:[~2010-04-04 19:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-04 19:30 Dulloor [this message]
2010-04-07 11:51 ` [PATCH 02/11] [XEN] exact node request Andre Przywara

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=y2k940bcfd21004041230z6f0f7733p2ab82ed93043d5db@mail.gmail.com \
    --to=dulloor@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).