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] Topology-info sysctl cleanups.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Topology-info sysctl cleanups.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Apr 2010 14:55:42 -0700
Delivery-date: Tue, 13 Apr 2010 15:05:21 -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 1271147934 -3600
# Node ID 2a4970daad74449a8f827ea649c9f3f35ecba2f4
# Parent  d2d8805868f1ee2359d7f5be665af1dde610f1ee
Topology-info sysctl cleanups.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/libxc/xc_pm.c               |   20 ----------
 tools/libxc/xenctrl.h             |   16 --------
 tools/misc/xenpm.c                |   52 +++++++++++++--------------
 tools/python/xen/lowlevel/xc/xc.c |   48 +++++++++++++++++-------
 tools/python/xen/xend/XendNode.py |   18 ++++-----
 xen/arch/x86/sysctl.c             |   73 +++++++++++---------------------------
 xen/drivers/acpi/pmstat.c         |   52 ---------------------------
 xen/include/public/sysctl.h       |   25 +------------
 8 files changed, 93 insertions(+), 211 deletions(-)

diff -r d2d8805868f1 -r 2a4970daad74 tools/libxc/xc_pm.c
--- a/tools/libxc/xc_pm.c       Tue Apr 13 08:37:16 2010 +0100
+++ b/tools/libxc/xc_pm.c       Tue Apr 13 09:38:54 2010 +0100
@@ -326,26 +326,6 @@ int xc_get_cpufreq_avgfreq(int xc_handle
     return ret;
 }
 
-int xc_get_cputopo(int xc_handle, struct xc_get_cputopo *info)
-{
-    int rc;
-    DECLARE_SYSCTL;
-
-    sysctl.cmd = XEN_SYSCTL_pm_op;
-    sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_get_cputopo;
-    sysctl.u.pm_op.cpuid = 0;
-    set_xen_guest_handle( sysctl.u.pm_op.u.get_topo.cpu_to_core,
-                         info->cpu_to_core );
-    set_xen_guest_handle( sysctl.u.pm_op.u.get_topo.cpu_to_socket,
-                         info->cpu_to_socket );
-    sysctl.u.pm_op.u.get_topo.max_cpus = info->max_cpus;
-
-    rc = do_sysctl(xc_handle, &sysctl);
-    info->nr_cpus = sysctl.u.pm_op.u.get_topo.nr_cpus;
-
-    return rc;
-}
-
 /* value:   0 - disable sched_smt_power_savings 
             1 - enable sched_smt_power_savings
  */
