xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <juergen.gross@ts.fujitsu.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH 5 of 5] Support new xl command cpupool-numa-split
Date: Thu, 09 Dec 2010 13:39:41 +0100	[thread overview]
Message-ID: <ec1ba7d9f2fe7af83df5.1291898381@nehalem1> (raw)
In-Reply-To: <patchbomb.1291898376@nehalem1>

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

New xl command cpupool-numa-split which will create one cpupool for each
numa node of the machine. Can be called only if no other cpupools than Pool 0
are defined. After creation the cpupools can be managed as usual.

Signed-off-by: juergen.gross@ts.fujitsu.com


3 files changed, 123 insertions(+)
tools/libxl/xl.h          |    1 
tools/libxl/xl_cmdimpl.c  |  117 +++++++++++++++++++++++++++++++++++++++++++++
tools/libxl/xl_cmdtable.c |    5 +



[-- Attachment #2: xen-work-5.patch --]
[-- Type: text/x-patch, Size: 5162 bytes --]

# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# Date 1291891853 -3600
# Node ID ec1ba7d9f2fe7af83df5bae80e461beed6c43972
# Parent  0a2df9e227c678d3dfcd04b19925ced8714a2524
Support new xl command cpupool-numa-split

New xl command cpupool-numa-split which will create one cpupool for each
numa node of the machine. Can be called only if no other cpupools than Pool 0
are defined. After creation the cpupools can be managed as usual.

Signed-off-by: juergen.gross@ts.fujitsu.com

diff -r 0a2df9e227c6 -r ec1ba7d9f2fe tools/libxl/xl.h
--- a/tools/libxl/xl.h	Thu Dec 09 13:37:32 2010 +0100
+++ b/tools/libxl/xl.h	Thu Dec 09 11:50:53 2010 +0100
@@ -86,6 +86,7 @@ int main_cpupoolcpuadd(int argc, char **
 int main_cpupoolcpuadd(int argc, char **argv);
 int main_cpupoolcpuremove(int argc, char **argv);
 int main_cpupoolmigrate(int argc, char **argv);
+int main_cpupoolnumasplit(int argc, char **argv);
 
 void help(const char *command);
 
diff -r 0a2df9e227c6 -r ec1ba7d9f2fe tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Dec 09 13:37:32 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Thu Dec 09 11:50:53 2010 +0100
@@ -5933,3 +5933,120 @@ int main_cpupoolmigrate(int argc, char *
 
     return -libxl_cpupool_movedomain(&ctx, poolid, domid);
 }
+
+int main_cpupoolnumasplit(int argc, char **argv)
+{
+    int ret;
+    int opt;
+    int p;
+    int c;
+    int n;
+    uint32_t poolid;
+    int schedid;
+    int n_pools;
+    int node;
+    char name[16];
+    libxl_uuid uuid;
+    libxl_cpumap cpumap;
+    libxl_cpupoolinfo *poolinfo;
+    libxl_topologyinfo topology;
+
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("cpupool-numa-split");
+            return 0;
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+    ret = 0;
+
+    poolinfo = libxl_list_cpupool(&ctx, &n_pools);
+    if (!poolinfo) {
+        fprintf(stderr, "error getting cpupool info\n");
+        return -ERROR_NOMEM;
+    }
+    poolid = poolinfo[0].poolid;
+    schedid = poolinfo[0].sched_id;
+    for (p = 0; p < n_pools; p++) {
+        libxl_cpupoolinfo_destroy(poolinfo + p);
+    }
+    if (n_pools > 1) {
+        fprintf(stderr, "splitting not possible, already cpupools in use\n");
+        return -ERROR_FAIL;
+    }
+
+    if (libxl_get_topologyinfo(&ctx, &topology)) {
+        fprintf(stderr, "libxl_get_topologyinfo failed\n");
+        return -ERROR_FAIL;
+    }
+
+    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+        fprintf(stderr, "Failed to allocate cpumap\n");
+        libxl_topologyinfo_destroy(&topology);
+        return -ERROR_FAIL;
+    }
+
+    /* Reset Pool-0 to 1st node: first add cpus, then remove cpus to avoid
+       a cpupool without cpus in between */
+
+    node = topology.nodemap.array[0];
+    if (libxl_cpupool_cpuadd_node(&ctx, 0, node, &n)) {
+        fprintf(stderr, "error on adding cpu to Pool 0\n");
+        return -ERROR_FAIL;
+    }
+
+    snprintf(name, 15, "Pool-node%d", node);
+    ret = -libxl_cpupool_rename(&ctx, name, 0);
+    if (ret) {
+        fprintf(stderr, "error on renaming Pool 0\n");
+        goto out;
+    }
+
+    for (c = 0; c < topology.nodemap.entries; c++) {
+        if (topology.nodemap.array[c] == node) {
+            topology.nodemap.array[c] = LIBXL_CPUARRAY_INVALID_ENTRY;
+        }
+    }
+
+    for (c = 0; c < topology.nodemap.entries; c++) {
+        if (topology.nodemap.array[c] == LIBXL_CPUARRAY_INVALID_ENTRY) {
+            continue;
+        }
+
+        node = topology.nodemap.array[c];
+        ret = -libxl_cpupool_cpuremove_node(&ctx, 0, node, &n);
+        if (ret) {
+            fprintf(stderr, "error on removing cpu from Pool 0\n");
+            goto out;
+        }
+
+        snprintf(name, 15, "Pool-node%d", node);
+        libxl_uuid_generate(&uuid);
+        ret = -libxl_create_cpupool(&ctx, name, schedid, cpumap, &uuid, &poolid);
+        if (ret) {
+            fprintf(stderr, "error on creating cpupool\n");
+            goto out;
+        }
+
+        ret = -libxl_cpupool_cpuadd_node(&ctx, 0, node, &n);
+        if (ret) {
+            fprintf(stderr, "error on adding cpus to cpupool\n");
+            goto out;
+        }
+
+        for (p = c; p < topology.nodemap.entries; p++) {
+            if (topology.nodemap.array[p] == node) {
+                topology.nodemap.array[p] = LIBXL_CPUARRAY_INVALID_ENTRY;
+            }
+        }
+    }
+
+out:
+    libxl_topologyinfo_destroy(&topology);
+    libxl_cpumap_destroy(&cpumap);
+
+    return ret;
+}
diff -r 0a2df9e227c6 -r ec1ba7d9f2fe tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Thu Dec 09 13:37:32 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c	Thu Dec 09 11:50:53 2010 +0100
@@ -378,6 +378,11 @@ struct cmd_spec cmd_table[] = {
       "Moves a domain into a CPU pool",
       "<Domain> <CPU Pool>",
     },
+    { "cpupool-numa-split",
+      &main_cpupoolnumasplit,
+      "Splits up the machine into one CPU pool per NUMA node",
+      "",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

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

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

  parent reply	other threads:[~2010-12-09 12:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-23  2:08 [PATCH] fix build error in libxl Zhang, Yang Z
2011-01-03 13:40 ` Christoph Egger
2010-12-09 12:39   ` [PATCH 0 of 5] support of NUMA topology in xl Juergen Gross
2010-12-09 12:39     ` [PATCH 1 of 5] Support getting topology info in libxl Juergen Gross
2010-12-09 13:11       ` Gianni Tedesco
2010-12-09 13:19         ` Juergen Gross
2010-12-10 17:30           ` Ian Jackson
2010-12-09 12:39     ` [PATCH 2 of 5] support topolgy info in xl info Juergen Gross
2010-12-09 12:39     ` [PATCH 3 of 5] Extend cpupools to support numa Juergen Gross
2010-12-09 12:39     ` [PATCH 4 of 5] Support renaming of cpupools Juergen Gross
2010-12-09 12:39     ` Juergen Gross [this message]
2010-12-17  6:09     ` [PATCH 0 of 5] support of NUMA topology in xl Juergen Gross
2010-12-17 17:46       ` Ian Jackson
2010-12-17 17:50         ` Keir Fraser
2010-12-17 21:42         ` [PATCH] xl: fix compilation warning on libxl.c Wei Huang
2011-01-05 23:39           ` [PATCH] xl: fix compilation warning on libxl.c [and 2 more messages] Ian Jackson
  -- strict thread matches above, loose matches on Subject: below --
2010-12-09 10:51 [PATCH 0 of 5] support of NUMA topology in xl Juergen Gross
2010-12-09 10:51 ` [PATCH 5 of 5] Support new xl command cpupool-numa-split Juergen Gross

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=ec1ba7d9f2fe7af83df5.1291898381@nehalem1 \
    --to=juergen.gross@ts.fujitsu.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).