]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Use the CPU index in capabilities to map NUMA node to cpu list.
authorOsier Yang <jyang@redhat.com>
Sat, 12 May 2012 12:52:45 +0000 (20:52 +0800)
committerOsier Yang <jyang@redhat.com>
Tue, 15 May 2012 02:09:43 +0000 (10:09 +0800)
On some of the NUMA platforms, the CPU index in each NUMA node
grows non-consecutive. While on other platforms, it can be inconsecutive,
E.g.

% numactl --hardware
available: 4 nodes (0-3)
node 0 cpus: 0 4 8 12 16 20 24 28
node 0 size: 131058 MB
node 0 free: 86531 MB
node 1 cpus: 1 5 9 13 17 21 25 29
node 1 size: 131072 MB
node 1 free: 127070 MB
node 2 cpus: 2 6 10 14 18 22 26 30
node 2 size: 131072 MB
node 2 free: 127758 MB
node 3 cpus: 3 7 11 15 19 23 27 31
node 3 size: 131072 MB
node 3 free: 127226 MB
node distances:
node   0   1   2   3
  0:  10  20  20  20
  1:  20  10  20  20
  2:  20  20  10  20
  3:  20  20  20  10

This patch is to fix the problem by using the CPU index in
caps->host.numaCell[i]->cpus[i] to set the bitmask instead of
assuming the CPU index of the NUMA nodes are always sequential.

src/qemu/qemu_process.c

index d226067a1a75eca333d5852a895876acfb0f8396..eebee66f8a3803b6748dff599a2a36972d5696ba 100644 (file)
@@ -1825,20 +1825,13 @@ qemuProcessInitCpuAffinity(struct qemud_driver *driver,
     if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
         VIR_DEBUG("Set CPU affinity with advisory nodeset from numad");
         /* numad returns the NUMA node list, convert it to cpumap */
-        int prev_total_ncpus = 0;
         for (i = 0; i < driver->caps->host.nnumaCell; i++) {
             int j;
             int cur_ncpus = driver->caps->host.numaCell[i]->ncpus;
             if (nodemask[i]) {
-                for (j = prev_total_ncpus;
-                     j < cur_ncpus + prev_total_ncpus &&
-                     j < maxcpu &&
-                     j < VIR_DOMAIN_CPUMASK_LEN;
-                     j++) {
-                    VIR_USE_CPU(cpumap, j);
-                }
+                for (j = 0; j < cur_ncpus; j++)
+                    VIR_USE_CPU(cpumap, driver->caps->host.numaCell[i]->cpus[j]);
             }
-            prev_total_ncpus += cur_ncpus;
         }
     } else {
         VIR_DEBUG("Set CPU affinity with specified cpuset");