diff -r d2d8805868f1 -r 2a4970daad74 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Tue Apr 13 08:37:16 2010 +0100
+++ b/tools/libxc/xenctrl.h     Tue Apr 13 09:38:54 2010 +0100
@@ -1302,22 +1302,6 @@ int xc_set_cpufreq_para(int xc_handle, i
 int xc_set_cpufreq_para(int xc_handle, int cpuid,
                         int ctrl_type, int ctrl_value);
 int xc_get_cpufreq_avgfreq(int xc_handle, int cpuid, int *avg_freq);
-
-struct xc_get_cputopo {
-     /* IN: maximum addressable entry in
-      * the caller-provided cpu_to_core/socket.
-      */
-    uint32_t max_cpus;
-    uint32_t *cpu_to_core;
-    uint32_t *cpu_to_socket;
-
-    /* OUT: number of cpus returned
-     * If OUT is greater than IN then the cpu_to_core/socket is truncated!
-     */
-    uint32_t nr_cpus;
-};
-
-int xc_get_cputopo(int xc_handle, struct xc_get_cputopo *info);
 
 int xc_set_sched_opt_smt(int xc_handle, uint32_t value);
 int xc_set_vcpu_migration_delay(int xc_handle, uint32_t value);
diff -r d2d8805868f1 -r 2a4970daad74 tools/misc/xenpm.c
--- a/tools/misc/xenpm.c        Tue Apr 13 08:37:16 2010 +0100
+++ b/tools/misc/xenpm.c        Tue Apr 13 09:38:54 2010 +0100
@@ -842,32 +842,32 @@ void cpu_topology_func(int argc, char *a
 {
     uint32_t cpu_to_core[MAX_NR_CPU];
     uint32_t cpu_to_socket[MAX_NR_CPU];
-    struct xc_get_cputopo info;
-    int i, ret;
-
-    info.cpu_to_core = cpu_to_core;
-    info.cpu_to_socket = cpu_to_socket;
-    info.max_cpus = MAX_NR_CPU;
-    ret = xc_get_cputopo(xc_fd, &info);
-    if (!ret)
-    {
-        printf("CPU\tcore\tsocket\n");
-        for (i=0; i<info.nr_cpus; i++)
-        {
-            if ( info.cpu_to_core[i] != INVALID_TOPOLOGY_ID &&
-                    info.cpu_to_socket[i] != INVALID_TOPOLOGY_ID )
-            {
-            printf("CPU%d\t %d\t %d\n", i, info.cpu_to_core[i],
-                    info.cpu_to_socket[i]);
-            }
-        }
-    }
-    else
-    {
-        printf("Can not get Xen CPU topology!\n");
-    }
-
-    return ;
+    uint32_t cpu_to_node[MAX_NR_CPU];
+    xc_topologyinfo_t info = { 0 };
+    int i;
+
+    set_xen_guest_handle(info.cpu_to_core, cpu_to_core);
+    set_xen_guest_handle(info.cpu_to_socket, cpu_to_socket);
+    set_xen_guest_handle(info.cpu_to_node, cpu_to_node);
+    info.max_cpu_index = MAX_NR_CPU-1;
+
+    if ( xc_topologyinfo(xc_fd, &info) )
+    {
+        printf("Can not get Xen CPU topology: %d\n", errno);
+        return;
+    }
+
+    if ( info.max_cpu_index > (MAX_NR_CPU-1) )
+        info.max_cpu_index = MAX_NR_CPU-1;
+
+    printf("CPU\tcore\tsocket\tnode\n");
+    for ( i = 0; i < info.max_cpu_index; i++ )
+    {
+        if ( cpu_to_core[i] == INVALID_TOPOLOGY_ID )
+            continue;
+        printf("CPU%d\t %d\t %d\t %d\n",
+               i, cpu_to_core[i], cpu_to_socket[i], cpu_to_node[i]);
+    }
 }
 
 void set_sched_smt_func(int argc, char *argv[])
diff -r d2d8805868f1 -r 2a4970daad74 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Tue Apr 13 08:37:16 2010 +0100
+++ b/tools/python/xen/lowlevel/xc/xc.c Tue Apr 13 09:38:54 2010 +0100
@@ -1191,7 +1191,7 @@ static PyObject *pyxc_topologyinfo(XcObj
 static PyObject *pyxc_topologyinfo(XcObject *self)
 {
 #define MAX_CPU_INDEX 255
-    xc_topologyinfo_t tinfo;
+    xc_topologyinfo_t tinfo = { 0 };
     int i, max_cpu_index;
     PyObject *ret_obj;
     PyObject *cpu_to_core_obj, *cpu_to_socket_obj, *cpu_to_node_obj;
@@ -1199,7 +1199,6 @@ static PyObject *pyxc_topologyinfo(XcObj
     xc_cpu_to_socket_t socketmap[MAX_CPU_INDEX + 1];
     xc_cpu_to_node_t nodemap[MAX_CPU_INDEX + 1];
 
-
     set_xen_guest_handle(tinfo.cpu_to_core, coremap);
     set_xen_guest_handle(tinfo.cpu_to_socket, socketmap);
     set_xen_guest_handle(tinfo.cpu_to_node, nodemap);
@@ -1218,19 +1217,38 @@ static PyObject *pyxc_topologyinfo(XcObj
     cpu_to_node_obj = PyList_New(0);
     for ( i = 0; i < max_cpu_index; i++ )
     {
-        PyObject *pyint;
-
-        pyint = PyInt_FromLong(coremap[i]);
-        PyList_Append(cpu_to_core_obj, pyint);
-        Py_DECREF(pyint);
-
-        pyint = PyInt_FromLong(socketmap[i]);
-        PyList_Append(cpu_to_socket_obj, pyint);
-        Py_DECREF(pyint);
-
-        pyint = PyInt_FromLong(nodemap[i]);
-        PyList_Append(cpu_to_node_obj, pyint);
-        Py_DECREF(pyint);
+        if ( coremap[i] == INVALID_TOPOLOGY_ID )
+        {
+            PyList_Append(cpu_to_core_obj, Py_None);
+        }
+        else
+        {
+            PyObject *pyint = PyInt_FromLong(coremap[i]);
+            PyList_Append(cpu_to_core_obj, pyint);
+            Py_DECREF(pyint);
+        }
+
+        if ( socketmap[i] == INVALID_TOPOLOGY_ID )
+        {
+            PyList_Append(cpu_to_socket_obj, Py_None);
+        }
+        else
+        {
+            PyObject *pyint = PyInt_FromLong(socketmap[i]);
+            PyList_Append(cpu_to_socket_obj, pyint);
+            Py_DECREF(pyint);
+        }
+
+        if ( nodemap[i] == INVALID_TOPOLOGY_ID )
+        {
+            PyList_Append(cpu_to_node_obj, Py_None);
+        }
+        else
+        {
+            PyObject *pyint = PyInt_FromLong(nodemap[i]);
+            PyList_Append(cpu_to_node_obj, pyint);
+            Py_DECREF(pyint);
+        }
     }
 
     ret_obj = Py_BuildValue("{s:i}", "max_cpu_index", max_cpu_index);
diff -r d2d8805868f1 -r 2a4970daad74 tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Tue Apr 13 08:37:16 2010 +0100
+++ b/tools/python/xen/xend/XendNode.py Tue Apr 13 09:38:54 2010 +0100
@@ -879,16 +879,16 @@ class XendNode:
         return self.format_pairs(self.list_to_rangepairs(list))
 
     def format_cpu_to_core_socket_node(self, tinfo):
-        try:
-            nr_cpus=tinfo['max_cpu_index']
-            str='\ncpu:    core    socket     node\n'
-            for i in range(0, nr_cpus):
+        max_cpu_index=tinfo['max_cpu_index']
+        str='\ncpu:    core    socket     node\n'
+        for i in range(0, max_cpu_index+1):
+            try:
                 str+='%3d:%8d %8d %8d\n' % (i, 
-                                          tinfo['cpu_to_core'][i],
-                                          tinfo['cpu_to_socket'][i],
-                                          tinfo['cpu_to_node'][i])
-        except:
-            str='none\n'
+                                            tinfo['cpu_to_core'][i],
+                                            tinfo['cpu_to_socket'][i],
+                                            tinfo['cpu_to_node'][i])
+            except:
+                pass
         return str[:-1];
 
     def format_numa_info(self, ninfo):
diff -r d2d8805868f1 -r 2a4970daad74 xen/arch/x86/sysctl.c
--- a/xen/arch/x86/sysctl.c     Tue Apr 13 08:37:16 2010 +0100
+++ b/xen/arch/x86/sysctl.c     Tue Apr 13 09:38:54 2010 +0100
@@ -80,64 +80,37 @@ long arch_do_sysctl(
         
     case XEN_SYSCTL_topologyinfo:
     {
-        uint32_t i, max_cpu_index;
-        XEN_GUEST_HANDLE_64(uint32) cpu_to_core_arr;
-        XEN_GUEST_HANDLE_64(uint32) cpu_to_socket_arr;
-        XEN_GUEST_HANDLE_64(uint32) cpu_to_node_arr;
-
+        uint32_t i, max_cpu_index, last_online_cpu;
         xen_sysctl_topologyinfo_t *ti = &sysctl->u.topologyinfo;
 
-        max_cpu_index = ti->max_cpu_index;
-        cpu_to_core_arr = ti->cpu_to_core;
-        cpu_to_socket_arr = ti->cpu_to_socket;
-        cpu_to_node_arr = ti->cpu_to_node;
-
-        memset(ti, 0, sizeof(*ti));
-        ti->cpu_to_core = cpu_to_core_arr;
-        ti->cpu_to_socket = cpu_to_socket_arr;
-        ti->cpu_to_node = cpu_to_node_arr;
-
-        max_cpu_index = min_t(uint32_t, max_cpu_index, num_online_cpus());
-        ti->max_cpu_index = max_cpu_index;
-
-        ret = 0;
-
-        for ( i = 0; i < max_cpu_index; i++ )
-        {
-            if ( !guest_handle_is_null(cpu_to_core_arr) )
+        last_online_cpu = last_cpu(cpu_online_map);
+        max_cpu_index = min_t(uint32_t, ti->max_cpu_index, last_online_cpu);
+        ti->max_cpu_index = last_online_cpu;
+
+        for ( i = 0; i <= max_cpu_index; i++ )
+        {
+            if ( !guest_handle_is_null(ti->cpu_to_core) )
             {
                 uint32_t core = cpu_online(i) ? cpu_to_core(i) : ~0u;
-                if ( copy_to_guest_offset(cpu_to_core_arr, i, &core, 1) )
-                {
-                    ret = -EFAULT;
-                    break;
-                }
-            }
-            if ( !guest_handle_is_null(cpu_to_socket_arr) )
+                if ( copy_to_guest_offset(ti->cpu_to_core, i, &core, 1) )
+                    break;
+            }
+            if ( !guest_handle_is_null(ti->cpu_to_socket) )
             {
                 uint32_t socket = cpu_online(i) ? cpu_to_socket(i) : ~0u;
-                if ( copy_to_guest_offset(cpu_to_socket_arr, i, &socket, 1) )
-                {
-                    ret = -EFAULT;
-                    break;
-                }
-            }
-            if ( !guest_handle_is_null(cpu_to_node_arr) )
+                if ( copy_to_guest_offset(ti->cpu_to_socket, i, &socket, 1) )
+                    break;
+            }
+            if ( !guest_handle_is_null(ti->cpu_to_node) )
             {
                 uint32_t node = cpu_online(i) ? cpu_to_node(i) : ~0u;
-                if ( copy_to_guest_offset(cpu_to_node_arr, i, &node, 1) )
-                {
-                    ret = -EFAULT;
-                    break;
-                }
-            }
-        }
-
-        if (ret)
-            break;
- 
-        if ( copy_to_guest(u_sysctl, sysctl, 1) )
-            ret = -EFAULT;
+                if ( copy_to_guest_offset(ti->cpu_to_node, i, &node, 1) )
+                    break;
+            }
+        }
+
+        ret = ((i <= max_cpu_index) || copy_to_guest(u_sysctl, sysctl, 1))
+            ? -EFAULT : 0;
     }
     break;
 
diff -r d2d8805868f1 -r 2a4970daad74 xen/drivers/acpi/pmstat.c
--- a/xen/drivers/acpi/pmstat.c Tue Apr 13 08:37:16 2010 +0100
+++ b/xen/drivers/acpi/pmstat.c Tue Apr 13 09:38:54 2010 +0100
@@ -419,52 +419,6 @@ static int get_cpufreq_avgfreq(struct xe
     return 0;
 }
 
-static int get_cputopo (struct xen_sysctl_pm_op *op)
-{
-    uint32_t i, nr_cpus;
-    XEN_GUEST_HANDLE_64(uint32) cpu_to_core_arr;
-    XEN_GUEST_HANDLE_64(uint32) cpu_to_socket_arr;
-    int arr_size, ret=0;
-
-    cpu_to_core_arr = op->u.get_topo.cpu_to_core;
-    cpu_to_socket_arr = op->u.get_topo.cpu_to_socket;
-    arr_size= min_t(uint32_t, op->u.get_topo.max_cpus, NR_CPUS);
-
-    if ( guest_handle_is_null( cpu_to_core_arr ) ||
-            guest_handle_is_null(  cpu_to_socket_arr) )
-    {
-        ret = -EINVAL;
-        goto out;
-    }
-
-    nr_cpus = 0;
-    for ( i = 0; i < arr_size; i++ )
-    {
-        uint32_t core, socket;
-        if ( cpu_online(i) )
-        {
-            core = cpu_to_core(i);
-            socket = cpu_to_socket(i);
-            nr_cpus = i;
-        }
-        else
-        {
-            core = socket = INVALID_TOPOLOGY_ID;
-        }
-
-        if ( copy_to_guest_offset(cpu_to_core_arr, i, &core, 1) ||
-                copy_to_guest_offset(cpu_to_socket_arr, i, &socket, 1))
-        {
-            ret = -EFAULT;
-            goto out;
-        }
-    }
-
-    op->u.get_topo.nr_cpus = nr_cpus + 1;
-out:
-    return ret;
-}
-
 int do_pm_op(struct xen_sysctl_pm_op *op)
 {
     int ret = 0;
@@ -510,12 +464,6 @@ int do_pm_op(struct xen_sysctl_pm_op *op
         break;
     }
 
-    case XEN_SYSCTL_pm_op_get_cputopo:
-    {
-        ret = get_cputopo(op);
-        break;
-    }
-
     case XEN_SYSCTL_pm_op_set_sched_opt_smt:
     {
         uint32_t saved_value;
diff -r d2d8805868f1 -r 2a4970daad74 xen/include/public/sysctl.h
--- a/xen/include/public/sysctl.h       Tue Apr 13 08:37:16 2010 +0100
+++ b/xen/include/public/sysctl.h       Tue Apr 13 09:38:54 2010 +0100
@@ -336,22 +336,6 @@ struct xen_set_cpufreq_para {
     uint32_t ctrl_value;
 };
 
-/* Get physical CPU topology information. */
-#define INVALID_TOPOLOGY_ID  (~0U)
-struct xen_get_cputopo {
-     /* IN: maximum addressable entry in
-      * the caller-provided cpu_to_core/socket.
-      */
-    uint32_t max_cpus;
-    XEN_GUEST_HANDLE_64(uint32) cpu_to_core;
-    XEN_GUEST_HANDLE_64(uint32) cpu_to_socket;
-
-    /* OUT: number of cpus returned
-     * If OUT is greater than IN then the cpu_to_core/socket is truncated!
-     */
-    uint32_t nr_cpus;
-};
-
 struct xen_sysctl_pm_op {
     #define PM_PARA_CATEGORY_MASK      0xf0
     #define CPUFREQ_PARA               0x10
@@ -361,9 +345,6 @@ struct xen_sysctl_pm_op {
     #define SET_CPUFREQ_GOV            (CPUFREQ_PARA | 0x02)
     #define SET_CPUFREQ_PARA           (CPUFREQ_PARA | 0x03)
     #define GET_CPUFREQ_AVGFREQ        (CPUFREQ_PARA | 0x04)
-
-    /* get CPU topology */
-    #define XEN_SYSCTL_pm_op_get_cputopo  0x20
 
     /* set/reset scheduler power saving option */
     #define XEN_SYSCTL_pm_op_set_sched_opt_smt    0x21
@@ -387,7 +368,6 @@ struct xen_sysctl_pm_op {
         struct xen_set_cpufreq_gov  set_gov;
         struct xen_set_cpufreq_para set_para;
         uint64_aligned_t get_avgfreq;
-        struct xen_get_cputopo      get_topo;
         uint32_t                    set_sched_opt_smt;
         uint32_t                    get_max_cstate;
         uint32_t                    set_max_cstate;
@@ -477,8 +457,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockp
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_lockprof_op_t);
 
 #define XEN_SYSCTL_topologyinfo         16 
+#define INVALID_TOPOLOGY_ID  (~0U)
 struct xen_sysctl_topologyinfo {
-
     /*
      * IN: maximum addressable entry in the caller-provided cpu_to_core, 
      * cpu_to_socket & cpu_to_node arrays.
@@ -498,8 +478,7 @@ struct xen_sysctl_topologyinfo {
      */
     XEN_GUEST_HANDLE_64(uint32) cpu_to_core;
     XEN_GUEST_HANDLE_64(uint32) cpu_to_socket;
-    XEN_GUEST_HANDLE_64(uint32) cpu_to_node;  /* node_number */
-
+    XEN_GUEST_HANDLE_64(uint32) cpu_to_node;
 };
 typedef struct xen_sysctl_topologyinfo xen_sysctl_topologyinfo_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_topologyinfo_t);

_______________________________________________
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] Topology-info sysctl cleanups., Xen patchbot-unstable <=